From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DE5E23C378A for ; Thu, 14 May 2026 11:45:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778759150; cv=none; b=EMWGybqWySRJRbeq9EwenrqUzpxsyVKxVbQ/EbYP3IrDN9nDIDHa4cnojTyYvPHZAx69GybxVj6w2eX6KXGAxHV/pVBoRaHSe1wDnOPkiMCEa9w7KzESH3cIzFnj1z3vzpQzp3XwkJB1YrOZGemba5ytD0rp6IvLIomGZsFZBB0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778759150; c=relaxed/simple; bh=HzzKtLdDSOU6qk7De5CYxTiWMfze0a1cgEfK3lOcNlM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=qUlSI/jaqv8c6cNbKosBKY6qCbHgiOrATVckVOx79f+A83Kbj/O4OPE15Ae1nB70nQFStpO2wnvEU0ecn8f4R3JBbxfZ0xwtDYy2CcSKHZk4rjWcTiw1zTFhSEn4gvTG9eZ2Rlmrpr/MS47NcgWJpmVTAmjfY/RSpV5bNt7kg0c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=h4JEizDX; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=OdTFDFD7; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="h4JEizDX"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="OdTFDFD7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778759144; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zZr60InQnZWO1LkpnVVTcP+GBmOQnYBqSDneZ78egzQ=; b=h4JEizDXhRmMv8dlbKCJLHLb1bRm4M5erDHufIWgPtw97v7/K2kqcH2PQFiARTVGkYE+NC 5Y1iFJZRtZoYnIbipm1FQzqyU/uA1Y9nDtRqQXcMkN2TUIJTMtIvm74IWywv7v9C0ckcnT Dx+xhJB8Td7Cp6TVzd3HxTih4xe692c= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-608-7wncK0YQPOO5qF5Ta4rN9A-1; Thu, 14 May 2026 07:45:43 -0400 X-MC-Unique: 7wncK0YQPOO5qF5Ta4rN9A-1 X-Mimecast-MFC-AGG-ID: 7wncK0YQPOO5qF5Ta4rN9A_1778759142 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-48e89faa62eso21923105e9.1 for ; Thu, 14 May 2026 04:45:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1778759142; x=1779363942; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=zZr60InQnZWO1LkpnVVTcP+GBmOQnYBqSDneZ78egzQ=; b=OdTFDFD7JaXCOs8XCSf1TIgk75lSZVyA2seKJvO60P8gslr05DHIK4cyHJaeOLoxPy ihVHmwVJsqfLAbNQ+PNTNhv8R3omhi4wGm+XQ2ZMhMxkjAcLUbOJ3b6oyn9VqpspOgR3 VhfhvpfTnAge2iU46B7ReTWlmPLVKkuxtjU9T0IdeSW8kXERma5QRH7RVBUpGbkGdvMy BCyMmkfFLAgD3e0sCYjcgPEZWHWq+eiKl9wwPAOflOigUDFBzmT2XPdvyozP5Hgzm5mB s8KPrCr66n5JsA+yyeKcfzQG3RkfBhKcFO4GJj4drKEYLdBDwEpfmltBaOG8DTK10qkf DZ/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778759142; x=1779363942; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zZr60InQnZWO1LkpnVVTcP+GBmOQnYBqSDneZ78egzQ=; b=Y9s77nBQpNYe2LLZ97MBABSnB0OMYhEEGFMGMRS+abkyUfBoV5iLr9FwDbKmRc0DY/ yD+IScGLke9/YEvuuXP8e9KVKWDc7oEk93CCQihTw96dYqz/V46tVCmgrDu579fL489V 4d0zsSSKQI9d659mIilyW49SzlDHwot4cBYYeAWrAzy6bu5M+TZ93iWLTZFY1XDL9qoE LMSM2T+rsx9FtgLX0EykRJXe7uQkrShwuoQz7hdC658yAuwHFzgwJQlyS2dOGTM5pbtE u9tV0OLcQAG4GXp68B20f0qrShVeBVtFWKfCnIR/7oNK6mLL6TWE7xhG45G6SBECyG84 jJmw== X-Forwarded-Encrypted: i=1; AFNElJ+w3WkPfIqdWZ6RzgMbOzJRXlBJkmFvMIPqtTSqrGNthOD/5ptndOWo31gobsEa/hVgYEiyIek=@vger.kernel.org X-Gm-Message-State: AOJu0YzTLR4zDCf9V/Mj6LbO8I94y9E3fz8LvudUhsOnz+8+VLQTeG0v bI92EfbgyQ46pb9xQcdpdV9jp89CeaA5iahk8pu03dcEtJvQsUtirYHTc2bA45SOsCNn9MWhs38 TVu5H++7ncnrVRfsuaBOckibSQabxZd7xxl3Y4mOrA7vXhPOH8YnIWXrDUQ== X-Gm-Gg: Acq92OHLi7vOwbzBcg+Dx81Itj7gDWBibSFOXzfT+Feq/ZYfj4rQvpzGUiWvQ3ZvcYY agxuSlNKJeDbL3sjL6XVkPdEoWhMKk+3xyxz8A9PeK9VRxrYB59+eSB7KGSQo/mMXAmHaAogoS2 WijRJT6VUil3EbmkghJ1R0XKJqlKv3FF1uM/6QM0TljlQvq6q7EWxRmsdb7Ubj/Kwh4+aRVYE8Y N8PZcqeeuaTWdFnBIP9asPWTLK6b9nf0uRahs9BJX6uuQzv4Ax70i2EwZ/ZBZNsjoKSa4FQfWBf rv9zaTWLcKUFPTK24+H2hpgHsTgWbxNhQNg+vpl09ZG53w/F9ZwoLMeSw5vanxNDv6VGjygU6lP b2IN623H5L8tiWc99qY4z7E0pc5R3k1sK+4Wh1ICZVpRcAJ/8cteav+Q= X-Received: by 2002:a05:600c:4ecc:b0:488:ac01:72b6 with SMTP id 5b1f17b1804b1-48fc9a391fbmr124907435e9.21.1778759142423; Thu, 14 May 2026 04:45:42 -0700 (PDT) X-Received: by 2002:a05:600c:4ecc:b0:488:ac01:72b6 with SMTP id 5b1f17b1804b1-48fc9a391fbmr124906965e9.21.1778759141942; Thu, 14 May 2026 04:45:41 -0700 (PDT) Received: from [192.168.88.32] ([216.128.9.106]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48fdb2c7f93sm57514445e9.10.2026.05.14.04.45.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 14 May 2026 04:45:41 -0700 (PDT) Message-ID: Date: Thu, 14 May 2026 13:45:39 +0200 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 net] net: core: dev: add reprocess depth limit for another_round in __netif_receive_skb_core To: Yizhou Zhao , netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Simon Horman , Stanislav Fomichev , Kuniyuki Iwashima , Samiullah Khawaja , Hangbin Liu , Krishna Kumar , Yuxiang Yang , Xuewei Feng , Qi Li , Ke Xu , stable@vger.kernel.org References: <20260512022127.7818-1-zhaoyz24@mails.tsinghua.edu.cn> From: Paolo Abeni Content-Language: en-US In-Reply-To: <20260512022127.7818-1-zhaoyz24@mails.tsinghua.edu.cn> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 5/12/26 4:21 AM, Yizhou Zhao wrote: > In __netif_receive_skb_core(), the another_round label can be reached > via a TC ingress redirect (bpf_redirect_peer returning -EAGAIN). > > Across network namespaces, two BPF programs on peer devices can redirect > packets back and forth indefinitely, creating an unbounded loop that > monopolizes a CPU core in softirq context. This leads to RCU stalls, > soft lockups, and system-wide denial of service. > > We reproduced it by creating a pair of TC BPF programs across two > network namespaces that redirect packets to each other, and the RCU > subsystem detects a stall: > > ``` > [ 24.835219] rcu: INFO: rcu_preempt detected stalls on CPUs/tasks: > [ 24.835837] rcu: (detected by 0, t=21002 jiffies, g=-627, q=2 ncpus=1) > [ 24.835959] rcu: All QSes seen, last rcu_preempt kthread activity 21002 (4294691810-4294670808), jiffies_till_next_fqs=3, root ->qsmask 0x0 > [ 24.836239] rcu: rcu_preempt kthread starved for 21002 jiffies! g-627 f0x2 RCU_GP_WAIT_FQS(5) ->state=0x0 ->cpu=0 > [ 24.836362] rcu: Unless rcu_preempt kthread gets sufficient CPU time, OOM is now expected behavior. > [ 24.836460] rcu: RCU grace-period kthread stack dump: > [ 24.836601] task:rcu_preempt state:R running task stack:15448 pid:15 tgid:15 ppid:2 task_flags:0x208040 flags:0x00080000 > [ 24.837139] Call Trace: > [ 24.837568] > [ 24.838008] __schedule+0x4ed/0xea0 > [ 24.838934] schedule+0x22/0xd0 > [ 24.839023] schedule_timeout+0x81/0x100 > [ 24.839095] ? __pfx_process_timeout+0x10/0x10 > [ 24.839165] rcu_gp_fqs_loop+0x11b/0x650 > [ 24.839226] ? __pfx_rcu_gp_kthread+0x10/0x10 > [ 24.839282] rcu_gp_kthread+0x17e/0x210 > [ 24.839333] ? __pfx_rcu_gp_kthread+0x10/0x10 > [ 24.839383] kthread+0xdd/0x110 > [ 24.839433] ? __pfx_kthread+0x10/0x10 > [ 24.839481] ret_from_fork+0x1aa/0x260 > [ 24.839538] ? __pfx_kthread+0x10/0x10 > [ 24.839585] ret_from_fork_asm+0x1a/0x30 > [ 24.839686] > ...... > ``` > > Fix this by adding a depth counter when it is about to go to another_round > label. When the counter exceeds XMIT_RECURSION_LIMIT (8), the packet is > dropped. This follows the same pattern as dev_xmit_recursion() which > protects the TX redirect path with the same limit. > > Reuse SKB_DROP_REASON_TC_RECLASSIFY_LOOP for observability. > > Fixes: 9aa1206e8f48 ("bpf: Add redirect_peer helper") > Cc: stable@vger.kernel.org > Reported-by: Yizhou Zhao > Reported-by: Yuxiang Yang > Reported-by: Xuewei Feng > Reported-by: Qi Li > Reported-by: Ke Xu > Assisted-by: GLM:GLM-5.1 > Signed-off-by: Yizhou Zhao > --- > Changes in v2: > - Move the check just after `another` is set to true to avoid affecting the fast path > - Reuse SKB_DROP_REASON_TC_RECLASSIFY_LOOP to avoid adding new drop reason > - Link to v1: https://lore.kernel.org/netdev/20260511063005.38134-1-zhaoyz24@mails.tsinghua.edu.cn/ > --- > net/core/dev.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/net/core/dev.c b/net/core/dev.c > index 831129f2a..bb9ae92f0 100644 > --- a/net/core/dev.c > +++ b/net/core/dev.c > @@ -5958,6 +5958,7 @@ static int __netif_receive_skb_core(struct sk_buff **pskb, bool pfmemalloc, > struct net_device *orig_dev; > bool deliver_exact = false; > int ret = NET_RX_DROP; > + int redirect_depth = 0; As reported by sashiko, the above will cause an unused variable warning, should be protected by #ifdef CONFIG_NET_INGRESS compiler guard. Also please respect the reverse christmas tree order above. /P