images: fix segfault when mounting without cap_sys_admin#25244
images: fix segfault when mounting without cap_sys_admin#25244openshift-merge-bot[bot] merged 1 commit intocontainers:mainfrom
Conversation
|
this should be made more robust, and make sure we never access |
Luap99
left a comment
There was a problem hiding this comment.
Why do we duplicate this complex reexec logic here? No other command need this so why should mount need it...
I guess because the goal is/was to get the cannot run command %q in rootless mode, must execute podman unshare first message for rootless users so they know they only see the mount point in the unshare env...
So if that is the case I think if we just drop that code and instead return an error if we are not already part in the user namesapce instead as this is what the code tries to do today
Also you are missing ContainerMount() which used the same broken code.
we have this ugly hack because we still want mount to succeed for |
|
the reason for this is that "mount" doesn't work from the host, users get confused that they need to With vfs instead it doesn't matter, because the "mount" point is accessible from the host since there is no mount |
commit c6fe5e5 rearranged the code so that it accesses the store before checking if the current process has CAP_SYS_ADMIN. Restore the check and augment it to also check for CAP_SYS_ADMIN. Closes: containers#25241 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
372a5e5 to
2f71072
Compare
thanks, fixed now |
|
lgtm |
|
Is it really that important to special case a storage driver there? I mean I agree that we should not just break that for backwards compatibility reasons but maybe we can should consider removing this when we have the chance or at rework it in a way where not duplicate this fragile logic. |
|
|
||
| func (ic *ContainerEngine) ContainerMount(ctx context.Context, nameOrIDs []string, options entities.ContainerMountOptions) ([]*entities.ContainerMountReport, error) { | ||
| if os.Geteuid() != 0 { | ||
| hasCapSysAdmin, err := unshare.HasCapSysAdmin() |
There was a problem hiding this comment.
Can this error happen without something critical going wrong?
There was a problem hiding this comment.
we have this function called in different places, and the result is cached. So if it fails, even if we ignore it here, it will be caught somewhere else
I don't think it is such an important case, except the error code is helpful if users don't see the mount after running |
Yes we can keep that, but this is unrelated to duplicating the reexec. Lines 98 to 105 in 2cbb5fe |
Luap99
left a comment
There was a problem hiding this comment.
anyway let's get this merged, it fixes the panic.
/lgtm
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: giuseppe, Luap99 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
24b686e
into
containers:main
commit c6fe5e5 rearranged the code so that it accesses the store before checking if the current process has CAP_SYS_ADMIN.
Restore the check and augment it to also check for CAP_SYS_ADMIN.
Closes: #25241
Does this PR introduce a user-facing change?