Commit bec1b089 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

Pull vfs fixes from Al Viro:
 "A couple of regression fixes"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  fix iov_iter_advance() for ITER_PIPE
  xattr: Fix setting security xattrs on sockfs
parents d46bc34d 680bb946
...@@ -170,7 +170,7 @@ int __vfs_setxattr_noperm(struct dentry *dentry, const char *name, ...@@ -170,7 +170,7 @@ int __vfs_setxattr_noperm(struct dentry *dentry, const char *name,
const void *value, size_t size, int flags) const void *value, size_t size, int flags)
{ {
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
int error = -EOPNOTSUPP; int error = -EAGAIN;
int issec = !strncmp(name, XATTR_SECURITY_PREFIX, int issec = !strncmp(name, XATTR_SECURITY_PREFIX,
XATTR_SECURITY_PREFIX_LEN); XATTR_SECURITY_PREFIX_LEN);
...@@ -183,15 +183,21 @@ int __vfs_setxattr_noperm(struct dentry *dentry, const char *name, ...@@ -183,15 +183,21 @@ int __vfs_setxattr_noperm(struct dentry *dentry, const char *name,
security_inode_post_setxattr(dentry, name, value, security_inode_post_setxattr(dentry, name, value,
size, flags); size, flags);
} }
} else if (issec) { } else {
const char *suffix = name + XATTR_SECURITY_PREFIX_LEN;
if (unlikely(is_bad_inode(inode))) if (unlikely(is_bad_inode(inode)))
return -EIO; return -EIO;
error = security_inode_setsecurity(inode, suffix, value, }
size, flags); if (error == -EAGAIN) {
if (!error) error = -EOPNOTSUPP;
fsnotify_xattr(dentry);
if (issec) {
const char *suffix = name + XATTR_SECURITY_PREFIX_LEN;
error = security_inode_setsecurity(inode, suffix, value,
size, flags);
if (!error)
fsnotify_xattr(dentry);
}
} }
return error; return error;
......
...@@ -683,10 +683,11 @@ static void pipe_advance(struct iov_iter *i, size_t size) ...@@ -683,10 +683,11 @@ static void pipe_advance(struct iov_iter *i, size_t size)
struct pipe_inode_info *pipe = i->pipe; struct pipe_inode_info *pipe = i->pipe;
struct pipe_buffer *buf; struct pipe_buffer *buf;
int idx = i->idx; int idx = i->idx;
size_t off = i->iov_offset; size_t off = i->iov_offset, orig_sz;
if (unlikely(i->count < size)) if (unlikely(i->count < size))
size = i->count; size = i->count;
orig_sz = size;
if (size) { if (size) {
if (off) /* make it relative to the beginning of buffer */ if (off) /* make it relative to the beginning of buffer */
...@@ -713,6 +714,7 @@ static void pipe_advance(struct iov_iter *i, size_t size) ...@@ -713,6 +714,7 @@ static void pipe_advance(struct iov_iter *i, size_t size)
pipe->nrbufs--; pipe->nrbufs--;
} }
} }
i->count -= orig_sz;
} }
void iov_iter_advance(struct iov_iter *i, size_t size) void iov_iter_advance(struct iov_iter *i, size_t size)
......
...@@ -341,8 +341,23 @@ static const struct xattr_handler sockfs_xattr_handler = { ...@@ -341,8 +341,23 @@ static const struct xattr_handler sockfs_xattr_handler = {
.get = sockfs_xattr_get, .get = sockfs_xattr_get,
}; };
static int sockfs_security_xattr_set(const struct xattr_handler *handler,
struct dentry *dentry, struct inode *inode,
const char *suffix, const void *value,
size_t size, int flags)
{
/* Handled by LSM. */
return -EAGAIN;
}
static const struct xattr_handler sockfs_security_xattr_handler = {
.prefix = XATTR_SECURITY_PREFIX,
.set = sockfs_security_xattr_set,
};
static const struct xattr_handler *sockfs_xattr_handlers[] = { static const struct xattr_handler *sockfs_xattr_handlers[] = {
&sockfs_xattr_handler, &sockfs_xattr_handler,
&sockfs_security_xattr_handler,
NULL NULL
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment