]> www.infradead.org Git - users/jedix/linux-maple.git/commit
rtnetlink: do_setlink: Use struct sockaddr_storage
authorKees Cook <kees@kernel.org>
Wed, 21 May 2025 20:46:15 +0000 (13:46 -0700)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 27 May 2025 06:25:43 +0000 (08:25 +0200)
commit6b12e0a3c3c9565c7dc106e2a8b1d433b1aa8eb6
treee1b2ebd412bdfe544f8dd192b011f7bc9e0801b3
parent9ca6804ab7c34f65fcf2e29333a39e7807c30b60
rtnetlink: do_setlink: Use struct sockaddr_storage

Instead of a heap allocating a variably sized struct sockaddr and lying
about the type in the call to netif_set_mac_address(), use a stack
allocated struct sockaddr_storage. This lets us drop the cast and avoid
the allocation.

Putting "ss" on the stack means it will get a reused stack slot since
it is the same size (128B) as other existing single-scope stack variables,
like the vfinfo array (128B), so no additional stack space is used by
this function.

Acked-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Kees Cook <kees@kernel.org>
Link: https://patch.msgid.link/20250521204619.2301870-7-kees@kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
net/core/rtnetlink.c