Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bec1b089 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
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
Loading
Loading
Loading
Loading
+14 −8
Original line number Original line Diff line number Diff line
@@ -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,16 +183,22 @@ 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;
	}
	if (error == -EAGAIN) {
		error = -EOPNOTSUPP;

		if (issec) {
			const char *suffix = name + XATTR_SECURITY_PREFIX_LEN;

			error = security_inode_setsecurity(inode, suffix, value,
			error = security_inode_setsecurity(inode, suffix, value,
							   size, flags);
							   size, flags);
			if (!error)
			if (!error)
				fsnotify_xattr(dentry);
				fsnotify_xattr(dentry);
		}
		}
	}


	return error;
	return error;
}
}
+3 −1
Original line number Original line Diff line number Diff line
@@ -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)
			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)
+15 −0
Original line number Original line Diff line number Diff line
@@ -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
};
};