NetBSD-Bugs archive

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

Re: kern/60975: NPF rules are almost never BPF JIT compiled since 2014



The following reply was made to PR kern/60975; it has been noted by GNATS.

From: Alexander Nasonov <alnsn%yandex.ru@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: kern-bug-people%netbsd.org@localhost, gnats-admin%netbsd.org@localhost,
	netbsd-bugs%netbsd.org@localhost
Subject: Re: kern/60975: NPF rules are almost never BPF JIT compiled since
 2014
Date: Sun, 15 Nov 2026 15:13:01 +0000

 joe%eloisystems.com@localhost via gnats wrote:
 > >Number:         60975
 > >Category:       kern
 > >Synopsis:       NPF rules are almost never BPF JIT compiled since 2014
 > >Confidential:   no
 > >Severity:       serious
 > >Priority:       high
 > >Responsible:    kern-bug-people
 > >State:          open
 > >Class:          sw-bug
 > >Submitter-Id:   net
 > >Arrival-Date:   Fri Nov 06 22:45:00 +0000 2026
 > >Originator:     Emmanuel Nyarko
 > >Release:        NetBSD 11
 > >Organization:
 > NetBSD
 > >Environment:
 > NetBSD  11.0_STABLE NetBSD 11.0_STABLE 
 > >Description:
 > 
 > wrong size is passed to npf_bpf_compile. the compile function expects a instruction size count 
 > but the byte count of the nvlist blob is what is sent to BPF JIT.
 > 
 > This almost always leads to RET instructions not falling on the last BPF code
 > or random crashes rules count are more than the blob size.
 
 The title is misleading. Even though a wrong size is passed, it's
 harmless in stable releases because bpfjit doesn't read unreachable
 code.
 
 Below is a copy of my analysis sent to source-changes-d:
 
 Alexander Nasonov wrote:
 > In stable releases it reads past the end of allocations but it generates
 > valid jitted code.
 
 Further analysis below. Stable releases should be fine,
 because I don't see reads of unreachable insns anywhere.
 
 optimize_pass1 doesn't read unreachable insns:
 
 	for (i = 0; i < insn_count; i++) {
 		if (!SLIST_EMPTY(&insn_dat[i].bjumps))
 			unreachable = false;
 		insn_dat[i].unreachable = unreachable;
 
 		if (unreachable)
 			continue;
 
 optimize_pass2 doesn't read unreachable insns, it only
 computes addresses:
 
 	for (i = insn_count; i != 0; i--) {
 		pc = &insns[i-1];
 		pd = &insn_dat[i-1];
 
 		if (pd->unreachable)
 			continue;
 
 optimize_pass3 doesn't read unreachable insns either:
 
 	for (i = 0; i < insn_count; i++) {
 		if (insn_dat[i].unreachable)
 			continue;
 
 --
 Alex
 



Home | Main Index | Thread Index | Old Index