Module Name: src Committed By: dholland Date: Mon Jun 20 01:44:05 UTC 2016
Modified Files: src/sys/ufs/lfs: lfs_vfsops.c ulfs_extattr.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.349 -r1.350 src/sys/ufs/lfs/lfs_vfsops.c cvs rdiff -u -r1.9 -r1.10 src/sys/ufs/lfs/ulfs_extattr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/ufs/lfs/lfs_vfsops.c diff -u src/sys/ufs/lfs/lfs_vfsops.c:1.349 src/sys/ufs/lfs/lfs_vfsops.c:1.350 --- src/sys/ufs/lfs/lfs_vfsops.c:1.349 Mon Oct 19 04:22:18 2015 +++ src/sys/ufs/lfs/lfs_vfsops.c Mon Jun 20 01:44:05 2016 @@ -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 } } -#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 mntfla } if (ump->um_extattr.uepm_flags & ULFS_EXTATTR_UEPM_INITIALIZED) { ulfs_extattr_uepm_destroy(&ump->um_extattr); + mp->mnt_flag &= ~MNT_EXTATTR; } } #endif Index: src/sys/ufs/lfs/ulfs_extattr.c diff -u src/sys/ufs/lfs/ulfs_extattr.c:1.9 src/sys/ufs/lfs/ulfs_extattr.c:1.10 --- src/sys/ufs/lfs/ulfs_extattr.c:1.9 Mon Jun 20 00:00:47 2016 +++ src/sys/ufs/lfs/ulfs_extattr.c Mon Jun 20 01:44:05 2016 @@ -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_ex 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, str 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)) {