diff mbox series

[v1,1/1] fs: Consider capabilities relative to namespace for linkat permission check

Message ID 20231110170615.2168372-2-cmirabil@redhat.com (mailing list archive)
State New
Headers show
Series fs: Consider capabilities relative to namespace for linkat permission check | expand

Commit Message

Charles Mirabile Nov. 10, 2023, 5:06 p.m. UTC
Previously, the check for CAP_DAC_READ_SEARCH when trying to use
AT_EMPTY_PATH happened relative to the init process's namespace
rather than the namespace of the current process. This seems like
an oversight because it meant that processes in new namespaces
could not ever use AT_EMPTY_PATH with linkat even if they have
CAP_DAC_READ_SEARCH within their namespace.

Signed-off-by: Charles Mirabile <cmirabil@redhat.com>
---
 fs/namei.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/fs/namei.c b/fs/namei.c
index 71c13b2990b4..0848aa563988 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -4628,7 +4628,7 @@  int do_linkat(int olddfd, struct filename *old, int newdfd,
 	 * This ensures that not everyone will be able to create
 	 * handlink using the passed filedescriptor.
 	 */
-	if (flags & AT_EMPTY_PATH && !capable(CAP_DAC_READ_SEARCH)) {
+	if (flags & AT_EMPTY_PATH && !ns_capable(current_user_ns(), CAP_DAC_READ_SEARCH)) {
 		error = -ENOENT;
 		goto out_putnames;
 	}