Skip to content

Commit a527a2b

Browse files
committed
Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull misc vfs fixes from Al Viro: "Several assorted fixes. I still think that audit ->d_name race is better fixed this way for the benefit of backports, with any possibly fancier variants done on top of it" * 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: dump_common_audit_data(): fix racy accesses to ->d_name iov_iter: fix the uaccess area in copy_compat_iovec_from_user umount(2): move the flag validity checks first
2 parents feb889f + d36a1dd commit a527a2b

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

fs/namespace.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1713,8 +1713,6 @@ static int can_umount(const struct path *path, int flags)
17131713
{
17141714
struct mount *mnt = real_mount(path->mnt);
17151715

1716-
if (flags & ~(MNT_FORCE | MNT_DETACH | MNT_EXPIRE | UMOUNT_NOFOLLOW))
1717-
return -EINVAL;
17181716
if (!may_mount())
17191717
return -EPERM;
17201718
if (path->dentry != path->mnt->mnt_root)
@@ -1728,6 +1726,7 @@ static int can_umount(const struct path *path, int flags)
17281726
return 0;
17291727
}
17301728

1729+
// caller is responsible for flags being sane
17311730
int path_umount(struct path *path, int flags)
17321731
{
17331732
struct mount *mnt = real_mount(path->mnt);
@@ -1749,6 +1748,10 @@ static int ksys_umount(char __user *name, int flags)
17491748
struct path path;
17501749
int ret;
17511750

1751+
// basic validity checks done first
1752+
if (flags & ~(MNT_FORCE | MNT_DETACH | MNT_EXPIRE | UMOUNT_NOFOLLOW))
1753+
return -EINVAL;
1754+
17521755
if (!(flags & UMOUNT_NOFOLLOW))
17531756
lookup_flags |= LOOKUP_FOLLOW;
17541757
ret = user_path_at(AT_FDCWD, name, lookup_flags, &path);

lib/iov_iter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1658,7 +1658,7 @@ static int copy_compat_iovec_from_user(struct iovec *iov,
16581658
(const struct compat_iovec __user *)uvec;
16591659
int ret = -EFAULT, i;
16601660

1661-
if (!user_access_begin(uvec, nr_segs * sizeof(*uvec)))
1661+
if (!user_access_begin(uiov, nr_segs * sizeof(*uiov)))
16621662
return -EFAULT;
16631663

16641664
for (i = 0; i < nr_segs; i++) {

security/lsm_audit.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,9 @@ static void dump_common_audit_data(struct audit_buffer *ab,
275275
struct inode *inode;
276276

277277
audit_log_format(ab, " name=");
278+
spin_lock(&a->u.dentry->d_lock);
278279
audit_log_untrustedstring(ab, a->u.dentry->d_name.name);
280+
spin_unlock(&a->u.dentry->d_lock);
279281

280282
inode = d_backing_inode(a->u.dentry);
281283
if (inode) {
@@ -293,8 +295,9 @@ static void dump_common_audit_data(struct audit_buffer *ab,
293295
dentry = d_find_alias(inode);
294296
if (dentry) {
295297
audit_log_format(ab, " name=");
296-
audit_log_untrustedstring(ab,
297-
dentry->d_name.name);
298+
spin_lock(&dentry->d_lock);
299+
audit_log_untrustedstring(ab, dentry->d_name.name);
300+
spin_unlock(&dentry->d_lock);
298301
dput(dentry);
299302
}
300303
audit_log_format(ab, " dev=");

0 commit comments

Comments
 (0)