Source-Changes-HG archive

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

[src/trunk]: src/sys/dev Check disk bounds, in RAW_PART.



details:   https://anonhg.NetBSD.org/src/rev/3bcd98e17ef5
branches:  trunk
changeset: 757734:3bcd98e17ef5
user:      kiyohara <kiyohara%NetBSD.org@localhost>
date:      Mon Sep 20 06:54:06 2010 +0000

description:
Check disk bounds, in RAW_PART.

diffstat:

 sys/dev/ld.c    |  17 +++++++++++------
 sys/dev/ldvar.h |   3 ++-
 2 files changed, 13 insertions(+), 7 deletions(-)

diffs (62 lines):

diff -r ce71efa211f4 -r 3bcd98e17ef5 sys/dev/ld.c
--- a/sys/dev/ld.c      Mon Sep 20 06:45:38 2010 +0000
+++ b/sys/dev/ld.c      Mon Sep 20 06:54:06 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ld.c,v 1.67 2010/08/19 17:59:10 jmcneill Exp $ */
+/*     $NetBSD: ld.c,v 1.68 2010/09/20 06:54:06 kiyohara Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.67 2010/08/19 17:59:10 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.68 2010/09/20 06:54:06 kiyohara Exp $");
 
 #include "rnd.h"
 
@@ -145,6 +145,7 @@
            "%d bytes/sect x %"PRIu64" sectors\n",
            tbuf, sc->sc_ncylinders, sc->sc_nheads,
            sc->sc_nsectors, sc->sc_secsize, sc->sc_secperunit);
+       sc->sc_disksize512 = sc->sc_secperunit * sc->sc_secsize / DEV_BSIZE;
 
        ld_set_properties(sc);
 
@@ -626,10 +627,14 @@
         * Do bounds checking and adjust the transfer.  If error, process.
         * If past the end of partition, just return.
         */
-       if (part != RAW_PART &&
-           bounds_check_with_label(&sc->sc_dk, bp,
-           (sc->sc_flags & (LDF_WLABEL | LDF_LABELLING)) != 0) <= 0) {
-               goto done;
+       if (part == RAW_PART) {
+               if (bounds_check_with_mediasize(bp, DEV_BSIZE,
+                   sc->sc_disksize512) <= 0)
+                       goto done;
+       } else {
+               if (bounds_check_with_label(&sc->sc_dk, bp,
+                   (sc->sc_flags & (LDF_WLABEL | LDF_LABELLING)) != 0) <= 0)
+                       goto done;
        }
 
        /*
diff -r ce71efa211f4 -r 3bcd98e17ef5 sys/dev/ldvar.h
--- a/sys/dev/ldvar.h   Mon Sep 20 06:45:38 2010 +0000
+++ b/sys/dev/ldvar.h   Mon Sep 20 06:54:06 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ldvar.h,v 1.17 2009/12/18 00:40:24 jakllsch Exp $      */
+/*     $NetBSD: ldvar.h,v 1.18 2010/09/20 06:54:06 kiyohara Exp $      */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -52,6 +52,7 @@
        int     sc_ncylinders;          /* # cylinders */
        int     sc_nheads;              /* # heads */
        int     sc_nsectors;            /* # sectors per track */
+       int     sc_disksize512;
 
        /*
         * The following are filled by hardware specific attachment code.



Home | Main Index | Thread Index | Old Index