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

Fix Brave Ads base::Time::FromLocalExplode always returns false from Linux sandbox on non UTC+0 timezones #20169

Closed
aseren opened this issue Dec 20, 2021 · 6 comments

Comments

@aseren
Copy link

aseren commented Dec 20, 2021

base::Time::FromLocalExpolode uses libc mktime call which requires access to /etc/timezone file: https://source.chromium.org/chromium/chromium/src/+/main:base/time/time_exploded_posix.cc;l=107?q=time_exploded_pos&ss=chromium
But access to filesystem is restricted from sandbox, so mktime uses UTC+0 timezone.

The problem is that base::Time::FromLocalExpolode verifies the results of mktime using base::Time::LocalExpolode function which uses local timezone (not UTC+0), because it calls libc localtime_r function. In fact localtime_r function call is intercepted in browser process thus returns time in local timezone. See:
https://bugs.chromium.org/p/chromium/issues/detail?id=16800
https://codereview.chromium.org/165011
https://source.chromium.org/chromium/chromium/src/+/main:sandbox/linux/services/libc_interceptor.cc;l=225?q=libc_interce&ss=chromium

So if local timezone is not UTC+0 then verification step fails and base::Time::FromLocalExpolode always returns false here:
https://source.chromium.org/chromium/chromium/src/+/main:base/time/time_exploded_posix.cc;l=283?q=time_exploded_pos&ss=chromium

@btlechowski
Copy link

btlechowski commented Feb 15, 2022

The corresponding PR has been merged. This issue can be closed.

@tmancey tmancey changed the title base::Time::FromLocalExpolode always returns false from Linux sandbox on non UTC+0 timezone Fix base::Time::FromLocalExplode always returns false from Linux sandbox on non UTC+0 timezones Apr 13, 2023
@tmancey tmancey changed the title Fix base::Time::FromLocalExplode always returns false from Linux sandbox on non UTC+0 timezones Fix Brave Ads base::Time::FromLocalExplode always returns false from Linux sandbox on non UTC+0 timezones Apr 13, 2023
@tmancey
Copy link
Contributor

tmancey commented Jun 14, 2023

Blocked until ads has moved to the browser process 100%

@tmancey tmancey self-assigned this Oct 22, 2023
@tmancey tmancey removed the blocked label Oct 22, 2023
@tmancey
Copy link
Contributor

tmancey commented Oct 22, 2023

CHECKs were triggered so brave/brave-core#20627 removes those CHECKs.

@tmancey tmancey added blocked and removed blocked labels Oct 22, 2023
@tmancey
Copy link
Contributor

tmancey commented Oct 22, 2023

Closing as won't fix

@tmancey
Copy link
Contributor

tmancey commented Oct 22, 2023

@aseren are we sure the linked bugs are related because they are 14 years old?

@tmancey tmancey added this to Ads Jun 10, 2024
@tmancey tmancey moved this to Done in Ads Jun 10, 2024
@tmancey
Copy link
Contributor

tmancey commented Sep 7, 2024

Resolved by #39307

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

4 participants