Commit 47d4b36
committed
netfilter: conntrack: fix rmmod double-free race
jira VULN-430
cve-pre CVE-2023-4244
commit-author Florian Westphal <fw@strlen.de>
commit e6d57e9
nf_conntrack_hash_check_insert() callers free the ct entry directly, via
nf_conntrack_free.
This isn't safe anymore because
nf_conntrack_hash_check_insert() might place the entry into the conntrack
table and then delteted the entry again because it found that a conntrack
extension has been removed at the same time.
In this case, the just-added entry is removed again and an error is
returned to the caller.
Problem is that another cpu might have picked up this entry and
incremented its reference count.
This results in a use-after-free/double-free, once by the other cpu and
once by the caller of nf_conntrack_hash_check_insert().
Fix this by making nf_conntrack_hash_check_insert() not fail anymore
after the insertion, just like before the 'Fixes' commit.
This is safe because a racing nf_ct_iterate() has to wait for us
to release the conntrack hash spinlocks.
While at it, make the function return -EAGAIN in the rmmod (genid
changed) case, this makes nfnetlink replay the command (suggested
by Pablo Neira).
Fixes: c56716c ("netfilter: extensions: introduce extension genid count")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
(cherry picked from commit e6d57e9)
Signed-off-by: Marcin Wcisło <marcin.wcislo@conclusive.pl>1 parent 709f6c7 commit 47d4b36
2 files changed
+15
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
890 | 890 | | |
891 | 891 | | |
892 | 892 | | |
893 | | - | |
894 | | - | |
895 | | - | |
896 | | - | |
| 893 | + | |
| 894 | + | |
897 | 895 | | |
898 | 896 | | |
899 | 897 | | |
| |||
928 | 926 | | |
929 | 927 | | |
930 | 928 | | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
931 | 942 | | |
932 | 943 | | |
933 | 944 | | |
| |||
936 | 947 | | |
937 | 948 | | |
938 | 949 | | |
939 | | - | |
940 | | - | |
941 | | - | |
942 | | - | |
943 | | - | |
944 | | - | |
945 | 950 | | |
946 | 951 | | |
947 | 952 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2316 | 2316 | | |
2317 | 2317 | | |
2318 | 2318 | | |
2319 | | - | |
2320 | | - | |
2321 | | - | |
2322 | 2319 | | |
2323 | 2320 | | |
2324 | 2321 | | |
| |||
0 commit comments