From: Herbert Poetzl <herbert@13thfloor.at>
To: Linus Torvalds <torvalds@osdl.org>, Andrew Morton <akpm@osdl.org>,
Christoph Hellwig <hch@infradead.org>,
Al Viro <viro@ftp.linux.org.uk>,
Linux Kernel ML <linux-kernel@vger.kernel.org>
Subject: [PATCH 5/6] vfs: propagate the vfsmount into *xattr()
Date: Sat, 21 Jan 2006 09:43:01 +0100 [thread overview]
Message-ID: <20060121084301.GF10044@MAIL.13thfloor.at> (raw)
In-Reply-To: <20060121083843.GA10044@MAIL.13thfloor.at>
;
; Bind Mount Extensions
;
; Copyright (C) 2003-2006 Herbert Pötzl <herbert@13thfloor.at>
;
; propagate the vfsmount into both setxattr() and removexattr()
; to allow for vfsmount based checks there ensuring that
; the vfsmount isn't read-only
;
;
; Changelog:
;
; 0.01 - broken out part from bme0.05
;
Signed-off-by: Herbert Pötzl <herbert@13thfloor.at>
diff -NurpP --minimal linux-2.6.16-rc1/fs/xattr.c linux-2.6.16-rc1-bme0.06.2-xa0.01/fs/xattr.c
--- linux-2.6.16-rc1/fs/xattr.c 2006-01-18 06:08:35 +0100
+++ linux-2.6.16-rc1-bme0.06.2-xa0.01/fs/xattr.c 2006-01-21 09:09:20 +0100
@@ -17,6 +17,7 @@
#include <linux/syscalls.h>
#include <linux/module.h>
#include <linux/fsnotify.h>
+#include <linux/mount.h>
#include <asm/uaccess.h>
@@ -167,7 +168,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
*/
static long
setxattr(struct dentry *d, char __user *name, void __user *value,
- size_t size, int flags)
+ size_t size, int flags, struct vfsmount *mnt)
{
int error;
void *kvalue = NULL;
@@ -194,6 +195,9 @@ setxattr(struct dentry *d, char __user *
}
}
+ if (MNT_IS_RDONLY(mnt))
+ return -EROFS;
+
error = vfs_setxattr(d, kname, kvalue, size, flags);
kfree(kvalue);
return error;
@@ -209,7 +213,7 @@ sys_setxattr(char __user *path, char __u
error = user_path_walk(path, &nd);
if (error)
return error;
- error = setxattr(nd.dentry, name, value, size, flags);
+ error = setxattr(nd.dentry, name, value, size, flags, nd.mnt);
path_release(&nd);
return error;
}
@@ -224,7 +228,7 @@ sys_lsetxattr(char __user *path, char __
error = user_path_walk_link(path, &nd);
if (error)
return error;
- error = setxattr(nd.dentry, name, value, size, flags);
+ error = setxattr(nd.dentry, name, value, size, flags, nd.mnt);
path_release(&nd);
return error;
}
@@ -239,7 +243,7 @@ sys_fsetxattr(int fd, char __user *name,
f = fget(fd);
if (!f)
return error;
- error = setxattr(f->f_dentry, name, value, size, flags);
+ error = setxattr(f->f_dentry, name, value, size, flags, f->f_vfsmnt);
fput(f);
return error;
}
@@ -412,7 +416,7 @@ sys_flistxattr(int fd, char __user *list
* Extended attribute REMOVE operations
*/
static long
-removexattr(struct dentry *d, char __user *name)
+removexattr(struct dentry *d, char __user *name, struct vfsmount *mnt)
{
int error;
char kname[XATTR_NAME_MAX + 1];
@@ -423,6 +427,9 @@ removexattr(struct dentry *d, char __use
if (error < 0)
return error;
+ if (MNT_IS_RDONLY(mnt))
+ return -EROFS;
+
return vfs_removexattr(d, kname);
}
@@ -435,7 +442,7 @@ sys_removexattr(char __user *path, char
error = user_path_walk(path, &nd);
if (error)
return error;
- error = removexattr(nd.dentry, name);
+ error = removexattr(nd.dentry, name, nd.mnt);
path_release(&nd);
return error;
}
@@ -449,7 +456,7 @@ sys_lremovexattr(char __user *path, char
error = user_path_walk_link(path, &nd);
if (error)
return error;
- error = removexattr(nd.dentry, name);
+ error = removexattr(nd.dentry, name, nd.mnt);
path_release(&nd);
return error;
}
@@ -463,7 +470,7 @@ sys_fremovexattr(int fd, char __user *na
f = fget(fd);
if (!f)
return error;
- error = removexattr(f->f_dentry, name);
+ error = removexattr(f->f_dentry, name, f->f_vfsmnt);
fput(f);
return error;
}
next prev parent reply other threads:[~2006-01-21 8:43 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-21 8:38 [PATCH 0/6] vfs: extend loopback (bind) mounts by mnt_flags Herbert Poetzl
2006-01-21 8:40 ` [PATCH 1/6] vfs: add missing MNT_RDONLY and macro to check Herbert Poetzl
2006-01-21 8:40 ` [PATCH 2/6] vfs: propagate mnt_flags into do_loopback/vfsmount Herbert Poetzl
2006-01-22 10:06 ` Suleiman Souhlal
2006-01-22 10:59 ` Suleiman Souhlal
2006-01-24 19:02 ` Christoph Hellwig
2006-01-26 21:04 ` Herbert Poetzl
2006-01-27 20:03 ` Herbert Poetzl
2006-04-01 17:02 ` Christoph Hellwig
2006-01-21 8:41 ` [PATCH 3/6] vfs: propagate vfsmount into chown_common() Herbert Poetzl
2006-01-21 8:42 ` [PATCH 4/6] vfs: propagate the nameidata into the relevant vfs_*() Herbert Poetzl
2006-01-21 8:43 ` Herbert Poetzl [this message]
2006-01-21 8:43 ` [PATCH 6/6] vfs: extend IS_RDONLY() checks to MNT_IS_RDONLY() Herbert Poetzl
2006-01-24 19:06 ` [PATCH 0/6] vfs: extend loopback (bind) mounts by mnt_flags Christoph Hellwig
2006-01-26 21:08 ` Herbert Poetzl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060121084301.GF10044@MAIL.13thfloor.at \
--to=herbert@13thfloor.at \
--cc=akpm@osdl.org \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.org \
--cc=viro@ftp.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).