Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Replace || by && in KASAN, to increase the pool cov...



details:   https://anonhg.NetBSD.org/src/rev/d82a4e3b6ec4
branches:  trunk
changeset: 458618:d82a4e3b6ec4
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sat Aug 03 09:31:07 2019 +0000

description:
Replace || by && in KASAN, to increase the pool coverage.

Strictly speaking, what we want to avoid is poisoning buffers that were
referenced in a global list as part of the ctor. But, if a buffer indeed
got referenced as part of the ctor, it necessarily has to be unreferenced
in the dtor; which implies it has to have a dtor. So we want both a ctor
and a dtor, and not just one of them.

Note that POOL_QUARANTINE already implicitly provides this increased
coverage.

diffstat:

 sys/kern/subr_pool.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (29 lines):

diff -r b9da1b33e066 -r d82a4e3b6ec4 sys/kern/subr_pool.c
--- a/sys/kern/subr_pool.c      Sat Aug 03 08:13:36 2019 +0000
+++ b/sys/kern/subr_pool.c      Sat Aug 03 09:31:07 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_pool.c,v 1.253 2019/08/02 05:22:14 maxv Exp $     */
+/*     $NetBSD: subr_pool.c,v 1.254 2019/08/03 09:31:07 maxv Exp $     */
 
 /*
  * Copyright (c) 1997, 1999, 2000, 2002, 2007, 2008, 2010, 2014, 2015, 2018
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.253 2019/08/02 05:22:14 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.254 2019/08/03 09:31:07 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -3098,8 +3098,8 @@
 pool_cache_redzone_check(pool_cache_t pc, void *p)
 {
 #ifdef KASAN
-       /* If there is a ctor/dtor, leave the data as valid. */
-       if (__predict_false(pc_has_ctor(pc) || pc_has_dtor(pc))) {
+       /* If there is a ctor+dtor, leave the data as valid. */
+       if (__predict_false(pc_has_ctor(pc) && pc_has_dtor(pc))) {
                return;
        }
 #endif



Home | Main Index | Thread Index | Old Index