Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src ufs: Prevent mkdir from choking on deleted directories.
details: https://anonhg.NetBSD.org/src/rev/fed7b8158fba
branches: trunk
changeset: 938238:fed7b8158fba
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sat Sep 05 02:47:48 2020 +0000
description:
ufs: Prevent mkdir from choking on deleted directories.
Fix some missing uvm_vnp_setsize in screw cases while here.
diffstat:
sys/ufs/lfs/lfs_vnops.c | 11 +++++++++--
sys/ufs/lfs/ulfs_lookup.c | 6 ++++--
sys/ufs/ufs/ufs_lookup.c | 6 ++++--
sys/ufs/ufs/ufs_vnops.c | 11 +++++++++--
tests/fs/vfs/t_renamerace.c | 4 +---
5 files changed, 27 insertions(+), 11 deletions(-)
diffs (150 lines):
diff -r 52d4c0b100aa -r fed7b8158fba sys/ufs/lfs/lfs_vnops.c
--- a/sys/ufs/lfs/lfs_vnops.c Sat Sep 05 02:47:03 2020 +0000
+++ b/sys/ufs/lfs/lfs_vnops.c Sat Sep 05 02:47:48 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_vnops.c,v 1.333 2020/05/16 18:31:53 christos Exp $ */
+/* $NetBSD: lfs_vnops.c,v 1.334 2020/09/05 02:47:48 riastradh Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -125,7 +125,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.333 2020/05/16 18:31:53 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.334 2020/09/05 02:47:48 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -991,6 +991,13 @@
*ap->a_vpp = NULL;
goto out;
}
+ if (VTOI(*ap->a_vpp)->i_size == 0) {
+ /* directory has been rmdir'd */
+ vput(*ap->a_vpp);
+ *ap->a_vpp = NULL;
+ error = ENOENT;
+ goto out;
+ }
tvp = *ap->a_vpp;
MARK_VNODE(tvp);
diff -r 52d4c0b100aa -r fed7b8158fba sys/ufs/lfs/ulfs_lookup.c
--- a/sys/ufs/lfs/ulfs_lookup.c Sat Sep 05 02:47:03 2020 +0000
+++ b/sys/ufs/lfs/ulfs_lookup.c Sat Sep 05 02:47:48 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ulfs_lookup.c,v 1.44 2020/05/16 18:31:53 christos Exp $ */
+/* $NetBSD: ulfs_lookup.c,v 1.45 2020/09/05 02:47:48 riastradh Exp $ */
/* from NetBSD: ufs_lookup.c,v 1.135 2015/07/11 11:04:48 mlelstv */
/*
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ulfs_lookup.c,v 1.44 2020/05/16 18:31:53 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ulfs_lookup.c,v 1.45 2020/09/05 02:47:48 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_lfs.h"
@@ -522,6 +522,7 @@
results->ulr_offset + LFS_DIRSIZ(fs, ep);
DIP_ASSIGN(dp, size, dp->i_size);
dp->i_state |= IN_CHANGE | IN_UPDATE;
+ uvm_vnp_setsize(vdp, dp->i_size);
}
brelse(bp, 0);
@@ -846,6 +847,7 @@
dp->i_size = ulr->ulr_offset + ulr->ulr_count;
DIP_ASSIGN(dp, size, dp->i_size);
dp->i_state |= IN_CHANGE | IN_UPDATE;
+ uvm_vnp_setsize(dvp, dp->i_size);
}
/*
* Get the block containing the space for the new directory entry.
diff -r 52d4c0b100aa -r fed7b8158fba sys/ufs/ufs/ufs_lookup.c
--- a/sys/ufs/ufs/ufs_lookup.c Sat Sep 05 02:47:03 2020 +0000
+++ b/sys/ufs/ufs/ufs_lookup.c Sat Sep 05 02:47:48 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs_lookup.c,v 1.153 2020/05/16 18:31:54 christos Exp $ */
+/* $NetBSD: ufs_lookup.c,v 1.154 2020/09/05 02:47:48 riastradh Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.153 2020/05/16 18:31:54 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.154 2020/09/05 02:47:48 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_ffs.h"
@@ -667,6 +667,7 @@
dp->i_size = newisize;
DIP_ASSIGN(dp, size, dp->i_size);
dp->i_flag |= IN_CHANGE | IN_UPDATE;
+ uvm_vnp_setsize(vdp, dp->i_size);
UFS_WAPBL_UPDATE(vdp, NULL, NULL, UPDATE_DIROP);
}
brelse(bp, 0);
@@ -956,6 +957,7 @@
dp->i_size = ulr->ulr_offset + ulr->ulr_count;
DIP_ASSIGN(dp, size, dp->i_size);
dp->i_flag |= IN_CHANGE | IN_UPDATE;
+ uvm_vnp_setsize(dvp, dp->i_size);
UFS_WAPBL_UPDATE(dvp, NULL, NULL, UPDATE_DIROP);
}
/*
diff -r 52d4c0b100aa -r fed7b8158fba sys/ufs/ufs/ufs_vnops.c
--- a/sys/ufs/ufs/ufs_vnops.c Sat Sep 05 02:47:03 2020 +0000
+++ b/sys/ufs/ufs/ufs_vnops.c Sat Sep 05 02:47:48 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs_vnops.c,v 1.256 2020/08/20 20:28:13 christos Exp $ */
+/* $NetBSD: ufs_vnops.c,v 1.257 2020/09/05 02:47:48 riastradh Exp $ */
/*-
* Copyright (c) 2008, 2020 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.256 2020/08/20 20:28:13 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.257 2020/09/05 02:47:48 riastradh Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ffs.h"
@@ -1253,6 +1253,13 @@
*ap->a_vpp = NULL;
goto out;
}
+ if (VTOI(*ap->a_vpp)->i_size == 0) {
+ /* directory has been rmdir'd */
+ vput(*ap->a_vpp);
+ *ap->a_vpp = NULL;
+ error = ENOENT;
+ goto out;
+ }
error = UFS_WAPBL_BEGIN(ap->a_dvp->v_mount);
if (error) {
vput(*ap->a_vpp);
diff -r 52d4c0b100aa -r fed7b8158fba tests/fs/vfs/t_renamerace.c
--- a/tests/fs/vfs/t_renamerace.c Sat Sep 05 02:47:03 2020 +0000
+++ b/tests/fs/vfs/t_renamerace.c Sat Sep 05 02:47:48 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_renamerace.c,v 1.38 2020/09/05 02:47:03 riastradh Exp $ */
+/* $NetBSD: t_renamerace.c,v 1.39 2020/09/05 02:47:49 riastradh Exp $ */
/*
* Modified for rump and atf from a program supplied
@@ -248,8 +248,6 @@
atf_tc_skip("directories not supported by file system");
if (FSTYPE_RUMPFS(tc))
atf_tc_skip("rename not supported by file system");
- if (FSTYPE_P2K_FFS(tc))
- atf_tc_expect_fail("assertion \"vp->v_size == ip->i_size\" failed");
if (FSTYPE_PUFFS(tc))
atf_tc_expect_fail("assertion \"dfd\" failed");
if (FSTYPE_NFS(tc))
Home |
Main Index |
Thread Index |
Old Index