Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Setting correct UTC time is rejected #28629

Closed
bluebin14 opened this issue Aug 10, 2023 · 1 comment · Fixed by #28668
Closed

[BUG] Setting correct UTC time is rejected #28629

bluebin14 opened this issue Aug 10, 2023 · 1 comment · Fixed by #28668
Labels
bug Something isn't working needs triage spec Mismatch between spec and implementation time sync Implementation of the Time Synchronization cluster

Comments

@bluebin14
Copy link
Contributor

bluebin14 commented Aug 10, 2023

Reproduction steps

Assuming Thread firmware development environment but the bug is not platform specific.

After building and flashing new firmware, setting the correct UTC time by the controller is rejected for "GMT offset" hours. Example for CET timezone, build made at 10:25:15 local time which is 08:25:15 UTC time:

10:52:24.153 503343.698        4  0 I: 489 [TS]Last Known Good Time: [unknown]
10:52:24.160 503343.705        7  0 I: 493 [TS]Setting Last Known Good Time to firmware build time 2023-08-10T10:25:15
...
10:56:26.787 503572.332        5  0 I: 229130 [TS]Last Known Good Time: 2023-08-10T10:25:15
10:56:26.794 503572.339        7  0 I: 229135 [TS]New proposed Last Known Good Time: 2023-08-10T08:56:26
10:56:26.799 503572.344        5  0 E: 229142 [TS]Failed to update Last Known Good Time: 2f
10:56:26.801 503572.346        2  0 E: 229147 [FP]Failed to update Known Good Time: 2f

The strange problem is caused by the SDK setting the build time to local time (the __TIME__ macro gives local time), then during runtime the same integer gets compared with an actual incoming UTC time and ends up with the command being rejected for 2 hours.
This can be a silent error (current commissioners ignore failure if setting the time fails, despite it being a possible security issue) or a functional error (e.g. in CET timezone TC-TIMESYNC-2.2 fails for 2 hours after firmware build, then it works).
Regarding comparing incoming time with current time and enforcing it to be greater can also be misused: if controller A sets UTC time to e.g. year 2033 (which is incorrect) no other controllers will be able to set it correctly afterwards. An attribute that cannot be corrected.

Bug prevalence

always

GitHub hash of the SDK that was being used

ba490f6

Platform

nrf

Platform Version(s)

No response

Anything else?

No response

@bluebin14
Copy link
Contributor Author

A workaround would be to subtract 1 day from result of GetFirmwareBuildChipEpochTime since the current result is wrong anyway, that would fix the above symptoms @bzbarsky-apple

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage spec Mismatch between spec and implementation time sync Implementation of the Time Synchronization cluster
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants