Is this related to kern/59153?

On Sat, 12 Apr 2025, Rin Okuyama wrote:

Hi!

I've made a draft patch to support dumping against > 2Gi blocks
for backends like nvme(4) or virtio(4).

Does it look reasonable to you?

Thanks,
rin

On 2025/04/12 16:30, Michael van Elst wrote:
Module Name:    src
Committed By:   mlelstv
Date:           Sat Apr 12 07:30:01 UTC 2025

Modified Files:
        src/sys/dev: ld.c

Log Message:
ld sc_dump backend takes an 'int' as disk address, fail when the
disk address is outside the possible range of an int.


To generate a diff of this commit:
cvs rdiff -u -r1.114 -r1.115 src/sys/dev/ld.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/dev/ld.c
diff -u src/sys/dev/ld.c:1.114 src/sys/dev/ld.c:1.115
--- src/sys/dev/ld.c:1.114      Wed Mar  5 00:41:17 2025
+++ src/sys/dev/ld.c    Sat Apr 12 07:30:01 2025
@@ -1,4 +1,4 @@
-/*     $NetBSD: ld.c,v 1.114 2025/03/05 00:41:17 jakllsch Exp $        */
+/*     $NetBSD: ld.c,v 1.115 2025/04/12 07:30:01 mlelstv 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.114 2025/03/05 00:41:17 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.115 2025/04/12 07:30:01 mlelstv Exp $");
    #include <sys/param.h>
  #include <sys/systm.h>
@@ -603,6 +603,12 @@ ld_dumpblocks(device_t dev, void *va, da
        if (sc->sc_dump == NULL)
                return (ENODEV);
  +     /*
+        * sc_dump takes only an 'int' as a disk address
+        */
+       if (blkno < 0 || blkno + nblk - 1 > INT_MAX)
+               return (EIO);
+
        return (*sc->sc_dump)(sc, va, blkno, nblk);
  }



!DSPAM:67fa3180268605766628163!


+---------------------+--------------------------+----------------------+
| Paul Goyette (.sig) | PGP Key fingerprint:     | E-mail addresses:    |
| (Retired)           | 1B11 1849 721C 56C8 F63A | p...@whooppee.com    |
| Software Developer  | 6E2E 05FD 15CE 9F2D 5102 | pgoye...@netbsd.org  |
| & Network Engineer  |                          | pgoyett...@gmail.com |
+---------------------+--------------------------+----------------------+

Reply via email to