* [RFC PATCH] vfs: add MNT_NOFOLLOW flag to umount(2)
@ 2010-02-04 17:36 Miklos Szeredi
0 siblings, 0 replies; 4+ messages in thread
From: Miklos Szeredi @ 2010-02-04 17:36 UTC (permalink / raw)
To: viro; +Cc: linux-fsdevel, linux-kernel, Eugene Teo, Michael Kerrisk
From: Miklos Szeredi <mszeredi@suse.cz>
Add a new MNT_NOFOLLOW flag to umount(2). This is needed to prevent
symlink attacks in unprivileged unmounts (fuse, samba, ncpfs).
Additionally, return -EINVAL if an unknown flag is encountered. This
makes it possible for the caller to determine if a flag is supported
or not (at least on kernels with this patch).
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
fs/namespace.c | 9 ++++++++-
include/linux/fs.h | 1 +
2 files changed, 9 insertions(+), 1 deletion(-)
Index: linux-2.6/fs/namespace.c
===================================================================
--- linux-2.6.orig/fs/namespace.c 2010-01-29 09:21:45.000000000 +0100
+++ linux-2.6/fs/namespace.c 2010-02-04 10:03:08.000000000 +0100
@@ -1121,8 +1121,15 @@ SYSCALL_DEFINE2(umount, char __user *, n
{
struct path path;
int retval;
+ int lookup_flags = 0;
- retval = user_path(name, &path);
+ if (flags & ~(MNT_FORCE | MNT_DETACH | MNT_EXPIRE | MNT_NOFOLLOW))
+ return -EINVAL;
+
+ if (!(flags & MNT_NOFOLLOW))
+ lookup_flags |= LOOKUP_FOLLOW;
+
+ retval = user_path_at(AT_FDCWD, name, lookup_flags, &path);
if (retval)
goto out;
retval = -EINVAL;
Index: linux-2.6/include/linux/fs.h
===================================================================
--- linux-2.6.orig/include/linux/fs.h 2010-01-22 08:46:57.000000000 +0100
+++ linux-2.6/include/linux/fs.h 2010-02-04 09:57:39.000000000 +0100
@@ -1305,6 +1305,7 @@ extern int send_sigurg(struct fown_struc
#define MNT_FORCE 0x00000001 /* Attempt to forcibily umount */
#define MNT_DETACH 0x00000002 /* Just detach from the tree */
#define MNT_EXPIRE 0x00000004 /* Mark for expiry */
+#define MNT_NOFOLLOW 0x00000008 /* Don't follow symlink on umount */
extern struct list_head super_blocks;
extern spinlock_t sb_lock;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC PATCH] vfs: add MNT_NOFOLLOW flag to umount(2)
[not found] <eae9I-mz-1@gated-at.bofh.it>
@ 2010-02-04 18:48 ` Bodo Eggert
2010-02-05 8:14 ` Miklos Szeredi
0 siblings, 1 reply; 4+ messages in thread
From: Bodo Eggert @ 2010-02-04 18:48 UTC (permalink / raw)
To: Miklos Szeredi, viro, linux-fsdevel, linux-kernel, Eugene Teo,
Michael Kerrisk
Miklos Szeredi <miklos@szeredi.hu> wrote:
> Additionally, return -EINVAL if an unknown flag is encountered. This
> makes it possible for the caller to determine if a flag is supported
> or not (at least on kernels with this patch).
There should be a guaranteed-to-be-invalid flag or flag-combination in
order to safely detect this feature.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC PATCH] vfs: add MNT_NOFOLLOW flag to umount(2)
2010-02-04 18:48 ` [RFC PATCH] vfs: add MNT_NOFOLLOW flag to umount(2) Bodo Eggert
@ 2010-02-05 8:14 ` Miklos Szeredi
2010-02-08 10:37 ` Bodo Eggert
0 siblings, 1 reply; 4+ messages in thread
From: Miklos Szeredi @ 2010-02-05 8:14 UTC (permalink / raw)
To: 7eggert; +Cc: miklos, viro, linux-fsdevel, linux-kernel, eugene, mtk.manpages
On Thu, 04 Feb 2010, Bodo Eggert wrote:
> Miklos Szeredi <miklos@szeredi.hu> wrote:
>
> > Additionally, return -EINVAL if an unknown flag is encountered. This
> > makes it possible for the caller to determine if a flag is supported
> > or not (at least on kernels with this patch).
>
> There should be a guaranteed-to-be-invalid flag or flag-combination in
> order to safely detect this feature.
It's difficult though, because the app would have to make sure the
detection itself would reliably fail, and with a different error.
Simply checking the kernel version might be easier.
Thanks,
Miklos
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC PATCH] vfs: add MNT_NOFOLLOW flag to umount(2)
2010-02-05 8:14 ` Miklos Szeredi
@ 2010-02-08 10:37 ` Bodo Eggert
0 siblings, 0 replies; 4+ messages in thread
From: Bodo Eggert @ 2010-02-08 10:37 UTC (permalink / raw)
To: Miklos Szeredi
Cc: 7eggert, viro, linux-fsdevel, linux-kernel, eugene, mtk.manpages
[-- Attachment #1: Type: TEXT/PLAIN, Size: 986 bytes --]
On Fri, 5 Feb 2010, Miklos Szeredi wrote:
> On Thu, 04 Feb 2010, Bodo Eggert wrote:
>> Miklos Szeredi <miklos@szeredi.hu> wrote:
>>
>>> Additionally, return -EINVAL if an unknown flag is encountered. This
>>> makes it possible for the caller to determine if a flag is supported
>>> or not (at least on kernels with this patch).
>>
>> There should be a guaranteed-to-be-invalid flag or flag-combination in
>> order to safely detect this feature.
>
> It's difficult though, because the app would have to make sure the
> detection itself would reliably fail, and with a different error.
>
> Simply checking the kernel version might be easier.
Yes, that's exactly what I intend to make possible:
| ret = umount("/tmp/mkstmp", UMOUNT_IMPOSSIBLE_FLAG);
| if (ret != -1 || errno != -EINVAL)
| goto extended_mount_flags_are_not_supported;
Checking the kernel version is a bad idea, because the application might
be portable, or features might be backported. ¢¢
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-02-08 10:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <eae9I-mz-1@gated-at.bofh.it>
2010-02-04 18:48 ` [RFC PATCH] vfs: add MNT_NOFOLLOW flag to umount(2) Bodo Eggert
2010-02-05 8:14 ` Miklos Szeredi
2010-02-08 10:37 ` Bodo Eggert
2010-02-04 17:36 Miklos Szeredi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).