Module Name:    src
Committed By:   tsutsui
Date:           Wed Nov 30 15:59:01 UTC 2022

Modified Files:
        src/sys/arch/hp300/dev: rd.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.114 -r1.115 src/sys/arch/hp300/dev/rd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/hp300/dev/rd.c
diff -u src/sys/arch/hp300/dev/rd.c:1.114 src/sys/arch/hp300/dev/rd.c:1.115
--- src/sys/arch/hp300/dev/rd.c:1.114	Fri Nov 25 16:12:32 2022
+++ src/sys/arch/hp300/dev/rd.c	Wed Nov 30 15:59:01 2022
@@ -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 @@ rdstrategy(struct buf *bp)
 	/* 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()

Reply via email to