Source-Changes-HG archive

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

[src/trunk]: src/sys/net bpf(4): Handle null bf_insn on free.



details:   https://anonhg.NetBSD.org/src/rev/a8b96e2b5b6b
branches:  trunk
changeset: 363914:a8b96e2b5b6b
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Tue Mar 15 13:00:44 2022 +0000

description:
bpf(4): Handle null bf_insn on free.

This is not guaranteed by bpf_setf to be nonnull.

Reported-by: syzbot+de1ec9471dfc2f283dda%syzkaller.appspotmail.com@localhost

diffstat:

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

diffs (30 lines):

diff -r 97c04191fc59 -r a8b96e2b5b6b sys/net/bpf.c
--- a/sys/net/bpf.c     Tue Mar 15 10:37:42 2022 +0000
+++ b/sys/net/bpf.c     Tue Mar 15 13:00:44 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bpf.c,v 1.245 2022/03/12 17:23:32 riastradh Exp $      */
+/*     $NetBSD: bpf.c,v 1.246 2022/03/15 13:00:44 riastradh Exp $      */
 
 /*
  * Copyright (c) 1990, 1991, 1993
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.245 2022/03/12 17:23:32 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.246 2022/03/15 13:00:44 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_bpf.h"
@@ -2089,9 +2089,9 @@
 {
 
        KASSERT(filter != NULL);
-       KASSERT(filter->bf_insn != NULL);
 
-       kmem_free(filter->bf_insn, filter->bf_size);
+       if (filter->bf_insn != NULL)
+               kmem_free(filter->bf_insn, filter->bf_size);
        if (filter->bf_jitcode != NULL)
                bpf_jit_freecode(filter->bf_jitcode);
        kmem_free(filter, sizeof(*filter));



Home | Main Index | Thread Index | Old Index