* [PATCH 1/1] fs: xattr: Don't display attributes without read access
@ 2014-02-16 12:31 Fabian Frederick
2014-02-18 23:16 ` Andrew Morton
0 siblings, 1 reply; 4+ messages in thread
From: Fabian Frederick @ 2014-02-16 12:31 UTC (permalink / raw)
To: linux-fsdevel; +Cc: linux-kernel, akpm
Any user can display extented attribute names without read
access.
eg: attr -l <filename>
This patch checks inode_permission in listxattr common
function before executing vfs_listxattr.
Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
fs/xattr.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/xattr.c b/fs/xattr.c
index 3377dff..d26b280 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -543,6 +543,10 @@ listxattr(struct dentry *d, char __user *list, size_t size)
char *klist = NULL;
char *vlist = NULL; /* If non-NULL, we used vmalloc() */
+ error = inode_permission(d->d_inode, MAY_READ);
+ if (error)
+ return error;
+
if (size) {
if (size > XATTR_LIST_MAX)
size = XATTR_LIST_MAX;
--
1.8.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] fs: xattr: Don't display attributes without read access
2014-02-18 23:16 ` Andrew Morton
@ 2014-02-18 22:43 ` Fabian Frederick
2014-02-19 21:51 ` Fabian Frederick
1 sibling, 0 replies; 4+ messages in thread
From: Fabian Frederick @ 2014-02-18 22:43 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-fsdevel, linux-kernel
On Tue, 18 Feb 2014 15:16:50 -0800
Andrew Morton <akpm@linux-foundation.org> wrote:
> On Sun, 16 Feb 2014 20:31:01 +0800 Fabian Frederick <fabf@skynet.be> wrote:
>
> > Any user can display extented attribute names without read
> > access.
> >
> > eg: attr -l <filename>
> >
> > This patch checks inode_permission in listxattr common
> > function before executing vfs_listxattr.
> >
> > ...
> >
> > --- a/fs/xattr.c
> > +++ b/fs/xattr.c
> > @@ -543,6 +543,10 @@ listxattr(struct dentry *d, char __user *list, size_t size)
> > char *klist = NULL;
> > char *vlist = NULL; /* If non-NULL, we used vmalloc() */
> >
> > + error = inode_permission(d->d_inode, MAY_READ);
> > + if (error)
> > + return error;
> > +
> > if (size) {
> > if (size > XATTR_LIST_MAX)
> > size = XATTR_LIST_MAX;
>
> erk. Doesn't this mean that if existing userspace is relying on the
> current behaviour, this patch will cause breakage?
>
IMHO userspace applications already receive weird results in that case.
Without read permission, attr -l receives attribute names which means
it tries lgetxattr on those attributes where result is EACCESS :
"Attribute <attribute name> has -1 byte" !!!
Besides, is it semantically correct for a user to have access to
a part of "file content" without read access ?
With that patch, attr -l <filename> displays
attr_list: Permission denied
Could not list "(null)" for <filename>
On the other hand, when stracing that situation,
I do see attr making more noise than usual ie it's opening all attr.mo
twice so I guess I should return something else than "permission denied" to avoid problems in userspace ...
Fabian
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] fs: xattr: Don't display attributes without read access
2014-02-16 12:31 [PATCH 1/1] fs: xattr: Don't display attributes without read access Fabian Frederick
@ 2014-02-18 23:16 ` Andrew Morton
2014-02-18 22:43 ` Fabian Frederick
2014-02-19 21:51 ` Fabian Frederick
0 siblings, 2 replies; 4+ messages in thread
From: Andrew Morton @ 2014-02-18 23:16 UTC (permalink / raw)
To: Fabian Frederick; +Cc: linux-fsdevel, linux-kernel
On Sun, 16 Feb 2014 20:31:01 +0800 Fabian Frederick <fabf@skynet.be> wrote:
> Any user can display extented attribute names without read
> access.
>
> eg: attr -l <filename>
>
> This patch checks inode_permission in listxattr common
> function before executing vfs_listxattr.
>
> ...
>
> --- a/fs/xattr.c
> +++ b/fs/xattr.c
> @@ -543,6 +543,10 @@ listxattr(struct dentry *d, char __user *list, size_t size)
> char *klist = NULL;
> char *vlist = NULL; /* If non-NULL, we used vmalloc() */
>
> + error = inode_permission(d->d_inode, MAY_READ);
> + if (error)
> + return error;
> +
> if (size) {
> if (size > XATTR_LIST_MAX)
> size = XATTR_LIST_MAX;
erk. Doesn't this mean that if existing userspace is relying on the
current behaviour, this patch will cause breakage?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] fs: xattr: Don't display attributes without read access
2014-02-18 23:16 ` Andrew Morton
2014-02-18 22:43 ` Fabian Frederick
@ 2014-02-19 21:51 ` Fabian Frederick
1 sibling, 0 replies; 4+ messages in thread
From: Fabian Frederick @ 2014-02-19 21:51 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-fsdevel, linux-kernel
On Tue, 18 Feb 2014 15:16:50 -0800
Andrew Morton <akpm@linux-foundation.org> wrote:
> On Sun, 16 Feb 2014 20:31:01 +0800 Fabian Frederick <fabf@skynet.be> wrote:
>
> > Any user can display extented attribute names without read
> > access.
> >
> > eg: attr -l <filename>
> >
> > This patch checks inode_permission in listxattr common
> > function before executing vfs_listxattr.
> >
> > ...
> >
> > --- a/fs/xattr.c
> > +++ b/fs/xattr.c
> > @@ -543,6 +543,10 @@ listxattr(struct dentry *d, char __user *list, size_t size)
> > char *klist = NULL;
> > char *vlist = NULL; /* If non-NULL, we used vmalloc() */
> >
> > + error = inode_permission(d->d_inode, MAY_READ);
> > + if (error)
> > + return error;
> > +
> > if (size) {
> > if (size > XATTR_LIST_MAX)
> > size = XATTR_LIST_MAX;
>
> erk. Doesn't this mean that if existing userspace is relying on the
> current behaviour, this patch will cause breakage?
>
FYI, I just noticed FreeBSD was giving the expected result : no attribute name revealed
without read access ....
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-02-19 21:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-16 12:31 [PATCH 1/1] fs: xattr: Don't display attributes without read access Fabian Frederick
2014-02-18 23:16 ` Andrew Morton
2014-02-18 22:43 ` Fabian Frederick
2014-02-19 21:51 ` Fabian Frederick
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).