You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reverse engineering from docs/SECURITY_IOCTL_RESTRICTION.md documentation (Section 2: Production IOCTLs Added)
Description
Driver MUST provide production-safe, high-level IOCTL abstractions (IOCTL_AVB_ADJUST_FREQUENCY and IOCTL_AVB_GET_CLOCK_CONFIG) to replace raw register access IOCTLs for PTP clock control in production builds.
MUST add case labels in device.c IOCTL routing switch: Location: Lines ~277-298 (per earlier reverse engineering) Routing Pattern:
caseIOCTL_AVB_ADJUST_FREQUENCY:
caseIOCTL_AVB_GET_CLOCK_CONFIG:
// Route to avb_integration_fixed.c handlerstatus=HandleAvbIoctl(FilterModuleContext, Request);
break;
Acceptance Criteria
AC-1: IOCTL_AVB_ADJUST_FREQUENCY Implementation
Given driver hardware is initialized When user-mode application calls IOCTL_AVB_ADJUST_FREQUENCY Then TIMINCA register is updated with new increment And previous TIMINCA value is returned in current_increment And status is NDIS_STATUS_SUCCESS
AC-2: IOCTL_AVB_GET_CLOCK_CONFIG Implementation
Given driver hardware is initialized When user-mode application calls IOCTL_AVB_GET_CLOCK_CONFIG Then current SYSTIM, TIMINCA, TSAUXC values are returned And clock rate is correctly detected And status is NDIS_STATUS_SUCCESS
AC-3: Works in Release Build
Given driver compiled in Release mode (NDEBUG defined) When production test application is run Then both IOCTLs are available and functional And no raw register access IOCTLs are present
AC-4: Input Validation
Given user provides invalid increment_ns (e.g., 0 or 100) WhenIOCTL_AVB_ADJUST_FREQUENCY is called Then status is NDIS_STATUS_INVALID_PARAMETER And TIMINCA register is NOT modified
AC-5: Test Coverage
Given production test file ptp_clock_control_production_test.c When test is executed Then all 4 test cases pass:
Test 1: Clock configuration query
Test 2: Frequency adjustment (5 different values)
Test 3: Timestamp setting and retrieval
Test 4: Clock stability measurement
Non-Functional Requirements
NFR-1: Performance (P1 - Important)
Latency: IOCTL handler completes in <1ms (register reads/writes are fast)
Throughput: Supports 100+ calls/second (unlikely to be performance bottleneck)
NFR-2: Reliability (P0 - Critical)
Atomicity: TIMINCA writes are atomic (single 32-bit write)
Error Handling: All error paths return meaningful status codes
Hardware State: Handlers verify hardware is initialized before access
NFR-3: Security (P0 - Critical)
No Arbitrary Access: Users cannot access arbitrary register offsets
Validated Input: All parameters validated before hardware writes
Production Safe: Available in Release builds without exposing raw registers
Implementation Status
✅ Completed (Per Documentation)
According to docs/SECURITY_IOCTL_RESTRICTION.md:
✅ Structures defined in include/avb_ioctl.h
✅ Handlers implemented in avb_integration_fixed.c
✅ Routing added to device.c
✅ Production test created: tools/avb_test/ptp_clock_control_production_test.c
⚠️ Verification Needed
Grep search found:
✅ AVB_FREQUENCY_REQUEST used in avb_integration_fixed.c (lines 724, 734)
✅ AVB_CLOCK_CONFIG used in multiple test files (20+ matches)
✅ IOCTL_AVB_ADJUST_FREQUENCY defined in include/avb_ioctl.h (line 73)
⚠️IOCTL_AVB_GET_CLOCK_CONFIG changed from code 39 to 45 (line 74) - Why? Action Required: Verify IOCTL code 45 change reason and update all test files.
🔍 IOCTL Code Mismatch Investigation
Current Code: 45 (per include/avb_ioctl.h line 74) Documented Code: 39 (per docs/SECURITY_IOCTL_RESTRICTION.md) Possible Reason (per inline comment):
#defineIOCTL_AVB_GET_CLOCK_CONFIG _NDIS_CONTROL_CODE(45, METHOD_BUFFERED)
/* Changed from 39 to 45 - testing if 0x9C blocked */
Impact: Test applications using code 39 will fail. This is Bug #4 continuation!
Test Requirements
Test-1: Frequency Adjustment
// Test various clock incrementsAVB_FREQUENCY_REQUESTfreq_req;
for (intns=6; ns <= 10; ns++) {
freq_req.increment_ns=ns;
freq_req.increment_frac=0;
BOOLsuccess=DeviceIoControl(h, IOCTL_AVB_ADJUST_FREQUENCY, ...);
assert(success&&freq_req.status==NDIS_STATUS_SUCCESS);
}
# Compile test in Release mode
cl /nologo /W4 /O2 /DNDEBUG /Zi /I include ptp_clock_control_production_test.c
# Should compile and run successfully
.\ptp_clock_control_production_test.exe
Abstraction Layer: High-level IOCTL API decouples user-mode from register details
Security Boundary: Production builds cannot bypass validated abstractions
Maintainability: Register layout changes isolated to driver internals
Migration Impact
Medium Impact on Test Code:
Files using IOCTL_AVB_READ/WRITE_REGISTER for TIMINCA/SYSTIM/TSAUXC must migrate
Migration guide provided in docs/SECURITY_IOCTL_RESTRICTION.md Section 4 Affected Test Files (from Section 4):
tools/avb_test/tsauxc_toggle_test.c - Uses raw TSAUXC writes
tools/avb_test/ptp_clock_control_test.c - Uses raw TIMINCA writes Migration Effort: 1-2 hours per test file (replace raw register patterns with IOCTL calls)
Requirement Type
Functional Requirement (IOCTL API)
Discovered Via
Reverse engineering from
docs/SECURITY_IOCTL_RESTRICTION.mddocumentation (Section 2: Production IOCTLs Added)Description
Driver MUST provide production-safe, high-level IOCTL abstractions (
IOCTL_AVB_ADJUST_FREQUENCYandIOCTL_AVB_GET_CLOCK_CONFIG) to replace raw register access IOCTLs for PTP clock control in production builds.Business Context
Functional Requirements
FR-1: IOCTL_AVB_ADJUST_FREQUENCY (Code 38)
Purpose: Adjust PTP clock frequency (replaces raw TIMINCA register writes)
IOCTL Definition:
Input/Output Structure:
Behavior:
increment_nsmust be reasonable for clock rate (e.g., 6-10ns for 125MHz)increment_ns + (increment_frac / 2^32)current_increment)increment_nsandincrement_fracstatus = NDIS_STATUS_SUCCESSon successstatus = NDIS_STATUS_INVALID_PARAMETERif increment out of rangestatus = NDIS_STATUS_ADAPTER_NOT_READYif hardware not initializedUsage Example:
FR-2: IOCTL_AVB_GET_CLOCK_CONFIG (Code 45)
Purpose: Query complete clock configuration (replaces raw register reads)
IOCTL Definition:
Note: Originally code 39, changed to 45 due to suspected Windows blocking (per inline comment in code).
Output Structure:
Behavior:
systimtimincatsauxcclock_rate_mhzstatus = NDIS_STATUS_SUCCESSon successstatus = NDIS_STATUS_ADAPTER_NOT_READYif hardware not initializedUsage Example:
FR-3: Always Available in All Builds
MUST NOT be guarded by
#ifndef NDEBUGor any conditional compilation.Rationale:
FR-4: Handler Implementation
MUST implement handlers in
avb_integration_fixed.c:Location: Lines ~724-780 (per grep search showing
AVB_FREQUENCY_REQUESTusage)Handler Pattern:
FR-5: IOCTL Routing in device.c
MUST add case labels in
device.cIOCTL routing switch:Location: Lines ~277-298 (per earlier reverse engineering)
Routing Pattern:
Acceptance Criteria
AC-1: IOCTL_AVB_ADJUST_FREQUENCY Implementation
Given driver hardware is initialized
When user-mode application calls
IOCTL_AVB_ADJUST_FREQUENCYThen TIMINCA register is updated with new increment
And previous TIMINCA value is returned in
current_incrementAnd status is
NDIS_STATUS_SUCCESSAC-2: IOCTL_AVB_GET_CLOCK_CONFIG Implementation
Given driver hardware is initialized
When user-mode application calls
IOCTL_AVB_GET_CLOCK_CONFIGThen current SYSTIM, TIMINCA, TSAUXC values are returned
And clock rate is correctly detected
And status is
NDIS_STATUS_SUCCESSAC-3: Works in Release Build
Given driver compiled in Release mode (NDEBUG defined)
When production test application is run
Then both IOCTLs are available and functional
And no raw register access IOCTLs are present
AC-4: Input Validation
Given user provides invalid
increment_ns(e.g., 0 or 100)When
IOCTL_AVB_ADJUST_FREQUENCYis calledThen status is
NDIS_STATUS_INVALID_PARAMETERAnd TIMINCA register is NOT modified
AC-5: Test Coverage
Given production test file
ptp_clock_control_production_test.cWhen test is executed
Then all 4 test cases pass:
Non-Functional Requirements
NFR-1: Performance (P1 - Important)
NFR-2: Reliability (P0 - Critical)
NFR-3: Security (P0 - Critical)
Implementation Status
✅ Completed (Per Documentation)
According to
docs/SECURITY_IOCTL_RESTRICTION.md:include/avb_ioctl.havb_integration_fixed.cdevice.ctools/avb_test/ptp_clock_control_production_test.cGrep search found:
AVB_FREQUENCY_REQUESTused inavb_integration_fixed.c(lines 724, 734)AVB_CLOCK_CONFIGused in multiple test files (20+ matches)IOCTL_AVB_ADJUST_FREQUENCYdefined ininclude/avb_ioctl.h(line 73)IOCTL_AVB_GET_CLOCK_CONFIGchanged from code 39 to 45 (line 74) - Why?Action Required: Verify IOCTL code 45 change reason and update all test files.
🔍 IOCTL Code Mismatch Investigation
Current Code: 45 (per
include/avb_ioctl.hline 74)Documented Code: 39 (per
docs/SECURITY_IOCTL_RESTRICTION.md)Possible Reason (per inline comment):
Impact: Test applications using code 39 will fail. This is Bug #4 continuation!
Test Requirements
Test-1: Frequency Adjustment
Test-2: Clock Configuration Query
Test-3: Clock Stability
Test-4: Release Build Compatibility
Traceability
Traces to (Parent Requirements)
Traces to: #23
Verified by (Test Cases)
Verified by: #319 (TEST-PTP-CTRL-001: Verify PTP Clock Control IOCTLs)
Related Requirements
Implements
Architecture Impact
Migration Impact
Medium Impact on Test Code:
IOCTL_AVB_READ/WRITE_REGISTERfor TIMINCA/SYSTIM/TSAUXC must migratedocs/SECURITY_IOCTL_RESTRICTION.mdSection 4Affected Test Files (from Section 4):
tools/avb_test/tsauxc_toggle_test.c- Uses raw TSAUXC writestools/avb_test/ptp_clock_control_test.c- Uses raw TIMINCA writesMigration Effort: 1-2 hours per test file (replace raw register patterns with IOCTL calls)
References
docs/SECURITY_IOCTL_RESTRICTION.mdPriority Justification
P0 (Critical) because:
ptp_clock_control_production_test.c)Open Issues
IOCTL_AVB_GET_CLOCK_CONFIGchanged from 39 to 45? ("testing if 0x9C blocked")Issue Created By: Reverse Engineering Analysis
Discovery Date: 2025-12-07
Standards: IEEE 1588-2008 (PTP), ISO/IEC/IEEE 29148:2018 (Requirements Engineering)