xsk: Validate socket state in xsk_recvmsg, prior touching socket members
Subsystems (4)
PATCH 1/1 xsk: Validate socket state in xsk_recvmsg, prior touching socket members
From: Björn Töpel <[email protected]>
In AF_XDP the socket state needs to be checked, prior touching the members of the socket. This was not the case for the recvmsg implementation. Fix that by moving the xsk_is_bound() call.
--- net/xdp/xsk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/xdp/xsk.c +2 -2
@@ -554,12 +554,12 @@ static int xsk_recvmsg(struct socket *sock, struct msghdr *m, size_t len, int flstruct sock *sk = sock->sk;struct xdp_sock *xs =xdp_sk (sk); +if (unlikely (!xsk_is_bound (xs))) +return -ENXIO ;if (unlikely (!(xs->dev->flags &IFF_UP )))return -ENETDOWN ;if (unlikely (!xs->rx))return -ENOBUFS ; -if (unlikely (!xsk_is_bound (xs))) -return -ENXIO ;if (unlikely (need_wait))return -EOPNOTSUPP ;
base-commit: 34da87213d3ddd26643aa83deff7ffc6463da0fc
Signature · 1 line
2.27.0
Quoted 7 lines · Björn Töpel
From: Björn Töpel <[email protected]>
In
AF_XDPthe socket state needs to be checked, prior touching the members of the socket. This was not the case for the recvmsg implementation. Fix that by moving thexsk_is_bound()call.
Quoted 6 lines
Reported-by kernel test robot <[email protected]>Fixes 45a86681844e ("xsk: Add support for recvmsg()")Signed-off-by Björn Töpel <[email protected]>--- net/xdp/xsk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 24 lines
net/xdp/xsk.c +2
-2@@ -554,12 +554,12 @@ static int xsk_recvmsg(struct socket *sock, struct msghdr *m, size_t len, int flstruct sock *sk = sock->sk;struct xdp_sock *xs =xdp_sk (sk); +if (unlikely (!xsk_is_bound (xs))) +return -ENXIO ;if (unlikely (!(xs->dev->flags &IFF_UP )))return -ENETDOWN ;if (unlikely (!xs->rx))return -ENOBUFS ; -if (unlikely (!xsk_is_bound (xs))) -return -ENXIO ;if (unlikely (need_wait))return -EOPNOTSUPP ;base-commit:
34da87213d3ddd26643aa83deff7ffc6463da0fc--
2.27.0
This patch was applied to bpf/bpf-next.git (refs/heads/master):
Hello:
This patch was applied to bpf/bpf-next.git (refs/heads/master):
Quoted 11 lines · On Mon, 7 Dec 2020 09:20:08 +0100 you wrote:
From: Björn Töpel <[email protected]>
In
AF_XDPthe socket state needs to be checked, prior touching the members of the socket. This was not the case for the recvmsg implementation. Fix that by moving thexsk_is_bound()call.Reported-by kernel test robot <[email protected]>Fixes 45a86681844e ("xsk: Add support for recvmsg()")Signed-off-by Björn Töpel <[email protected]>[...]
Here is the summary with links:
- [bpf-next] xsk: Validate socket state in xsk_recvmsg, prior touching socket members
https://git.kernel.org/bpf/bpf-next/c/3546b9b8eced
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html