Source-Changes-HG archive

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

[src/trunk]: src/sys/kern wapbl_write_revocations(): fix use-after-free when ...



details:   https://anonhg.NetBSD.org/src/rev/c61c4a5b484a
branches:  trunk
changeset: 348045:c61c4a5b484a
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Sun Oct 02 14:38:46 2016 +0000

description:
wapbl_write_revocations(): fix use-after-free when writing more then one
block worth of revocations, introduced in previous commit; discovered by
Brad Harder on current-users

diffstat:

 sys/kern/vfs_wapbl.c |  7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diffs (28 lines):

diff -r 542a3d1fd8dc -r c61c4a5b484a sys/kern/vfs_wapbl.c
--- a/sys/kern/vfs_wapbl.c      Sun Oct 02 14:16:02 2016 +0000
+++ b/sys/kern/vfs_wapbl.c      Sun Oct 02 14:38:46 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_wapbl.c,v 1.81 2016/10/01 13:15:45 jdolecek Exp $  */
+/*     $NetBSD: vfs_wapbl.c,v 1.82 2016/10/02 14:38:46 jdolecek Exp $  */
 
 /*-
  * Copyright (c) 2003, 2008, 2009 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 #define WAPBL_INTERNAL
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.81 2016/10/01 13:15:45 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.82 2016/10/02 14:38:46 jdolecek Exp $");
 
 #include <sys/param.h>
 #include <sys/bitops.h>
@@ -2335,8 +2335,7 @@
        if (wl->wl_dealloccnt == 0)
                return 0;
 
-       wd = SIMPLEQ_FIRST(&wl->wl_dealloclist);
-       while (wd) {
+       while ((wd = SIMPLEQ_FIRST(&wl->wl_dealloclist)) != NULL) {
                wc->wc_type = WAPBL_WC_REVOCATIONS;
                wc->wc_len = blocklen;
                wc->wc_blkcount = 0;



Home | Main Index | Thread Index | Old Index