]> git.baikalelectronics.ru Git - kernel.git/commit
net: prevent address rewrite in kernel_bind()
authorJordan Rife <jrife@google.com>
Thu, 21 Sep 2023 23:46:42 +0000 (18:46 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 19 Oct 2023 21:08:50 +0000 (23:08 +0200)
commit020958c946c0c6e1f41419e69f86f436ae838d0d
tree75f069ed0b4b52ad0d9085a0f98fc78468bf2a21
parent8fcdf7da9d4b9b8103761d84e9c9f81ae9c03247
net: prevent address rewrite in kernel_bind()

commit c889a99a21bf124c3db08d09df919f0eccc5ea4c upstream.

Similar to the change in commit 0bdf399342c5("net: Avoid address
overwrite in kernel_connect"), BPF hooks run on bind may rewrite the
address passed to kernel_bind(). This change

1) Makes a copy of the bind address in kernel_bind() to insulate
   callers.
2) Replaces direct calls to sock->ops->bind() in net with kernel_bind()

Link: https://lore.kernel.org/netdev/20230912013332.2048422-1-jrife@google.com/
Fixes: 4fbac77d2d09 ("bpf: Hooks for sys_bind")
Cc: stable@vger.kernel.org
Reviewed-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Jordan Rife <jrife@google.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/netfilter/ipvs/ip_vs_sync.c
net/rds/tcp_connect.c
net/rds/tcp_listen.c
net/socket.c