summaryrefslogtreecommitdiff
path: root/net/phonet/pn_netlink.c
diff options
context:
space:
mode:
authorThadeu Lima de Souza Cascardo <cascardo@igalia.com>2024-05-02 10:20:06 -0300
committerPaolo Abeni <pabeni@redhat.com>2024-05-06 13:38:14 +0200
commita26ff37e624d12e28077e5b24d2b264f62764ad6 (patch)
treeb66a50e55aaa3e56c763424e19af949c69c67ac0 /net/phonet/pn_netlink.c
parentfa870b45b08ad3a50a305b8f9f5896a5c5f565bc (diff)
net: fix out-of-bounds access in ops_init
net_alloc_generic is called by net_alloc, which is called without any locking. It reads max_gen_ptrs, which is changed under pernet_ops_rwsem. It is read twice, first to allocate an array, then to set s.len, which is later used to limit the bounds of the array access. It is possible that the array is allocated and another thread is registering a new pernet ops, increments max_gen_ptrs, which is then used to set s.len with a larger than allocated length for the variable array. Fix it by reading max_gen_ptrs only once in net_alloc_generic. If max_gen_ptrs is later incremented, it will be caught in net_assign_generic. Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@igalia.com> Fixes: 073862ba5d24 ("netns: fix net_alloc_generic()") Reviewed-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20240502132006.3430840-1-cascardo@igalia.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'net/phonet/pn_netlink.c')
0 files changed, 0 insertions, 0 deletions