Skip to content

Use mount_setattr() in bind_mount()#756

Open
xxyzz wants to merge 1 commit into
containers:mainfrom
xxyzz:mount_setattr
Open

Use mount_setattr() in bind_mount()#756
xxyzz wants to merge 1 commit into
containers:mainfrom
xxyzz:mount_setattr

Conversation

@xxyzz
Copy link
Copy Markdown

@xxyzz xxyzz commented May 31, 2026

Fix #754, all tests passed. I also update some GitHub Actions.

Comment thread bind-mount.c Outdated
.attr_set = MOUNT_ATTR_NOSUID | (devices ? 0 : MOUNT_ATTR_NODEV) |
(readonly ? MOUNT_ATTR_RDONLY : 0),
};
if (mount_setattr(dest_fd, "",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

musl does not have a library function for mount_setattr yet. Also older (before 2024?) glibc versions. We should ifdef-provide our own definition.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Wrapper function added.

@xxyzz xxyzz force-pushed the mount_setattr branch 2 times, most recently from 69fdb9e to f65b3ec Compare May 31, 2026 08:38
@charmander
Copy link
Copy Markdown

I also update some GitHub Actions.

Were they related somehow?

@xxyzz
Copy link
Copy Markdown
Author

xxyzz commented May 31, 2026

Were they related somehow?

No, these actions are just too outdated so I updated them.

@rusty-snake
Copy link
Copy Markdown
Contributor

What was wrong with has_mount_setattr?

The code changes have some AI smell to me.

@xxyzz
Copy link
Copy Markdown
Author

xxyzz commented Jun 1, 2026

I feel has_mount_setattr is kind of redundant now and the code resembles your previous suggestion in issue 650. I did ask gemini some questions because I'm not sure how to be compatible with musl and the #define lines are modified from the chatbot's answer. Is the change good enough or maybe it need further improvement?

@rusty-snake
Copy link
Copy Markdown
Contributor

Is the change good enough or maybe it need further improvement?

It needs a review from.someone who is actually responsible for the codebase.

@ao2
Copy link
Copy Markdown
Contributor

ao2 commented Jun 2, 2026

I also update some GitHub Actions.

Were they related somehow?

Please move unrelated changes to a separate commit, or even to a separate PR, to have a more focused review, and in general avoid unnecessary space changes.

Also the commit message of the main change should mention the rationale from #754 and also have lines like:

...

Fixes: https://github.com/containers/bubblewrap/issues/754
Signed-off-by: YOUR NAME <email>

Ideally with your real name, but I don't think this is a strict requirement 😄

Comment thread utils.h Outdated
const char *src);

#ifndef __NR_mount_setattr
#define __NR_mount_setattr 442
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please note that syscall numbers in linux are platform specific, so this is not general enough. E.g. on alpha __NR_mount_setattr is 552, see https://github.com/torvalds/linux/blob/6f3ed7fec72fc8979b2a8c7219c0a9fcfc8d07b5/arch/alpha/kernel/syscalls/syscall.tbl#L484

What about having a simpler approach like done for pivot_root? So that we require that __NR_mount_setattr is defined but we support the cases where the system function mount_setattr is not.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Code updated. I think I've read that function before but somehow forgot it...

Fixes: containers#754

Signed-off-by: xxyzz <gitpull@protonmail.com>
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.

Use mount_setattr() on newer kernels, instead of walking mount hierarchy the hard way

4 participants