Skip to content

Commit d9e0b48

Browse files
committed
netfilter, bpf: Adjust timeouts of non-confirmed CTs in bpf_ct_insert_entry()
jira VULN-430 cve-bf CVE-2023-4244 commit-author Ilya Leoshkevich <iii@linux.ibm.com> commit 837723b bpf_nf testcase fails on s390x: bpf_skb_ct_lookup() cannot find the entry that was added by bpf_ct_insert_entry() within the same BPF function. The reason is that this entry is deleted by nf_ct_gc_expired(). The CT timeout starts ticking after the CT confirmation; therefore nf_conn.timeout is initially set to the timeout value, and __nf_conntrack_confirm() sets it to the deadline value. bpf_ct_insert_entry() sets IPS_CONFIRMED_BIT, but does not adjust the timeout, making its value meaningless and causing false positives. Fix the problem by making bpf_ct_insert_entry() adjust the timeout, like __nf_conntrack_confirm(). Fixes: 2cdaa3e ("netfilter: conntrack: restore IPS_CONFIRMED out of nf_conntrack_hash_check_insert()") Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Cc: Florian Westphal <fw@strlen.de> Link: https://lore.kernel.org/bpf/20230830011128.1415752-3-iii@linux.ibm.com Signed-off-by: Alexei Starovoitov <ast@kernel.org> (cherry picked from commit 837723b) Signed-off-by: Marcin Wcisło <marcin.wcislo@conclusive.pl>
1 parent e774e89 commit d9e0b48

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

net/netfilter/nf_conntrack_bpf.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,8 @@ struct nf_conn *bpf_ct_insert_entry(struct nf_conn___init *nfct_i)
339339
struct nf_conn *nfct = (struct nf_conn *)nfct_i;
340340
int err;
341341

342+
if (!nf_ct_is_confirmed(nfct))
343+
nfct->timeout += nfct_time_stamp;
342344
nfct->status |= IPS_CONFIRMED;
343345
err = nf_conntrack_hash_check_insert(nfct);
344346
if (err < 0) {

0 commit comments

Comments
 (0)