Article View: linux.kernel.netdev
Article #10939[PATCH net] net: raw: fix ICMP unreachable sent when receive queue is full
From: Jiayuan Chen
Date: Wed, 04 Nov 2026 11:57
Date: Wed, 04 Nov 2026 11:57
94 lines
11401 bytes
11401 bytes
It's found in a raw socket application. When the application doesn't
read packets in time, the client receives ICMP Protocol Unreachable,
which makes the client abort the session.
The reason is that the server hits the sk_rcvbuf limit, and
raw_v4_input() skips the socket before setting 'delivered', so it
returns 0. Then ip_protocol_deliver_rcu() sees 'raw' is 0, thinks no one
handles this protocol and calls icmp_send() to send ICMP Protocol
Unreachable.
IPv6 has the same issue, ip6_protocol_deliver_rcu() sends ICMPv6
Parameter Problem instead.
Also, we'd better run icmp_filter() and ip_mc_sf_allow() (icmpv6_filter()
for IPv6) before we check sk_rcvbuf, otherwise packets rejected by
ICMP_FILTER/ICMPV6_FILTER or the multicast filter are counted in
sk_drops. So move the check right before skb_clone().
Fixes: d721812aa875 ("ipv4: raw: check sk->sk_rcvbuf earlier")
Fixes: 026763ece881 ("ipv6: raw: check sk->sk_rcvbuf earlier")
Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
---
net/ipv4/raw.c | 15 ++++++++-------
net/ipv6/raw.c | 15 ++++++++-------
2 files changed, 16 insertions(+), 14 deletions(-)
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index 9d01006d8189..f33a9dfc5309 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -182,18 +182,19 @@ static int raw_v4_input(struct net *net, struct sk_buff *skb,
iph->saddr, iph->daddr, dif, sdif))
continue;
- if (atomic_read(&sk->sk_rmem_alloc) >=
- READ_ONCE(sk->sk_rcvbuf)) {
- sk_drops_inc(sk);
- continue;
- }
-
delivered = 1;
if ((iph->protocol != IPPROTO_ICMP || !icmp_filter(sk, skb)) &&
ip_mc_sf_allow(sk, iph->daddr, iph->saddr,
skb->dev->ifindex, sdif)) {
- struct sk_buff *clone = skb_clone(skb, GFP_ATOMIC);
+ struct sk_buff *clone;
+
+ if (atomic_read(&sk->sk_rmem_alloc) >=
+ READ_ONCE(sk->sk_rcvbuf)) {
+ sk_drops_inc(sk);
+ continue;
+ }
+ clone = skb_clone(skb, GFP_ATOMIC);
/* Not releasing hash table! */
if (clone)
raw_rcv(sk, clone);
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index b965258cf9e5..eb99f4a906ec 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -160,12 +160,6 @@ static bool ipv6_raw_deliver(struct sk_buff *skb, int nexthdr)
inet6_iif(skb), inet6_sdif(skb)))
continue;
- if (atomic_read(&sk->sk_rmem_alloc) >=
- READ_ONCE(sk->sk_rcvbuf)) {
- sk_drops_inc(sk);
- continue;
- }
-
delivered = true;
switch (nexthdr) {
case IPPROTO_ICMPV6:
@@ -197,8 +191,15 @@ static bool ipv6_raw_deliver(struct sk_buff *skb, int nexthdr)
if (filtered < 0)
break;
if (filtered == 0) {
- struct sk_buff *clone = skb_clone(skb, GFP_ATOMIC);
+ struct sk_buff *clone;
+
+ if (atomic_read(&sk->sk_rmem_alloc) >=
+ READ_ONCE(sk->sk_rcvbuf)) {
+ sk_drops_inc(sk);
+ continue;
+ }
+ clone = skb_clone(skb, GFP_ATOMIC);
/* Not releasing hash table! */
if (clone)
rawv6_rcv(sk, clone);
--
2.43.0
Technical Details
Message-ID:
<20261104115732.322151-1-jiayuan.chen@linux.dev>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-356398-linux-kernel-netdev=dewy.ruShow 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-356398-linux-kernel-netdev=dewy.ru From: jiayuan.chen@linux.dev (Jiayuan Chen) Newsgroups: linux.kernel.netdev Subject: [PATCH net] net: raw: fix ICMP unreachable sent when receive queue is full Date: Wed, 4 Nov 2026 19:57:26 +0800 Organization: Usenet Network Message-ID: <20261104115732.322151-1-jiayuan.chen@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3384102"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:BtuV+mbw6lJOLGgPIvtUsnyfTfg= sha256:f3xh9YPHEmG94bO/wxzDnTh4bi7F/8ekP5Xs1gZ5Vok= sha1:jvLq45s0FK2C4AmNZ+XfFTO8aRs= sha256:upowgnm0P1E4Tdb4iFhNgQvpCNWXz1UT9AdlGl6e9bo= 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 B2E96112BA7; Wed, 4 Nov 2026 14:58:11 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -2.151 X-Spam-Status: No, score=-2.151 tagged_above=-9999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, HK_RANDOM_FROM=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 (1024-bit key) header.d=linux.dev 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 VHDE9goK24On; Wed, 4 Nov 2026 14:58:06 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-356398-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id B1980112BA2; Wed, 4 Nov 2026 14:57:56 +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 44501606A33; Wed, 4 Nov 2026 11:57:52 +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=1793793469; b=yBxkckh+Nv4HJ65Ze/G4P/IHuwgtBS5ZcBuJ1wNGdFZP7x0vSekU4qcwVpPDh2Fqs7o7 SjqavWgLx9qWyDBqjnFhdEG3cEZumqzakfrr3I98ROl14uFH//nxuIZ6lKccvX5QaqhqO iqC9hbMSozWmNjld9ixsLPKABv1xcK3J5rW9US0TFhc2VldXEpGFf2Lvmcp8CeQXSCMtR 45+X4cu55sQKYY/uMxXIBZIrxdMAogn6ByUjKsxpRmjmhjALGqdC/Nu7GwFOCHcZwNzR+ pY4K052+VTD6owEWvpY6kwkiQY3NAz8vxIuYtcG5mSq2qa9iu9BxpX7UIad4xHV/HcA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793793469; h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature: X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc: Subject:Date:Message-ID:X-Mailer:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version:Content-Transfer-Encoding; bh=STtrZRO2YxEVx3H+ha1sUlpeSWj4yt3rSoZpXoj+5so=; b=eE78HvFVOd5RibeNlgaEVHf1roR2epifRw9+dIgrskYoNbJsZQTUmhROADEba2iENFKN C70fmJjMG3YJhYnhWkvRHVBRUMIpGP+51NZXwmg/79h/DY0bDyzb7KGP8pWunVfEynvoi iiUZpnfvfw799J+LQ+wKY2bZlADFuwH4Ab4ADs27Es2PAuCAC3KrEokrWNWm1IU/1wkan xKFCZsRSk9OwqrvJUE57xKG9T4VAo2O49eePxxvajdk/2Gw47gmO4/Xe1cuwaMErA6q2E nL2QLeGWaENwF+FEZOtJFIp4ebVLOXLTs7xi9m3zVrt2ASVCi4naVuNWsNxc2BJrdNw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=NO+1zbRS; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; 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 71C4D606A332; Wed, 4 Nov 2026 11:57:49 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=NO+1zbRS X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.54 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793793468; b=IITJTPFdx+QDIFRXUmCSUmx4fgrGPaafaXXnN0efjlJycS4kEeWfUZ4UnliN39iWKkAo XmpB73MJ6cNmmO4KRZiSd3ndRV3pAHSurMmrYr8bR4dqTvPyKACbsOC11BTxi2kybKWOT Abe7XED+Wd9jxkT5HxC8ZH/YK/Ve0GAo49rkSedH+WRvrzZulzYr9D1Cxn3SBiDYVDwF6 kgfdD5OM6YiFLG1IaCvr8qxDDtDLvJBCK1bbS0JRv+HGJA5ol57ymn83YK2CtINrqPPDj IrrHwiLFuBgPbED7JBZPwPseBreF6+olnjou6WuHxjVeq53L6aFOHPSZnQUF2drieUg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793793468; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc:Subject:Date:Message-ID: X-Mailer:MIME-Version:Content-Transfer-Encoding; bh=STtrZRO2YxEVx3H+ha1sUlpeSWj4yt3rSoZpXoj+5so=; b=A7XbAXsP9GcX4+Zv8e+K+1FP18nfuyc3QTzvyXlM/XGW6KOB0YrIybGJ0trsGNybTjdP oCiVl6EiHmHbW/8bcN9jrTS+aVJi/XSJg0igN09usRwLb7ZUDTMeUXmXJK2PHiUynvqfl rLfzZkSZ0DPYyVmRP3dIwthhoOyVmcPNj17M0fXLw60QJRL0iM8LYdnIdUBzqwT9zN82D aEARdWRa7G3quu1ksWXVmQbFnBxMYdkaCuyhcaay+KgLNA8Lg9tKE7gndh5MI2tr71gw/ aknwNa7+FxbWfPXmFW/Bi/F2eNeXaY/nQzmo2G1I6zxau4uzxsJ/tsj71XogUAxGR6A== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=NO+1zbRS; arc=none smtp.remote-ip=95.215.58.54 X-Received: from mta1.migadu.com (out-54.mta1.migadu.com [95.215.58.54]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B044D606A31B for <netdev@vger.kernel.org>; Wed, 4 Nov 2026 11:57:47 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B044D606A31B X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Envelope-To: netdev@vger.kernel.org X-DKIM-Signature: a=rsa-sha256; bh=9ozzZ0J6mwwASk+DJQ5lOt7LdV8xbNav1SzRVl12KLg=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1793793465; v=1; x=1794398265; b=NO+1zbRSM+V63urpcuwaMWPllejHdbakKNru/UJnunnDdRNDWf8o51B11Rfz3uSE/KHgzEMg yQH0pvmOz4ud5jVnLfrrSbGaVUESnsmWt7GoyZF2n1UvtODIZ6hIvsL/V1A7RHN4QOAMMUPJngg m9d03mraUzvq51pKW3OfIxNY= X-Envelope-To: netdev@vger.kernel.org X-Received: by smtp.migadu.com with ESMTPS id 8e7a7c0b85afa322; Wed, 04 Nov 2026 11:57:45 +0000 X-Mizu-Trace-ID: 8e7a7c0b85afa322 X-Migadu-Flow: FLOW_OUT X-Cc: Jiayuan Chen <jiayuan.chen@linux.dev>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>, Willem de Bruijn <willemb@google.com>, Kees Cook <kees@kernel.org>, Jeff Layton <jlayton@kernel.org>, Runyu Xiao <runyu.xiao@seu.edu.cn>, Breno Leitao <leitao@debian.org>, "Gustavo A. R. Silva" <gustavoars@kernel.org>, Joe Damato <joe@dama.to>, Stanislav Fomichev <sdf@fomichev.me>, Li RongQing <lirongqing@baidu.com>, linux-kernel@vger.kernel.org X-Mailer: git-send-email 2.43.0 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