Skip to content

Fix Y2038 timestamp overflow in sonic-pac authentication manager#19

Open
devin-ai-integration[bot] wants to merge 3 commits intomasterfrom
devin/1770242126-y2038-pac-fix
Open

Fix Y2038 timestamp overflow in sonic-pac authentication manager#19
devin-ai-integration[bot] wants to merge 3 commits intomasterfrom
devin/1770242126-y2038-pac-fix

Conversation

@devin-ai-integration
Copy link

@devin-ai-integration devin-ai-integration bot commented Feb 4, 2026

Why I did it

This PR addresses the Y2038 timestamp overflow problem in the sonic-pac authentication manager. On January 19, 2038, 32-bit signed Unix timestamps will overflow, causing timestamp comparisons and calculations to fail. The affected fields (sessionTime and lastAuthTime) store authentication session timestamps that could be affected by this overflow.

This is part of a coordinated Y2038 fix effort across multiple SONiC submodules (sonic-stp, sonic-sairedis, sonic-pac).

Work item tracking
  • Microsoft ADO (number only):

How I did it

Changed timestamp fields from uint32 to uint64 in three header files:

  • authmgrClientInfo_t.sessionTime and authmgrClientInfo_t.lastAuthTime in auth_mgr_db.h
  • authmgrPortSessionStats_t.sessionTime in auth_mgr_exports.h
  • pac_authenticated_clients_oper_table_t.sessionTime and pac_authenticated_clients_oper_table_t.lastAuthTime in pacoper_common.h

Updates since last revision:

  • Added Y2038 unit tests in src/sonic-pac/tests/test_y2038_timestamp.c covering:
    • Type size verification (uint64 is 8 bytes)
    • Timestamp storage beyond Y2038 overflow point
    • Arithmetic operations at Y2038 boundary
    • Session duration and timeout calculations
    • Struct field size verification
  • Added Y2038 detection signature functions and tests:
    • y2038_overflow_imminent(): Returns true if timestamp is within 1 year of Y2038 overflow
    • y2038_overflow_occurred(): Returns true if timestamp has passed the Y2038 overflow point
    • Y2038_TIMESTAMP_CHECK macro: Compile-time check that timestamp type is at least 64-bit
    • Tests for detection signatures with PAC-specific authmgrClientInfo_t types

How to verify it

  1. Verify the code compiles successfully
  2. Compile and run the new unit tests: gcc -o test_y2038 src/sonic-pac/tests/test_y2038_timestamp.c && ./test_y2038
  3. Verify that all code using these fields handles 64-bit values correctly (especially format specifiers in logging)
  4. Check that serialization/deserialization of these structures is updated if applicable

Important review items:

  • Verify uint64 typedef is properly defined in datatypes.h
  • Check auth_mgr_control.c lines 1722-1730 for overflow handling logic that may need updating (uses 0xffffffff constant)
  • Verify format specifiers in auth_mgr_debug.c (lines 1340, 1342) are updated for 64-bit values
  • Confirm no binary serialization depends on the old struct sizes
  • Verify the new unit tests compile and pass in the full build environment

Which release branch to backport (provide reason below if selected)

  • 202305
  • 202311
  • 202405
  • 202411
  • 202505
  • 202511

Tested branch (Please provide the tested image version)

Description for the changelog

Fix Y2038 timestamp overflow in sonic-pac by changing sessionTime and lastAuthTime fields from uint32 to uint64

Link to config_db schema for YANG module changes

N/A - no YANG model changes

A picture of a cute animal (not mandatory but encouraged)

Additional context

- Change sessionTime from uint32 to uint64 in authmgrClientInfo_t
- Change lastAuthTime from uint32 to uint64 in authmgrClientInfo_t
- Change sessionTime from uint32 to uint64 in authmgrPortSessionStats_t
- Change sessionTime from uint32 to uint64 in pac_authenticated_clients_oper_table_t
- Change lastAuthTime from uint32 to uint64 in pac_authenticated_clients_oper_table_t

These changes prevent timestamp overflow that would occur on
January 19, 2038 when 32-bit signed timestamps exceed INT32_MAX.

Co-Authored-By: Arthur Poon <arthur.poon@windsurf.com>
@devin-ai-integration
Copy link
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Add tests to verify 64-bit timestamp handling:
- Test uint64 type is correctly sized (8 bytes)
- Test sessionTime can hold values beyond Y2038
- Test lastAuthTime can hold values beyond Y2038
- Test timestamp arithmetic doesn't overflow at Y2038 boundary
- Test timestamp comparison works for large values
- Test session duration calculation across Y2038 boundary
- Test authentication timeout calculation
- Test struct field sizes are correct
- Test struct operations with Y2038 values

These tests ensure the Y2038 fix works correctly for timestamps
that would have overflowed with the previous 32-bit implementation.

Co-Authored-By: Arthur Poon <arthur.poon@windsurf.com>
Copy link
Author

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional flags.

Open in Devin Review

Add detection signature functions:
- y2038_overflow_imminent(): Returns true if timestamp is within 1 year of Y2038
- y2038_overflow_occurred(): Returns true if timestamp has passed Y2038
- Y2038_TIMESTAMP_CHECK macro: Compile-time check for 64-bit timestamp types

Add tests for detection signatures:
- Test y2038_overflow_imminent for various timestamp ranges
- Test y2038_overflow_occurred for various timestamp ranges
- Test compile-time check macro
- Test detection with PAC-specific authmgrClientInfo_t types

Co-Authored-By: Arthur Poon <arthur.poon@windsurf.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants