πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #5382

Re: [PATCH net-next 1/3] net: qrtr: do not take the sock lock on blocking recv

#5382
From: netdev-bot+sashiko
Date: Tue, 20 Oct 2026 09:35
94 lines
11076 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The commit "net: qrtr: do not take the sock lock on blocking
  recv" fixes a real, user-visible defect but has no Fixes: tag.
- [Low] The concern says qrtr_ioctl(TIOCINQ) (net/qrtr/af_qrtr.c:1234),
  which calls skb_peek(&sk->sk_receive_queue) under lock_sock() only, is…

--

net: qrtr: do not take the sock lock on blocking recv

This patch changes qrtr_recvmsg() so it no longer holds lock_sock() while
it blocks in skb_recv_datagram(). The lock is now taken only after a
datagram has been dequeued. Before this, other calls on the same socket
could not run while a recv() was waiting.

> Signed-off-by: Chunkai Deng <chunkai.deng@oss.qualcomm.com>

[Severity: Low]
Should this have a Fixes: tag? The commit message describes a hang that
users can see. A thread blocked in recv() holds lock_sock() inside
skb_recv_datagram(). While it waits, sendmsg(), bind(), connect() or
ioctl() from another thread on the same socket cannot proceed until a
datagram arrives.

In qrtr_recvmsg(), the lock_sock() held across skb_recv_datagram() and
the release_sock() calls on the early return paths all come from the
original driver, so perhaps:

Fixes: bdabad3e363d ("net: Add Qualcomm IPC router")

> diff --git a/net/qrtr/af_qrtr.c b/net/qrtr/af_qrtr.c
> index e7b3647424b8f..0851763d83baf 100644
> --- a/net/qrtr/af_qrtr.c
> +++ b/net/qrtr/af_qrtr.c
> @@ -1109,18 +1109,14 @@ static int qrtr_recvmsg(struct socket *sock, struct msghdr *msg,
>  	struct qrtr_cb *cb;
>  	int copied, rc;
>  
> -	lock_sock(sk);
> -
> -	if (sock_flag(sk, SOCK_ZAPPED)) {
> -		release_sock(sk);
> +	if (sock_flag(sk, SOCK_ZAPPED))
>  		return -EADDRNOTAVAIL;
> -	}
>  
>  	skb = skb_recv_datagram(sk, flags, &rc);
> -	if (!skb) {
> -		release_sock(sk);
> +	if (!skb)
>  		return rc;
> -	}
> +
> +	lock_sock(sk);

[Severity: Low]
This isn't a bug, but the dequeue now happens outside lock_sock(), so
qrtr_ioctl(TIOCINQ) is no longer serialized against it:

net/qrtr/af_qrtr.c:qrtr_ioctl() {
    ...
	lock_sock(sk);
    ...
	case TIOCINQ:
		skb = skb_peek(&sk->sk_receive_queue);
		if (skb)
			len = skb->len;
    ...
}

As far as I can tell this is still memory safe. skb_free_datagram() in
qrtr_recvmsg() still runs under lock_sock(). The consume_skb() in
skb_set_peeked() only drops a reference on a shared skb.

The length TIOCINQ reports also matches some valid ordering of the ioctl
and the recv. The unlocked skb_peek() racing with __skb_queue_tail() on
the enqueue path was already possible before this patch.

Would it be worth taking sk_receive_queue.lock around the skb_peek() in
TIOCINQ, as packet_ioctl() does? Then the ioctl would not rely on
qrtr_recvmsg() freeing the skb under lock_sock().

>  	cb = (struct qrtr_cb *)skb->cb;
>  
>  	copied = skb->len;

-- 
Sashiko AI review Β· https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261016-qrtr-add-shutdown-v1-0-e1cc01ca5919%40oss.qualcomm.com
Technical Details
Message-ID: <179248895205.3135.9429539491944688688@kernel.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-349148-linux-kernel-netdev=dewy.ru
References: <20261016-qrtr-add-shutdown-v1-1-e1cc01ca5919@oss.qualcomm.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-349148-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next 1/3] net: qrtr: do not take the sock lock on
 blocking recv
Date: Tue, 20 Oct 2026 09:35:52 +0000
Organization: Usenet Network
Message-ID: <179248895205.3135.9429539491944688688@kernel.org>
References: <20261016-qrtr-add-shutdown-v1-1-e1cc01ca5919@oss.qualcomm.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3822037"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:TyHSlPT4B1hJH1cod6+rQ7G46rc= sha256:13DuQbqT+iXOUZhJzEBCA1sr8W+fwZNJuBL8qC47bdo=
	sha1:R3DVHYrMxdEDc9LLE9Iu955RDZo= sha256:Mrt4XfYWCgs8V+kq6joQHhHwxHoTfl2xzO8imDiUAVc=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id CC675110C66; Tue, 20 Oct 2026 12:36:35 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.829
X-Spam-Status: No, score=-3.829 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.329, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id keIO_bF_VA_L;
	Tue, 20 Oct 2026 12:36:31 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-349148-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 4BCE2110C65; Tue, 20 Oct 2026 12:36:23 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id E915060A48B; Tue, 20 Oct 2026 09:36:05 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1792488960;
	b=wasFu8LNwS2TiHm8Cu9JU1xnbbnnlV3gjNtFK/dVloZ/POByW6ha/sD1KoJLVw0oEPm1
	 2+a3MlM3mhrj82injiETLLjIET8IV3gdSd/rmWTvUvhSfygdkNHbYEknoDXdMqkkgMXv/
	 oZU8cXhsuVilj/oqe1MNIgjpV9clsFyFc9WtMrafiEgvEZjzvflfUQq4bmSpriJlKEHJk
	 7Jzy67+zQk/HXTKtCcFm5bLlNtlNcskp9egzZUSkUceRskpk/WmSJB8zBjbJKc3RlZX9I
	 76UM4AcdnSKrl3a7i5qzt5TDkvRaWkUfchY6t6OlGgadrkUOiyRoH2POaeFYwXZyi+g==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792488960;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=HSmjPI16nvDN8Ul0NAtxX99vasGqIsxArWPRVzPVvL4=;
	b=1+kmhN4zXcPtgWPSwEKHAOh85k4I/QCOQ6PBPN9c/EpOmoVeju2QO15OwkiKMYNKcDXM
	 W0Fxcdr2o9xBQtkpPq2RT95wxOlDSx0FFlBcyAC7DZDZjUeU2ie9GE/Pt9IiJZbtOK+ZL
	 VHOXVZdfWOef3PK03mCyxVGkv/E0T7Wp51ZF82Ut6KibPkNPxXUM2J9QWx8q9B6u+JjDZ
	 u7juFJoS7S6eKqk+lsYlJix6w6YUssgkV0iSmU3ZwHNvCWcb8bcAmwOBRE5FoLAKEzJtO
	 ww/NH7k5DhhP0qxQw2niefYeMsClIGOJ+MxgpzShQ2Swf4dMV919lL7RKyRT8sY8Q+w==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=T0LhVunn;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 011B060A2605;
	Tue, 20 Oct 2026 09:36:00 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=T0LhVunn
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1792488954;
	b=PRV3b5ORGvshoUGCPieGahrd2zvQUXYCEMJGFoARygnXwMc69hxpljMeoSHPrw4VIeWw
	 ihUaualC1Lj1gZI5eVSLcCJd17vQXaZkFd9+Opd6QJp9r6Jkf1y8RFNSR4YcmUW6NuQzI
	 TGWdU/SM0xu4/T/OeIslK/zcYKGSW6GWU7gn16U7kHZ5VmuNPbBZOYLR2rI3Vo6An8fSz
	 P6z0H7jfZolYkYhxAJGN2zMa6+C/YW2HefcsLomo2P2qi66KncE4OZaOjCceNkjiNdmZr
	 2S2LIzmAfQCsaypXGtCQSXBRR4S7eHFOe52HB5nJyn2dfzJmYT8MeagIHAS+m3wANxg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792488954;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=HSmjPI16nvDN8Ul0NAtxX99vasGqIsxArWPRVzPVvL4=;
	b=axmDNX00zdS/lx28xxRUIlOp7LyLM1+cOt5q5B36AI3WenVoMcZMYb6FTCTmarDAEpMC
	 AxMPt5og/8pZXhRz8iaiVuVzXgMaG/y0ZyPqgn7CUT0QPLP0i0Mh85hlHOGeBconoSBqp
	 e2slpfvPP6vsPwTt38+XV8DLikt1wxoVDPHfXTmnUaoJVWJ2qFmz+2CND4jUiso3YqIiE
	 IvbI6cZahbE90C2i7wPHvbLZwuJH321l/c9k8+40JRa7TE5C9r2AIsxH2VWQEjowNQa49
	 Fol+o1HwpKhqkGV7217iswWPRnhw5BhJvazjP/bUTIuKAMJl/q8AsiyCas1oCTdL3Xg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=T0LhVunn;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id B9FE5606A327;
	Tue, 20 Oct 2026 09:35:53 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86AE61F000C4;
	Tue, 20 Oct 2026 09:35:52 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1792488953;
	bh=HSmjPI16nvDN8Ul0NAtxX99vasGqIsxArWPRVzPVvL4=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=T0LhVunnP9LkJ49WUDcR9bg/c+SeBVw6wOT7ZN4DiA4Z8Xx179x45rntpoC609Z1u
	 TORpH9toScTu8AeJTwyup6DjDuBZq3Kcyhlr1f/bSq+q54MlYJu/CVEjxYesBObVdV
	 /jiDggaRbY3vtKUp+sj7Im5MJ1DwRmK9mV5+8Htca0m43c6s9epKuTj6cndHgh8HLS
	 t7xhO9rFWJYEoEWHg6JCNSXMGK/z8Q1uz6hoRvZHKoeFq5eKPDvKbDSeV95RlJraYy
	 NzwPjXjjKh0Zb5ew76X63yvHI6mMELqeDLjt4l/IeOdvJ76X0f2ENCN90ZYCHTpSwb
	 q4hbF+74Gm6tA==
X-Cc: mani@kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
 pabeni@redhat.com, horms@kernel.org, linux-arm-msm@vger.kernel.org,
 netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
 tao.zhang1@oss.qualcomm.com, peter.chen@oss.qualcomm.com,
 jeff.johnson@oss.qualcomm.com, konrad.dybcio@oss.qualcomm.com
X-In-Reply-To: <20261016-qrtr-add-shutdown-v1-1-e1cc01ca5919@oss.qualcomm.com>
X-sashiko-severity: Low
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list