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

initrd : do initgroups on chroot #3521

Merged
merged 1 commit into from
Nov 11, 2023
Merged

Conversation

shjala
Copy link
Member

@shjala shjala commented Oct 25, 2023

check for errors on security sensitive calls and call initgroups() to remove root from the new uid supplementary groups.

This should go after #3512, so I keep it as WIP for now.

@shjala shjala requested a review from rene as a code owner October 25, 2023 10:21
@codecov
Copy link

codecov bot commented Oct 25, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (2279125) 19.47% compared to head (1e21211) 19.48%.
Report is 4 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3521   +/-   ##
=======================================
  Coverage   19.47%   19.48%           
=======================================
  Files         231      231           
  Lines       50220    50220           
=======================================
+ Hits         9781     9784    +3     
+ Misses      39720    39718    -2     
+ Partials      719      718    -1     

see 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@shjala shjala changed the title [wip] initrd : do initgroups on chroot initrd : do initgroups on chroot Nov 7, 2023
@shjala shjala requested a review from rouming November 7, 2023 12:24
Copy link
Contributor

@eriknordmark eriknordmark left a comment

Choose a reason for hiding this comment

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

LGTM

return -1;
}

if (mount("proc", "/proc", "proc", 0, NULL) != 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this mount is some leftover from former implementation... we are already mounting the /proc in the initrd script, as well as the other needed filesystems (/dev, /sys) before call the chroot. I think we can safely remove this mount and just expect that /proc will be ready like the others... as the POSIX chroot does, it won't mount any of these filesystems by himself...

Copy link
Member Author

Choose a reason for hiding this comment

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

clone() is called with CLONE_NEWPID so AFAIR mounting it allows the launched process and all the subsequent childs have their own (limited) view of the /proc.

Copy link
Member Author

@shjala shjala Nov 8, 2023

Choose a reason for hiding this comment

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

now that you mentioned it I think we should create a new mnt namespace for the child, because this mount affects the parent process too.

I will send another PR for that.

check for errors on security sensitive calls and call initgroups() to remove
root from the new uid supplementary groups.

Signed-off-by: Shahriyar Jalayeri <[email protected]>
@shjala
Copy link
Member Author

shjala commented Nov 8, 2023

moved initgroups() before chroot() because it reads from /etc/group.

Copy link
Contributor

@rene rene left a comment

Choose a reason for hiding this comment

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

I got it @shjala , LGTM now...

@eriknordmark eriknordmark merged commit 53e2d24 into lf-edge:master Nov 11, 2023
22 of 29 checks passed
@shjala shjala deleted the chroot branch November 16, 2023 10:36
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.

3 participants