Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev Bounds check against media size for non-persistent s...
details: https://anonhg.NetBSD.org/src/rev/5c0bdc1bbcce
branches: trunk
changeset: 358322:5c0bdc1bbcce
user: hannken <hannken%NetBSD.org@localhost>
date: Thu Dec 21 15:51:07 2017 +0000
description:
Bounds check against media size for non-persistent snapshots.
diffstat:
sys/dev/fss.c | 22 ++++++++++++++--------
1 files changed, 14 insertions(+), 8 deletions(-)
diffs (51 lines):
diff -r f52aa79e89cd -r 5c0bdc1bbcce sys/dev/fss.c
--- a/sys/dev/fss.c Thu Dec 21 15:50:33 2017 +0000
+++ b/sys/dev/fss.c Thu Dec 21 15:51:07 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fss.c,v 1.101 2017/12/21 15:50:33 hannken Exp $ */
+/* $NetBSD: fss.c,v 1.102 2017/12/21 15:51:07 hannken Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.101 2017/12/21 15:50:33 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.102 2017/12/21 15:51:07 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -280,20 +280,26 @@
mutex_enter(&sc->sc_slock);
if (write || !FSS_ISVALID(sc)) {
-
- mutex_exit(&sc->sc_slock);
-
bp->b_error = (write ? EROFS : ENXIO);
- bp->b_resid = bp->b_bcount;
- biodone(bp);
- return;
+ goto done;
}
+ /* Check bounds for non-persistent snapshots. */
+ if ((sc->sc_flags & FSS_PERSISTENT) == 0 &&
+ bounds_check_with_mediasize(bp, DEV_BSIZE,
+ btodb(FSS_CLTOB(sc, sc->sc_clcount - 1) + sc->sc_clresid)) <= 0)
+ goto done;
bp->b_rawblkno = bp->b_blkno;
bufq_put(sc->sc_bufq, bp);
cv_signal(&sc->sc_work_cv);
mutex_exit(&sc->sc_slock);
+ return;
+
+done:
+ mutex_exit(&sc->sc_slock);
+ bp->b_resid = bp->b_bcount;
+ biodone(bp);
}
int
Home |
Main Index |
Thread Index |
Old Index