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
This commit is contained in:
maxv 2014-07-16 20:09:00 +00:00
parent e51b4cca97
commit 8ee3c88d2b
1 changed files with 10 additions and 2 deletions

View File

@ -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 @@ msdosfs_mountfs(struct vnode *devvp, struct mount *mp, struct lwp *l, struct msd
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) {