BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Linpu Yu" <linpu5433@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf v4] xskmap: reject TX-only AF_XDP sockets
Date: Fri, 08 May 2026 21:51:32 +0000	[thread overview]
Message-ID: <20260508215133.7FCA3C2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260508144344.694-1-linpu5433@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Returning -ENOBUFS when rejecting a TX-only AF_XDP socket during map insertion is semantically incorrect and deviates from previous behavior.
--

commit cc939da4429db85f32555fd19f4546a51d44ca3d
Author: Linpu Yu <linpu5433@gmail.com>

xskmap: reject TX-only AF_XDP sockets

This commit rejects TX-only AF_XDP sockets during XSKMAP updates to prevent
a kernel crash in xsk_generic_rcv(). It checks if the socket lacks an Rx
ring and returns an error before inserting it into the map.

> diff --git a/net/xdp/xskmap.c b/net/xdp/xskmap.c
> index afa457506274c..3bff346308d0f 100644
> --- a/net/xdp/xskmap.c
> +++ b/net/xdp/xskmap.c
> @@ -184,6 +184,10 @@ static long xsk_map_update_elem(struct bpf_map *map, void *key, void *value,
>  	}
>  
>  	xs = (struct xdp_sock *)sock->sk;
> +	if (!READ_ONCE(xs->rx)) {
> +		sockfd_put(sock);
> +		return -ENOBUFS;

Should this return -EOPNOTSUPP or -EINVAL instead?

Earlier in this same function, -EOPNOTSUPP is returned when the socket
family is not PF_XDP. Returning -ENOBUFS might be semantically misleading
for userspace since the socket intentionally lacks an Rx ring by design,
rather than experiencing a temporary buffer shortage.

> +	}
>  
>  	map_entry = &m->xsk_map[i];
>  	node = xsk_map_node_alloc(m, map_entry);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260508144344.694-1-linpu5433@gmail.com?part=1

  reply	other threads:[~2026-05-08 21:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-08 14:43 [PATCH bpf v4] xskmap: reject TX-only AF_XDP sockets Linpu Yu
2026-05-08 21:51 ` sashiko-bot [this message]
2026-05-09  7:17 ` Jason Xing
2026-05-09 23:20 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260508215133.7FCA3C2BCB0@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=linpu5433@gmail.com \
    --cc=sashiko@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox