Source-Changes-HG archive

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

[src/netbsd-1-4]: src/sys/ufs/lfs Pull up revision 1.50 (requested by perseant):



details:   https://anonhg.NetBSD.org/src/rev/75caab89891d
branches:  netbsd-1-4
changeset: 470551:75caab89891d
user:      he <he%NetBSD.org@localhost>
date:      Fri May 05 13:06:52 2000 +0000

description:
Pull up revision 1.50 (requested by perseant):
  Sanity check the superblock before trying to use it to find the
  alt superblock; sanity check the disk address of the alt superblock
  to avoid deadlocking when trying to read it with the primary
  superblock buffer still busy.  Fixes PR#10001.

diffstat:

 sys/ufs/lfs/lfs_vfsops.c |  36 +++++++++++++++++++++++-------------
 1 files changed, 23 insertions(+), 13 deletions(-)

diffs (63 lines):

diff -r bccebae4b5a0 -r 75caab89891d sys/ufs/lfs/lfs_vfsops.c
--- a/sys/ufs/lfs/lfs_vfsops.c  Fri May 05 13:03:34 2000 +0000
+++ b/sys/ufs/lfs/lfs_vfsops.c  Fri May 05 13:06:52 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_vfsops.c,v 1.28.2.8 2000/03/29 20:51:33 he Exp $   */
+/*     $NetBSD: lfs_vfsops.c,v 1.28.2.9 2000/05/05 13:06:52 he Exp $   */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -355,6 +355,7 @@
 
        /* Don't free random space on error. */
        bp = NULL;
+       abp = NULL;
        ump = NULL;
 
        /* Read in the superblock. */
@@ -363,24 +364,33 @@
                goto out;
        dfs = (struct dlfs *)bp->b_data;
 
+       /* Check the basics. */
+       if (dfs->dlfs_magic != LFS_MAGIC || dfs->dlfs_bsize > MAXBSIZE ||
+           dfs->dlfs_version > LFS_VERSION ||
+           dfs->dlfs_bsize < sizeof(struct dlfs)) {
+               error = EINVAL;         /* XXX needs translation */
+               goto out;
+       }
+
        /*
         * Check the second superblock to see which is newer; then mount
         * using the older of the two.  This is necessary to ensure that
         * the filesystem is valid if it was not unmounted cleanly.
         */
-       error = bread(devvp, dfs->dlfs_sboffs[1], LFS_SBPAD, cred, &abp);
-       if (error)
-               goto out;
-       adfs = (struct dlfs *)abp->b_data;
+       if (dfs->dlfs_sboffs[1] &&
+           dfs->dlfs_sboffs[1]-(LFS_LABELPAD/size) > LFS_SBPAD/size)
+       {
+               error = bread(devvp, dfs->dlfs_sboffs[1], LFS_SBPAD, cred, &abp);
+               if (error)
+                       goto out;
+               adfs = (struct dlfs *)abp->b_data;
 
-       if (adfs->dlfs_tstamp < dfs->dlfs_tstamp) /* XXX KS - 1s resolution? */
-               dfs = adfs;
-
-       /* Check the basics. */
-       if (dfs->dlfs_magic != LFS_MAGIC || dfs->dlfs_bsize > MAXBSIZE ||
-           dfs->dlfs_version > LFS_VERSION ||
-           dfs->dlfs_bsize < sizeof(struct dlfs)) {
-               error = EINVAL;         /* XXX needs translation */
+               if (adfs->dlfs_tstamp < dfs->dlfs_tstamp) /* XXX 1s? */
+                       dfs = adfs;
+       } else {
+               printf("lfs_mountfs: invalid alt superblock daddr=0x%x\n",
+                       dfs->dlfs_sboffs[1]);
+               error = EINVAL;
                goto out;
        }
 



Home | Main Index | Thread Index | Old Index