Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/ufs/ffs ffs_reload(): the current implementation blindly...
details: https://anonhg.NetBSD.org/src/rev/e89de08027d5
branches: trunk
changeset: 336492:e89de08027d5
user: maxv <maxv%NetBSD.org@localhost>
date: Tue Mar 03 17:46:39 2015 +0000
description:
ffs_reload(): the current implementation blindly guesses critical fields
of the superblock didn't change. Add checks to ensure they didn't change
for real. This prevents several memory corruptions.
diffstat:
sys/ufs/ffs/ffs_vfsops.c | 24 ++++++++++++++++--------
1 files changed, 16 insertions(+), 8 deletions(-)
diffs (52 lines):
diff -r 7b0a4af2049f -r e89de08027d5 sys/ufs/ffs/ffs_vfsops.c
--- a/sys/ufs/ffs/ffs_vfsops.c Tue Mar 03 14:31:48 2015 +0000
+++ b/sys/ufs/ffs/ffs_vfsops.c Tue Mar 03 17:46:39 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ffs_vfsops.c,v 1.319 2015/02/23 13:38:54 maxv Exp $ */
+/* $NetBSD: ffs_vfsops.c,v 1.320 2015/03/03 17:46:39 maxv 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.319 2015/02/23 13:38:54 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.320 2015/03/03 17:46:39 maxv Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ffs.h"
@@ -733,12 +733,6 @@
#endif
fs->fs_flags &= ~FS_SWAPPED;
- /* We don't want the superblock size to change. */
- if (newfs->fs_sbsize != fs_sbsize) {
- brelse(bp, 0);
- kmem_free(newfs, fs_sbsize);
- return (EINVAL);
- }
if ((newfs->fs_magic != FS_UFS1_MAGIC &&
newfs->fs_magic != FS_UFS2_MAGIC)) {
brelse(bp, 0);
@@ -751,6 +745,20 @@
return (EINVAL);
}
+ /*
+ * The current implementation doesn't handle the possibility that
+ * these values may have changed.
+ */
+ if ((newfs->fs_sbsize != fs_sbsize) ||
+ (newfs->fs_cssize != fs->fs_cssize) ||
+ (newfs->fs_contigsumsize != fs->fs_contigsumsize) ||
+ (newfs->fs_ncg != fs->fs_ncg)) {
+ brelse(bp, 0);
+ kmem_free(newfs, fs_sbsize);
+ return (EINVAL);
+ }
+
+
/* Store off old fs_sblockloc for fs_oldfscompat_read. */
sblockloc = fs->fs_sblockloc;
/*
Home |
Main Index |
Thread Index |
Old Index