Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/hp300/dev Check bounds of RAW_PART by bounds_check_...



details:   https://anonhg.NetBSD.org/src/rev/b081bc7633ad
branches:  trunk
changeset: 372463:b081bc7633ad
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Wed Nov 30 15:59:01 2022 +0000

description:
Check bounds of RAW_PART by bounds_check_with_mediasize() as other drivers.

With this check, dd(1) without a count value against a raw partition
is terminated properly at the end of media.  Tested on 425t and HPDisk.

Should be pulled up to netbsd-9.

diffstat:

 sys/arch/hp300/dev/rd.c |  10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diffs (31 lines):

diff -r f656766b1852 -r b081bc7633ad sys/arch/hp300/dev/rd.c
--- a/sys/arch/hp300/dev/rd.c   Wed Nov 30 15:57:54 2022 +0000
+++ b/sys/arch/hp300/dev/rd.c   Wed Nov 30 15:59:01 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rd.c,v 1.114 2022/11/25 16:12:32 tsutsui Exp $ */
+/*     $NetBSD: rd.c,v 1.115 2022/11/30 15:59:01 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -72,7 +72,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.114 2022/11/25 16:12:32 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.115 2022/11/30 15:59:01 tsutsui Exp $");
 
 #include "opt_useleds.h"
 
@@ -893,7 +893,11 @@
        /* Don't perform partition translation on RAW_PART. */
        offset = (rdpart(bp->b_dev) == RAW_PART) ? 0 : pinfo->p_offset;
 
-       if (rdpart(bp->b_dev) != RAW_PART) {
+       if (rdpart(bp->b_dev) == RAW_PART) {
+               if (bounds_check_with_mediasize(bp, DEV_BSIZE,
+                   rdidentinfo[sc->sc_type].ri_nblocks) <= 0)
+                       goto done;
+       } else {
                /*
                 * XXX This block of code belongs in
                 * XXX bounds_check_with_label()



Home | Main Index | Thread Index | Old Index