Source-Changes-HG archive

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

[src/trunk]: src/sys/fs/msdosfs Limit the minimum size of a disk sector to 51...



details:   https://anonhg.NetBSD.org/src/rev/8f69b89121ed
branches:  trunk
changeset: 797403:8f69b89121ed
user:      maxv <maxv%NetBSD.org@localhost>
date:      Wed Jul 16 20:09:00 2014 +0000

description:
Limit the minimum size of a disk sector to 512 bytes, to prevent memory
overflow on extremely low secsize. This normally conforms to the old standard
(for which there doesn't seem to be a clear spec). Since 2011, IDEMA's Advanced
Format standardizes it to 4k, so this change won't cause any trouble on
new devices.

Put the printf under DIAGNOSTIC temporarily to see if someone complains.

after a quick discussion on tech-kern

diffstat:

 sys/fs/msdosfs/msdosfs_vfsops.c |  12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diffs (33 lines):

diff -r b7eecde42cde -r 8f69b89121ed sys/fs/msdosfs/msdosfs_vfsops.c
--- a/sys/fs/msdosfs/msdosfs_vfsops.c   Wed Jul 16 20:08:37 2014 +0000
+++ b/sys/fs/msdosfs/msdosfs_vfsops.c   Wed Jul 16 20:09:00 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msdosfs_vfsops.c,v 1.113 2014/07/15 11:43:54 christos Exp $    */
+/*     $NetBSD: msdosfs_vfsops.c,v 1.114 2014/07/16 20:09:00 maxv Exp $        */
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.113 2014/07/15 11:43:54 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.114 2014/07/16 20:09:00 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -493,6 +493,14 @@
                psize = 0;
                error = 0;
        }
+       if (secsize < DEV_BSIZE) {
+#ifdef DIAGNOSTIC /* XXX: to be converted to DPRINTF */
+               printf("%s(): Invalid block secsize (%d < DEV_BSIZE)\n", __func__,
+                   secsize);
+#endif
+               error = EINVAL;
+               goto error_exit;
+       }
 
        if (argp->flags & MSDOSFSMNT_GEMDOSFS) {
                if (secsize != GEMDOSFS_BSIZE) {



Home | Main Index | Thread Index | Old Index