Skip to content

Commit

Permalink
netfilter: cttimeout: fix slab-out-of-bounds read in cttimeout_net_exit
Browse files Browse the repository at this point in the history
syzbot reports:
BUG: KASAN: slab-out-of-bounds in __list_del_entry_valid+0xcc/0xf0 lib/list_debug.c:42
[..]
 list_del include/linux/list.h:148 [inline]
 cttimeout_net_exit+0x211/0x540 net/netfilter/nfnetlink_cttimeout.c:617

No reproducer so far. Looking at recent changes in this area
its clear that the free_head must not be at the end of the
structure because nf_ct_timeout structure has variable size.

Reported-by: <[email protected]>
Fixes: 78222ba ("netfilter: cttimeout: decouple unlink and free on netns destruction")
Signed-off-by: Florian Westphal <[email protected]>
Signed-off-by: Pablo Neira Ayuso <[email protected]>
  • Loading branch information
Florian Westphal authored and ummakynes committed May 27, 2022
1 parent 56b14ec commit aeed55a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions net/netfilter/nfnetlink_cttimeout.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ static unsigned int nfct_timeout_id __read_mostly;

struct ctnl_timeout {
struct list_head head;
struct list_head free_head;
struct rcu_head rcu_head;
refcount_t refcnt;
char name[CTNL_TIMEOUT_NAME_MAX];
struct nf_ct_timeout timeout;

struct list_head free_head;
/* must be at the end */
struct nf_ct_timeout timeout;
};

struct nfct_timeout_pernet {
Expand Down

0 comments on commit aeed55a

Please sign in to comment.