Merge -r1.44 of ufs_extattr.c and related change -r1.302 of ffs_vfops.c:

fix use-after-free on failed unmount with extended attributes enabled.
This commit is contained in:
dholland 2016-06-20 01:44:05 +00:00
parent 8ddcdf74f7
commit 87c7b3f519
2 changed files with 11 additions and 18 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_vfsops.c,v 1.349 2015/10/19 04:22:18 dholland Exp $ */
/* $NetBSD: lfs_vfsops.c,v 1.350 2016/06/20 01:44:05 dholland Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007
@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.349 2015/10/19 04:22:18 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.350 2016/06/20 01:44:05 dholland Exp $");
#if defined(_KERNEL_OPT)
#include "opt_lfs.h"
@ -1248,18 +1248,6 @@ lfs_mountfs(struct vnode *devvp, struct mount *mp, struct lwp *l)
}
}
#ifdef LFS_EXTATTR
/*
* Initialize file-backed extended attributes for ULFS1 file
* systems.
*
* XXX: why is this limited to ULFS1?
*/
if (ump->um_fstype == ULFS1) {
ulfs_extattr_uepm_init(&ump->um_extattr);
}
#endif
#ifdef LFS_KERNEL_RFW
lfs_roll_forward(fs, mp, l);
#endif
@ -1372,6 +1360,7 @@ lfs_unmount(struct mount *mp, int mntflags)
}
if (ump->um_extattr.uepm_flags & ULFS_EXTATTR_UEPM_INITIALIZED) {
ulfs_extattr_uepm_destroy(&ump->um_extattr);
mp->mnt_flag &= ~MNT_EXTATTR;
}
}
#endif

View File

@ -1,5 +1,5 @@
/* $NetBSD: ulfs_extattr.c,v 1.9 2016/06/20 00:00:47 dholland Exp $ */
/* from NetBSD: ufs_extattr.c,v 1.43 2014/02/07 15:29:23 hannken Exp */
/* $NetBSD: ulfs_extattr.c,v 1.10 2016/06/20 01:44:05 dholland Exp $ */
/* from NetBSD: ufs_extattr.c,v 1.44 2014/11/14 10:09:50 manu */
/*-
* Copyright (c) 1999-2002 Robert N. M. Watson
@ -49,7 +49,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ulfs_extattr.c,v 1.9 2016/06/20 00:00:47 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: ulfs_extattr.c,v 1.10 2016/06/20 01:44:05 dholland Exp $");
#ifdef _KERNEL_OPT
#include "opt_lfs.h"
@ -384,10 +384,11 @@ ulfs_extattr_uepm_destroy(struct ulfs_extattr_per_mount *uepm)
panic("ulfs_extattr_uepm_destroy: called while still started");
/*
* It's not clear that either order for the next two lines is
* It's not clear that either order for the next three lines is
* ideal, and it should never be a problem if this is only called
* during unmount, and with vfs_busy().
*/
uepm->uepm_flags &= ~ULFS_EXTATTR_UEPM_STARTED;
uepm->uepm_flags &= ~ULFS_EXTATTR_UEPM_INITIALIZED;
mutex_destroy(&uepm->uepm_lock);
}
@ -403,6 +404,9 @@ ulfs_extattr_start(struct mount *mp, struct lwp *l)
ump = VFSTOULFS(mp);
if (!(ump->um_extattr.uepm_flags & ULFS_EXTATTR_UEPM_INITIALIZED))
ulfs_extattr_uepm_init(&ump->um_extattr);
ulfs_extattr_uepm_lock(ump);
if (!(ump->um_extattr.uepm_flags & ULFS_EXTATTR_UEPM_INITIALIZED)) {