Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-8]: src/sys/ufs Pull up following revision(s) (requested by chris...



details:   https://anonhg.NetBSD.org/src/rev/382e60f055ee
branches:  netbsd-8
changeset: 434602:382e60f055ee
user:      martin <martin%NetBSD.org@localhost>
date:      Sun Feb 04 12:52:02 2018 +0000

description:
Pull up following revision(s) (requested by christos in ticket #523):
        sys/ufs/ffs/ffs_vfsops.c: revision 1.356
        sys/ufs/ufs/ufs_inode.c: revision 1.103
Make sure inode blocks and size are zero when VOP_INACTIVE()
finalises a now unlinked inode.
Counterpart of the check in ffs_newvnode().
Prevent use-after-free where genfs_node_destroy() would destroy
a lock residing in the just freed inode data.

diffstat:

 sys/ufs/ffs/ffs_vfsops.c |  10 +++++-----
 sys/ufs/ufs/ufs_inode.c  |  13 +++++++++++--
 2 files changed, 16 insertions(+), 7 deletions(-)

diffs (70 lines):

diff -r 32be6d714716 -r 382e60f055ee sys/ufs/ffs/ffs_vfsops.c
--- a/sys/ufs/ffs/ffs_vfsops.c  Sun Feb 04 12:49:25 2018 +0000
+++ b/sys/ufs/ffs/ffs_vfsops.c  Sun Feb 04 12:52:02 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ffs_vfsops.c,v 1.353 2017/04/17 08:32:01 hannken Exp $ */
+/*     $NetBSD: ffs_vfsops.c,v 1.353.4.1 2018/02/04 12:52:02 martin Exp $      */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.353 2017/04/17 08:32:01 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.353.4.1 2018/02/04 12:52:02 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -2030,14 +2030,14 @@
 {
        struct inode *ip = VTOI(vp);
 
+       genfs_node_destroy(vp);
+       vp->v_data = NULL;
+
        if (ump->um_fstype == UFS1)
                pool_cache_put(ffs_dinode1_cache, ip->i_din.ffs1_din);
        else
                pool_cache_put(ffs_dinode2_cache, ip->i_din.ffs2_din);
        pool_cache_put(ffs_inode_cache, ip);
-
-       genfs_node_destroy(vp);
-       vp->v_data = NULL;
 }
 
 /*
diff -r 32be6d714716 -r 382e60f055ee sys/ufs/ufs/ufs_inode.c
--- a/sys/ufs/ufs/ufs_inode.c   Sun Feb 04 12:49:25 2018 +0000
+++ b/sys/ufs/ufs/ufs_inode.c   Sun Feb 04 12:52:02 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ufs_inode.c,v 1.101.2.1 2017/11/02 21:29:53 snj Exp $  */
+/*     $NetBSD: ufs_inode.c,v 1.101.2.2 2018/02/04 12:52:02 martin Exp $       */
 
 /*
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ufs_inode.c,v 1.101.2.1 2017/11/02 21:29:53 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_inode.c,v 1.101.2.2 2018/02/04 12:52:02 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -149,6 +149,15 @@
         */
        *ap->a_recycle = (ip->i_mode == 0);
 
+       if (ip->i_mode == 0 && (DIP(ip, size) != 0 || DIP(ip, blocks) != 0)) {
+               printf("%s: unlinked ino %" PRId64 " on \"%s\" has"
+                   " non zero size %" PRIx64 " or blocks %" PRIx64
+                   " with allerror %d\n",
+                   __func__, ip->i_number, mp->mnt_stat.f_mntonname,
+                   DIP(ip, size), DIP(ip, blocks), allerror);
+               panic("%s: dirty filesystem?", __func__);
+       }
+
        return (allerror);
 }
 



Home | Main Index | Thread Index | Old Index