Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Issue 2578483002: Namespace sandbox: add check for unprivileged use of CLONE_NEWUSER (Closed)

Created:
4 years ago by Tom (Use chromium acct)
Modified:
3 years, 11 months ago
Reviewers:
sky, mdempsky
CC:
chromium-reviews, jln+watch_chromium.org, Jorge Lucangeli Obes
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Namespace sandbox: add check for unprivileged use of CLONE_NEWUSER Debian 8 restricts use of CLONE_NEWUSER to only processes with CAP_SYS_ADMIN. (https://github.com/semplice/linux/blob/master/debian/patches/debian/add-sysctl-to-disallow-unprivileged-CLONE_NEWUSER-by-default.patch) Chrome was previously checking if the kernel supported CLONE_NEWUSER by running clone(CLONE_NEWUSER, ...) with the same capabilities chrome was launched with. This leads to 2 scenarios: 1. If Chrome was run as root: The check for CLONE_NEWUSER will succeed. Chrome will then set up the namespace sandbox by clone()'ing and dropping CAP_SYS_ADMIN. Subsequent clone()'s with CLONE_NEWUSER will then fail. 2. If Chrome was run as a normal user: The check for CLONE_NEWUSER will fail. Chrome will fallback to using the setuid sandbox. The solution is to simply drop CAP_SYS_ADMIN before the check. In addition, this CL disallows running Chromium as root unless launched with --no-sandbox. BUG=638180 Review-Url: https://codereview.chromium.org/2578483002 Cr-Commit-Position: refs/heads/master@{#443062} Committed: https://chromium.googlesource.com/chromium/src/+/357c17552fb353ea9f3de6eca8a47b2d009067c8

Patch Set 1 #

Total comments: 5

Patch Set 2 : Refactor #

Patch Set 3 : Disallow root even with --user-data-dir #

Total comments: 2

Patch Set 4 : getuid -> geteuid #

Total comments: 5

Patch Set 5 : Allow --no-sandbox #

Patch Set 6 : Add comment #

Unified diffs Side-by-side diffs Delta from patch set Stats (+45 lines, -24 lines) Patch
M chrome/app/generated_resources.grd View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/ui/views/chrome_browser_main_extra_parts_views.cc View 1 2 3 4 2 chunks +3 lines, -3 lines 0 comments Download
M sandbox/linux/services/credentials.cc View 1 2 3 4 4 chunks +36 lines, -18 lines 0 comments Download
M sandbox/linux/suid/client/setuid_sandbox_client.cc View 1 2 3 4 5 1 chunk +5 lines, -2 lines 0 comments Download

Messages

Total messages: 35 (11 generated)
Tom (Use chromium acct)
mdempsky@ PTAL. This finally fixes bug 638180, which has been a top browser-crasher since M53 ...
4 years ago (2016-12-14 04:13:48 UTC) #3
mdempsky
https://codereview.chromium.org/2578483002/diff/1/sandbox/linux/services/credentials.cc File sandbox/linux/services/credentials.cc (right): https://codereview.chromium.org/2578483002/diff/1/sandbox/linux/services/credentials.cc#newcode297 sandbox/linux/services/credentials.cc:297: int ret = sys_unshare(CLONE_NEWUSER); I would probably do: PCHECK(sys_unshare(CLONE_NEWUSER)); ...
4 years ago (2016-12-14 05:11:11 UTC) #4
Tom (Use chromium acct)
https://codereview.chromium.org/2578483002/diff/1/sandbox/linux/services/credentials.cc File sandbox/linux/services/credentials.cc (right): https://codereview.chromium.org/2578483002/diff/1/sandbox/linux/services/credentials.cc#newcode297 sandbox/linux/services/credentials.cc:297: int ret = sys_unshare(CLONE_NEWUSER); On 2016/12/14 05:11:11, mdempsky wrote: ...
4 years ago (2016-12-14 21:10:27 UTC) #5
Tom (Use chromium acct)
ping
4 years ago (2016-12-15 17:22:47 UTC) #6
mdempsky
On 2016/12/14 21:10:27, Tom Anderson wrote: > But we do have a check here: > ...
4 years ago (2016-12-15 17:28:21 UTC) #7
Tom (Use chromium acct)
+sky@ for chrome/app/generated_resources.grd and chrome/browser/ui/views/chrome_browser_main_extra_parts_views.cc On 2016/12/15 17:28:21, mdempsky wrote: > On 2016/12/14 21:10:27, Tom ...
3 years, 11 months ago (2017-01-05 21:35:20 UTC) #9
sky
https://codereview.chromium.org/2578483002/diff/40001/chrome/browser/ui/views/chrome_browser_main_extra_parts_views.cc File chrome/browser/ui/views/chrome_browser_main_extra_parts_views.cc (left): https://codereview.chromium.org/2578483002/diff/40001/chrome/browser/ui/views/chrome_browser_main_extra_parts_views.cc#oldcode79 chrome/browser/ui/views/chrome_browser_main_extra_parts_views.cc:79: const base::CommandLine& command_line = Can you update the description ...
3 years, 11 months ago (2017-01-05 23:21:59 UTC) #10
Tom (Use chromium acct)
https://codereview.chromium.org/2578483002/diff/40001/chrome/browser/ui/views/chrome_browser_main_extra_parts_views.cc File chrome/browser/ui/views/chrome_browser_main_extra_parts_views.cc (left): https://codereview.chromium.org/2578483002/diff/40001/chrome/browser/ui/views/chrome_browser_main_extra_parts_views.cc#oldcode79 chrome/browser/ui/views/chrome_browser_main_extra_parts_views.cc:79: const base::CommandLine& command_line = On 2017/01/05 23:21:59, sky wrote: ...
3 years, 11 months ago (2017-01-06 00:18:38 UTC) #13
sky
Thanks for updating description LGTM
3 years, 11 months ago (2017-01-06 00:36:46 UTC) #14
jln (very slow on Chromium)
Thanks for your work on this, Tom. I agree with Matthew that we should just ...
3 years, 11 months ago (2017-01-06 01:07:30 UTC) #15
Tom (Use chromium acct)
On 2017/01/06 01:07:30, jln (very slow on Chromium) wrote: > Thanks for your work on ...
3 years, 11 months ago (2017-01-06 01:41:02 UTC) #16
jln (very slow on Chromium)
On 2017/01/06 01:41:02, Tom Anderson wrote: > My main concern is if we have the ...
3 years, 11 months ago (2017-01-06 01:45:53 UTC) #17
Tom (Use chromium acct)
On 2017/01/06 01:45:53, jln (very slow on Chromium) wrote: > On 2017/01/06 01:41:02, Tom Anderson ...
3 years, 11 months ago (2017-01-06 02:00:21 UTC) #18
jln (very slow on Chromium)
On 2017/01/06 02:00:21, Tom Anderson wrote: > On 2017/01/06 01:45:53, jln (very slow on Chromium) ...
3 years, 11 months ago (2017-01-09 18:34:38 UTC) #19
Tom (Use chromium acct)
On 2017/01/09 18:34:38, jln (very slow on Chromium) wrote: > On 2017/01/06 02:00:21, Tom Anderson ...
3 years, 11 months ago (2017-01-10 22:15:10 UTC) #21
mdempsky
On 2017/01/10 22:15:10, Tom Anderson wrote: > Do you still think we should permit --no-sandbox? ...
3 years, 11 months ago (2017-01-10 22:31:49 UTC) #22
mdempsky
https://codereview.chromium.org/2578483002/diff/60001/sandbox/linux/services/credentials.cc File sandbox/linux/services/credentials.cc (right): https://codereview.chromium.org/2578483002/diff/60001/sandbox/linux/services/credentials.cc#newcode291 sandbox/linux/services/credentials.cc:291: CHECK(sandbox::Credentials::DropAllCapabilities(proc_fd.get())); nit: You can just use DropAllCapabilities(), which will ...
3 years, 11 months ago (2017-01-10 22:48:23 UTC) #23
Tom (Use chromium acct)
On 2017/01/10 22:31:49, mdempsky wrote: > On 2017/01/10 22:15:10, Tom Anderson wrote: > > Do ...
3 years, 11 months ago (2017-01-10 23:32:03 UTC) #25
Tom (Use chromium acct)
ping. should be ready to land imo :)
3 years, 11 months ago (2017-01-11 19:56:30 UTC) #26
sky
You have a bunch of reviewers listed, who are you pinging? On Wed, Jan 11, ...
3 years, 11 months ago (2017-01-11 21:49:17 UTC) #27
mdempsky
lgtm https://codereview.chromium.org/2578483002/diff/60001/sandbox/linux/suid/client/setuid_sandbox_client.cc File sandbox/linux/suid/client/setuid_sandbox_client.cc (right): https://codereview.chromium.org/2578483002/diff/60001/sandbox/linux/suid/client/setuid_sandbox_client.cc#newcode25 sandbox/linux/suid/client/setuid_sandbox_client.cc:25: base::ScopedFD proc_self_exe(HANDLE_EINTR(open("/proc/self/exe", O_RDONLY))); On 2017/01/10 23:32:03, Tom Anderson ...
3 years, 11 months ago (2017-01-11 22:20:15 UTC) #28
Tom (Use chromium acct)
On 2017/01/11 22:20:15, mdempsky wrote: > lgtm > > https://codereview.chromium.org/2578483002/diff/60001/sandbox/linux/suid/client/setuid_sandbox_client.cc > File sandbox/linux/suid/client/setuid_sandbox_client.cc (right): > ...
3 years, 11 months ago (2017-01-11 22:34:31 UTC) #29
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2578483002/100001
3 years, 11 months ago (2017-01-11 22:35:59 UTC) #32
commit-bot: I haz the power
3 years, 11 months ago (2017-01-11 23:56:46 UTC) #35
Message was sent while issue was closed.
Committed patchset #6 (id:100001) as
https://chromium.googlesource.com/chromium/src/+/357c17552fb353ea9f3de6eca8a4...

Powered by Google App Engine
This is Rietveld 408576698