The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Martin Schiller" <ms@dev.tdt.de>
Cc: linux-rt-devel@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v3 1/2] net/x25: don't call lock_sock() from softirq in x25_kill_by_neigh()
Date: Wed, 02 Dec 2026 12:02:09 +0000	[thread overview]
Message-ID: <sashiko-outbox-245652@kernel.org> (raw)
In-Reply-To: <20261201-x25-kill-by-neigh-v3-1-7f05bdff15b1@dev.tdt.de>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] net/x25: missing X25_KILL_FLAG check in
  x25_process_rx_frame()
--

commit c78b5f40e4fa8e2412e3a3fc71a271972e1bbfc0
Author: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>

net/x25: don't call lock_sock() from softirq in x25_kill_by_neigh()

This commit replaces lock_sock() in x25_kill_by_neigh() with the socket
spinlock, deferring x25_disconnect() via X25_KILL_FLAG and a proto
release_cb when the socket is owned by user context.

> diff --git a/net/x25/x25_in.c b/net/x25/x25_in.c
> index e47ebd8acd21b..297acfdbfb05d 100644
> --- a/net/x25/x25_in.c
> +++ b/net/x25/x25_in.c
> @@ -450,7 +450,12 @@ int x25_process_rx_frame(struct sock *sk, struct sk_buff *skb)
>  
>  int x25_backlog_rcv(struct sock *sk, struct sk_buff *skb)
>  {
> -	int queued = x25_process_rx_frame(sk, skb);
> +	int queued;
> +
> +	/* Serialize against x25_kill_sock() like the softirq receive path */
> +	spin_lock_bh(&sk->sk_lock.slock);
> +	queued = x25_process_rx_frame(sk, skb);
> +	spin_unlock_bh(&sk->sk_lock.slock);
>  
>  	if (!queued)
>  		kfree_skb(skb);

[Severity: Medium]
Should x25_process_rx_frame() also bail out when X25_KILL_FLAG is set?

When a socket is owned by user context, x25_kill_sock() only sets
X25_KILL_FLAG and leaves x25->state and x25->neighbour intact until
x25_release_cb() runs.  However, release_sock() drains sk->sk_backlog via
__release_sock() -> x25_backlog_rcv() -> x25_process_rx_frame() before
invoking sk->sk_prot->release_cb():

net/x25/x25_in.c:x25_process_rx_frame() {
	struct x25_sock *x25 = x25_sk(sk);
	int queued = 0, frametype, ns, nr, q, d, m;

	if (x25->state == X25_STATE_0)
		return 0;

Because x25_process_rx_frame() does not check X25_KILL_FLAG, frames
queued on sk->sk_backlog before X25_KILL_FLAG was set still run the
state machine for the dead call.  For example, a backlogged
X25_CLEAR_REQUEST or X25_CLEAR_CONFIRMATION frame calls
x25_disconnect(sk, 0, ...), clearing x25->neighbour and setting
sk->sk_err = 0, so x25_release_cb() then skips
x25_disconnect(sk, ENETUNREACH, 0, 0) and clears X25_KILL_FLAG, losing
ENETUNREACH (and without commit a2f4e558b645 ("net/x25: re-check
x25->neighbour after re-acquiring the socket lock"), allowing
x25_recvmsg() -> x25_check_rbuf_owned() -> x25_write_internal() to
dereference a NULL x25->neighbour).

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261201-x25-kill-by-neigh-v3-0-7f05bdff15b1@dev.tdt.de?part=1

  reply	other threads:[~2026-12-02 12:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 12:01 [PATCH net v3 0/2] net/x25: don't call lock_sock() from softirq in x25_kill_by_neigh() Martin Schiller
2026-12-01 12:01 ` [PATCH net v3 1/2] " Martin Schiller
2026-12-02 12:02   ` sashiko-bot [this message]
2026-12-02 12:18     ` Martin Schiller
2026-12-01 12:01 ` [PATCH net v3 2/2] net/x25: re-check x25->neighbour after re-acquiring the socket lock Martin Schiller

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=sashiko-outbox-245652@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --cc=ms@dev.tdt.de \
    --cc=sashiko-reviews@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