From patchwork Tue Jun 7 17:17:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12872181 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B603AC43334 for ; Tue, 7 Jun 2022 17:17:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345495AbiFGRRr (ORCPT ); Tue, 7 Jun 2022 13:17:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344707AbiFGRRo (ORCPT ); Tue, 7 Jun 2022 13:17:44 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CA8E4FC5E for ; Tue, 7 Jun 2022 10:17:43 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id w13-20020a17090a780d00b001e8961b355dso4251966pjk.5 for ; Tue, 07 Jun 2022 10:17:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8PPQ+e5B3bo3oZ0FlS4Jz6Ii1VVUtQoGFiulGS3lIN4=; b=PdnqY4K33C3bUAhljq+1Ewak3BgOSbtDq3wmbUBUIE9aYfW+bkHKna9jJrPSb/uawO XnvykqSNlKkcmp9ppjKq+O7Dh67oe0t9zfLFPcKKhlsBZ8DyozRQfZUIwCMEJqJ13bAL BoTadRf8UCUMnvBzFHKGSCALyGj0uZ1M1Ixq0+SMxBSq3lCON620SRwlcZ0JDkzUTAlG NHlkACCV54nGbTjXIjf81D0yQM1Vbx1AiZy5iPke44wTCgv32XXrBVxSVd4aX3H2iQvr rfND9CNFqoyDhATEXy1JJ3R8mWXcNHChRgTSl6mkIrmoO8TMM787O29KFc9hxMBuBHxR 87fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8PPQ+e5B3bo3oZ0FlS4Jz6Ii1VVUtQoGFiulGS3lIN4=; b=Yu1i+LjGBYYJpy4tBZLe9CZg4u8ShWxjdHoF5Wak3j1ArXppUMEABGxFagwK/l7sXJ YMLBmYTekU/WRdgrSKsvjz4KL1IpMdcDDUw70qk4PycgPgRn/wPdmdSll94A9eJluE17 Ymb+ETSM1V790GpFDy0LSq4pcG6UWx/BSBYdXl3zvPaZQt2dmfvXtJJLNiB4n2AXrQ4T Pe/T/aE7VSIM7XHM90zAo2vPRZG4JDiZgndY12RK/Hak2t9OwiOIQUbxrb8+xhfvRCf3 xmCC2zq6cB+kRVdhcY5hSDl7qhHPX7i5hm4q2FA2hqyPE/2yPweQgQhx+a3QFTum0Y73 gWCA== X-Gm-Message-State: AOAM533GdcrGkWywqijWLwiYcyKoPE9lH3qe3gPJKMD4qiHOOEAEspcL ZtQWRF2OZi3kfM1MmQKqCFM= X-Google-Smtp-Source: ABdhPJyjCv1ZRd4GhaEC30IDNdRUQoWW3sJMrA3iU52RWoReDKOWOM/a13hgNZ0yfpr6NWP3gw5NgA== X-Received: by 2002:a17:903:1103:b0:167:839e:7ba1 with SMTP id n3-20020a170903110300b00167839e7ba1mr9469146plh.136.1654622262648; Tue, 07 Jun 2022 10:17:42 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:191a:13a7:b80a:f36e]) by smtp.gmail.com with ESMTPSA id d4-20020a621d04000000b0051b930b7bbesm13001616pfd.135.2022.06.07.10.17.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 10:17:37 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev , Eric Dumazet , Eric Dumazet Subject: [PATCH net-next 1/8] net: use DEBUG_NET_WARN_ON_ONCE() in __release_sock() Date: Tue, 7 Jun 2022 10:17:25 -0700 Message-Id: <20220607171732.21191-2-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog In-Reply-To: <20220607171732.21191-1-eric.dumazet@gmail.com> References: <20220607171732.21191-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Eric Dumazet Check against skb dst in socket backlog has never triggered in past years. Keep the check only for CONFIG_DEBUG_NET=y builds. Signed-off-by: Eric Dumazet --- net/core/sock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/sock.c b/net/core/sock.c index 2ff40dd0a7a652029cca1743109286b50c2a17f3..f5062d9e122275a511efbc4d30de2ee501182498 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -2844,7 +2844,7 @@ void __release_sock(struct sock *sk) do { next = skb->next; prefetch(next); - WARN_ON_ONCE(skb_dst_is_noref(skb)); + DEBUG_NET_WARN_ON_ONCE(skb_dst_is_noref(skb)); skb_mark_not_on_list(skb); sk_backlog_rcv(sk, skb); From patchwork Tue Jun 7 17:17:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12872182 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01792C433EF for ; Tue, 7 Jun 2022 17:17:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345250AbiFGRRs (ORCPT ); Tue, 7 Jun 2022 13:17:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235464AbiFGRRq (ORCPT ); Tue, 7 Jun 2022 13:17:46 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9617F4E3BF for ; Tue, 7 Jun 2022 10:17:44 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id a10so16188173pju.3 for ; Tue, 07 Jun 2022 10:17:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZCkITjwU6+t7qKCD0kNZF73oF6jkTD3D32IscKNuK8s=; b=hE8e4eg3Ul9USMOJgPwPZlw7AHAFJaOJr5m/SvRPFvFN/h3u8ELhDkybuWOXa/2hws K5jiY7zTJ6s8nqeGbCsZkzTFZFV2SS10kfqmb03nSgka1VFw9Xk/7V1xNiOk0dOUH72d 3skuHiF8ER+gijxRBu7xIb2FBvQMPyHQripPYcGAplLzyoXFfFDIVgwCOJ0T669hGrJV EnOGQtmVmXol2MfzzIk7M/hsUnWDl4ddF0ZR4+zl+M5IlvVvkeMX3ZCgE/2oFn2u8sBs 3MGmHRHwn7CXLh7Rny32/wV9pHlofAhUXuVEqhh/nwPdab2M/Ge78cxAQ/lBgFBejs7p LGHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZCkITjwU6+t7qKCD0kNZF73oF6jkTD3D32IscKNuK8s=; b=SAoVN6T5eTZVpZGWSrarTM7HO7Bv+RZnCR0Iov6fonmhwffXiBUcy+Np0ZkCkLDPcf wHPFdTjzOkShl0M+zO/mTKsro8NYRMi3gda7FTIZCqGgew9FBc9eSWf0xMbF+wzahtZ8 DOuQOfxNBwCC77A3CH0Cfxn6rshljW9vHBhAw1+fYlzYR4Lr/SLHQ6rUNqxLf/63NRLs 8EHpMAjZm6cr5JnzXDg4TWxhsLDIygR1YrTNswoOSDMmPfALjZ6Ga5FBoZmCU21DNo1t /zdNMEWzk404cwalAGsgcgtpayvMOarKe8GjYTB3a5Mbi+7MaLLfYgzI7oj0JhXpg8tf afDQ== X-Gm-Message-State: AOAM5305oECiPiDce3G0F450+rhT7Xo8Eo94bBaMcU2a+XGDEiqF9zFU 2lhby4rPJyjoLsOzJE+i5xA= X-Google-Smtp-Source: ABdhPJxfnLVC+u3HWvkv2AjVeqiY+vV3LvaP9l99oF7xNikzWhG7/SvUegmNeshUOPA6tkjPS9Gz4Q== X-Received: by 2002:a17:902:d5ce:b0:167:6c02:754c with SMTP id g14-20020a170902d5ce00b001676c02754cmr15621237plh.135.1654622264134; Tue, 07 Jun 2022 10:17:44 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:191a:13a7:b80a:f36e]) by smtp.gmail.com with ESMTPSA id d4-20020a621d04000000b0051b930b7bbesm13001616pfd.135.2022.06.07.10.17.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 10:17:43 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev , Eric Dumazet , Eric Dumazet Subject: [PATCH net-next 2/8] net: use DEBUG_NET_WARN_ON_ONCE() in dev_loopback_xmit() Date: Tue, 7 Jun 2022 10:17:26 -0700 Message-Id: <20220607171732.21191-3-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog In-Reply-To: <20220607171732.21191-1-eric.dumazet@gmail.com> References: <20220607171732.21191-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Eric Dumazet One check in dev_loopback_xmit() has not caught issues in the past. Keep it for CONFIG_DEBUG_NET=y builds only. Signed-off-by: Eric Dumazet --- net/core/dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/dev.c b/net/core/dev.c index 08ce317fcec89609f6f8e9335b3d9f57e813024d..27ad09ad80a4550097ce4d113719a558b5e2a811 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3925,7 +3925,7 @@ int dev_loopback_xmit(struct net *net, struct sock *sk, struct sk_buff *skb) skb->pkt_type = PACKET_LOOPBACK; if (skb->ip_summed == CHECKSUM_NONE) skb->ip_summed = CHECKSUM_UNNECESSARY; - WARN_ON(!skb_dst(skb)); + DEBUG_NET_WARN_ON_ONCE(!skb_dst(skb)); skb_dst_force(skb); netif_rx(skb); return 0; From patchwork Tue Jun 7 17:17:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12872183 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DE5DC433EF for ; Tue, 7 Jun 2022 17:17:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344627AbiFGRRt (ORCPT ); Tue, 7 Jun 2022 13:17:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345494AbiFGRRr (ORCPT ); Tue, 7 Jun 2022 13:17:47 -0400 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 558F44E3BF for ; Tue, 7 Jun 2022 10:17:46 -0700 (PDT) Received: by mail-pj1-x102a.google.com with SMTP id cx11so16206211pjb.1 for ; Tue, 07 Jun 2022 10:17:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LCo1XE9x3JPvz7KT7k6B+icHFHtfZ+pjZYOXW3MVAf8=; b=jk/f/OqBxwMmQVJZEfocRrRJuvFRSBp13RmLR6vGeun6q+ne4NGJSicVebtSdNs8xF xzjmMpbAkeA9rFKc5wwOlaMWOKSmwO2YtHpH0zv5EFwZuQ2aut1Ne33GwxIi811frCq+ BvMi5RJ/8/7EIYiHEGUka4cQhHJXZUHo1rHdJtZeD6I3qk6czvEE0EgkV9sO31Jwl3bT jBR8fsMlfIZ6BKKYEE2b+9iWAuxsjovwSdCyXwa7KIT+5FfYRTIgtkkqZN2utMotzvvG 2U5ZZyQ1rJXUJiINpwc6dwWqIrydxrOwULP4zRk+wx4b2LuFoxi7955R28euFFhbiCUh drIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LCo1XE9x3JPvz7KT7k6B+icHFHtfZ+pjZYOXW3MVAf8=; b=x6+StwClqBg6Zexwh5GDsZs/BTTGuoBvkZxNxHlhWNMQnqCNJdnzfUhZbQjFEBzVkj NMeT2DD1d3D74zHpUe4f7nXiVVhdtRfyHmCJwTbXpjFBpiHjca8ciRnCKDff3jiTIlSm M+/spLRx90cYFCJo+TdOrtUDkwS35Y9xVbWhy/tDYE7E4XEDv81xVyNOrlRhIsQUlHr3 JIGrMvqk1vI6LyzpgFzqpR1qofEEknYUXMQCDHlu+C+RV/sLD3LFD5ODhYrqw/zaIXUH AK/McwBsmpOq/QZN4MHNgaBpSjClV8F9Xj0U3LGjjGxh1rlYMCIiB7q6meXA5Rr4aAHB cunw== X-Gm-Message-State: AOAM533bDLmtfPoA6ZJafW0aOljZBRwRpdpoCA2ll8zteGJ4tRM6qGVI mgY84VATZYKsh/oA8c9nPB8= X-Google-Smtp-Source: ABdhPJxkxMSzg1anFMSp4YvrjgxHZX/H9qpbdNXMhWjAdCVZJXz7eBKzwRn0iD8UnQbP6y2zXxId+w== X-Received: by 2002:a17:902:e78f:b0:163:7572:f83f with SMTP id cp15-20020a170902e78f00b001637572f83fmr30725239plb.60.1654622265876; Tue, 07 Jun 2022 10:17:45 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:191a:13a7:b80a:f36e]) by smtp.gmail.com with ESMTPSA id d4-20020a621d04000000b0051b930b7bbesm13001616pfd.135.2022.06.07.10.17.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 10:17:45 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev , Eric Dumazet , Eric Dumazet Subject: [PATCH net-next 3/8] net: use DEBUG_NET_WARN_ON_ONCE() in inet_sock_destruct() Date: Tue, 7 Jun 2022 10:17:27 -0700 Message-Id: <20220607171732.21191-4-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog In-Reply-To: <20220607171732.21191-1-eric.dumazet@gmail.com> References: <20220607171732.21191-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Eric Dumazet inet_sock_destruct() has four warnings which have been useful to point to kernel bugs in the past. However they are potentially a problem because they could flood the syslog, and really only a developper can make sense of them. Keep the checks for CONFIG_DEBUG_NET=y builds, and issue them once only. Signed-off-by: Eric Dumazet --- net/ipv4/af_inet.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 93da9f783bec52e4bda6213dc78ef3820e180cc4..5ec85ffe1e13afb333e40819b2a5e60b003d44a7 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -148,10 +148,10 @@ void inet_sock_destruct(struct sock *sk) return; } - WARN_ON(atomic_read(&sk->sk_rmem_alloc)); - WARN_ON(refcount_read(&sk->sk_wmem_alloc)); - WARN_ON(sk->sk_wmem_queued); - WARN_ON(sk_forward_alloc_get(sk)); + DEBUG_NET_WARN_ON_ONCE(atomic_read(&sk->sk_rmem_alloc)); + DEBUG_NET_WARN_ON_ONCE(refcount_read(&sk->sk_wmem_alloc)); + DEBUG_NET_WARN_ON_ONCE(sk->sk_wmem_queued); + DEBUG_NET_WARN_ON_ONCE(sk_forward_alloc_get(sk)); kfree(rcu_dereference_protected(inet->inet_opt, 1)); dst_release(rcu_dereference_protected(sk->sk_dst_cache, 1)); From patchwork Tue Jun 7 17:17:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12872188 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BFD5AC43334 for ; Tue, 7 Jun 2022 17:18:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345509AbiFGRSF (ORCPT ); Tue, 7 Jun 2022 13:18:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345500AbiFGRR7 (ORCPT ); Tue, 7 Jun 2022 13:17:59 -0400 Received: from mail-oa1-x31.google.com (mail-oa1-x31.google.com [IPv6:2001:4860:4864:20::31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 537BF51E6F for ; Tue, 7 Jun 2022 10:17:59 -0700 (PDT) Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-fe023ab520so756365fac.10 for ; Tue, 07 Jun 2022 10:17:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YdqU5p5P1KJbnolEPhwdA3nRakckKoJfnz6ajx5T568=; b=GSsypi/ofmOkV3K/qYbPnrha9KLvWG8RtyhAo7YXXJd2RGQjbCK0YR6L76KXlOoPZ4 3C+Zaz2F6P2cinFtAP3H4Y3FlNYbNzN3FAIXKg97HijbXBFfYYdOKklrwSqpUz6qt5QF qtZvhzSaryI6groa8Co8iJTm7zrZh80ru/JKhXtb372NEyupcoaf3djmOhwUfbhrOHBm UiGG0XkanO+0CSxGe94nftta4Q9ZHH3R9IIxjKAIA3HmxWMwIZ7pgpY/0xedSDOUO2br KSR1QEEo4UdVPh5yXHOQ5Jk3X1SArLKg/wluQ4T3Qdv5ObI96S+aIe38gjqGAMj82UnM ObQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YdqU5p5P1KJbnolEPhwdA3nRakckKoJfnz6ajx5T568=; b=RK/qtunK6XXiZ1p338kXgqk48sp+X+FrvgHlbUItpxklLzevBe8d6LSaENoCoPeeGs /hgD3h/GV3H1H6sZF0bfushZVoPvmOETDqGY5jloga32/0wJrSdZY917wZ1pCRB00NgR 6HJrTH8pRgmw+d/TY/+61cXuqXTVXpfEl9nQmC0Aviap3V5IpwUAgYEl5X+YQhA4QXW/ XTlotVjGWV6b1vF/OzjGhpeOUGayYQR/0cB6OOO0eeB/bcmqY/iTraoXhNldXStEXpOw ENrIkwcv65o888PlCbHbrP7HXU4Gl2Ycy9AB2riCF6/D1np0eSrSUWkRSNLfVil+txxa F7Eg== X-Gm-Message-State: AOAM530FK9cGBlXSiODdJsMo3FjvXhmycQtlmfo88kmQUb6sJUS3jl5K 0FSuDOs8gTZDSV3gMnz37BenCbca8Tw= X-Google-Smtp-Source: ABdhPJw6VvXnARdnA2LMVfRQxFsvNcuSGsLGDRuVJkoM7cPJb2hRY1ZTVF8T5fKQOkK89lTfkgZYBA== X-Received: by 2002:a17:90b:3a90:b0:1e6:a203:c7dd with SMTP id om16-20020a17090b3a9000b001e6a203c7ddmr28321749pjb.144.1654622267456; Tue, 07 Jun 2022 10:17:47 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:191a:13a7:b80a:f36e]) by smtp.gmail.com with ESMTPSA id d4-20020a621d04000000b0051b930b7bbesm13001616pfd.135.2022.06.07.10.17.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 10:17:47 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev , Eric Dumazet , Eric Dumazet Subject: [PATCH net-next 4/8] net: use DEBUG_NET_WARN_ON_ONCE() in sk_stream_kill_queues() Date: Tue, 7 Jun 2022 10:17:28 -0700 Message-Id: <20220607171732.21191-5-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog In-Reply-To: <20220607171732.21191-1-eric.dumazet@gmail.com> References: <20220607171732.21191-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Eric Dumazet sk_stream_kill_queues() has three checks which have been useful to detect kernel bugs in the past. However they are potentially a problem because they could flood the syslog, and really only a developper can make sense of them. Keep the checks for CONFIG_DEBUG_NET=y builds, and issue them once only. Signed-off-by: Eric Dumazet --- net/core/stream.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/core/stream.c b/net/core/stream.c index 06b36c730ce8a29bb2d8984495e780931907ca72..a5aa3620be95574c6d0f371f5943bb3b8f36cb4c 100644 --- a/net/core/stream.c +++ b/net/core/stream.c @@ -196,13 +196,13 @@ void sk_stream_kill_queues(struct sock *sk) __skb_queue_purge(&sk->sk_receive_queue); /* Next, the write queue. */ - WARN_ON(!skb_queue_empty(&sk->sk_write_queue)); + DEBUG_NET_WARN_ON_ONCE(!skb_queue_empty(&sk->sk_write_queue)); /* Account for returned memory. */ sk_mem_reclaim_final(sk); - WARN_ON(sk->sk_wmem_queued); - WARN_ON(sk->sk_forward_alloc); + DEBUG_NET_WARN_ON_ONCE(sk->sk_wmem_queued); + DEBUG_NET_WARN_ON_ONCE(sk->sk_forward_alloc); /* It is _impossible_ for the backlog to contain anything * when we get here. All user references to this socket From patchwork Tue Jun 7 17:17:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12872184 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7DC94C43334 for ; Tue, 7 Jun 2022 17:18:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345494AbiFGRR7 (ORCPT ); Tue, 7 Jun 2022 13:17:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345496AbiFGRRw (ORCPT ); Tue, 7 Jun 2022 13:17:52 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D274A6F4BB for ; Tue, 7 Jun 2022 10:17:49 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id q18so15328291pln.12 for ; Tue, 07 Jun 2022 10:17:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=f6j9GBN0w5grHc+ifaZiPx7VIaBCMhY99fjc3Bz/5zI=; b=G6P0Xr0cF1NBYFa+klXp4PxxpBCPgLqM6JflQUvijurfXAZLwqsLfK0dBnayS19rfJ TZz6S3/GlHgZ6/toE1A2xOrdElV9Pzlulwau21bKa7dGkHuajaSr3W/hBdvRfIWfDS3K 0axMkFipWmrg1ADwh6bm1Jv2bJfV11ZChL/r4+vxCR2rNmZMkpAkAHL1937Djzjz4la7 509L7QGSjfmMEZAjWFr+lhIKTbbiOSMWww7K5lm98iSKLjSj2THcq1doGDh/vV01Idc4 +0LiLcX1oaF2V8vDCrUPm3XuJrXI9bmxPlYdJ9iRLb1jWEKROGfMB8G/tnUvWMpIEHuy GEOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=f6j9GBN0w5grHc+ifaZiPx7VIaBCMhY99fjc3Bz/5zI=; b=gGAG9dMpnASxODBQJ57P2wGcq1+hQopXTZTc9IH8PhFKuDeE1rM51qTq27vgvNTOwY EHXk6Cd9dqjMmmvttvDh27QlNp/aLMwd7OcVJwKsaoKvn1IetgyRW8u1MP7ilAmIPlWu Oxq9CVGy4MDCYRj4f3aFqunCjiGyNvvQMMQvmjv+dtUByvrJllEegojFibEYs+uI8KPt xINgNdoDOHBiytF3ntQPnrL9MXuSRPjLFJ9ErAXox4DwTH2rn8COTLFMM/IjF6wAfASt ZpAtrE2Ezkm7VXFTjn1mWbHxWs5Zq0P/1a2FFE4ylLB2Sj+iKgMZ2fHhR4/j7QR32EcT mspg== X-Gm-Message-State: AOAM532ITXWlJng7LJRZRiwjKch66Tm40rXK3kT6BMaqzrb0fFmFa9fo A6mG514oqfqj5VHuN6E3KcCWJ8uqeDA= X-Google-Smtp-Source: ABdhPJzLBHtpNQ1mGkbMQYMBWoZdj4RFgPr4nFiEvamkCEerwD6Lu34QI1eFLJ/50EfnwNaHB4DmYg== X-Received: by 2002:a17:90a:d58d:b0:1e0:adde:a7f8 with SMTP id v13-20020a17090ad58d00b001e0addea7f8mr68312495pju.74.1654622269301; Tue, 07 Jun 2022 10:17:49 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:191a:13a7:b80a:f36e]) by smtp.gmail.com with ESMTPSA id d4-20020a621d04000000b0051b930b7bbesm13001616pfd.135.2022.06.07.10.17.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 10:17:48 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev , Eric Dumazet , Eric Dumazet Subject: [PATCH net-next 5/8] af_unix: use DEBUG_NET_WARN_ON_ONCE() Date: Tue, 7 Jun 2022 10:17:29 -0700 Message-Id: <20220607171732.21191-6-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog In-Reply-To: <20220607171732.21191-1-eric.dumazet@gmail.com> References: <20220607171732.21191-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Eric Dumazet Replace four WARN_ON() that have not triggered recently with DEBUG_NET_WARN_ON_ONCE(). Signed-off-by: Eric Dumazet --- net/unix/af_unix.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 654dcef7cfb3849463be9d905ae625319fbae406..ae254195aac87f196a93853443048b40e332cc60 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -302,7 +302,7 @@ static void __unix_remove_socket(struct sock *sk) static void __unix_insert_socket(struct sock *sk) { - WARN_ON(!sk_unhashed(sk)); + DEBUG_NET_WARN_ON_ONCE(!sk_unhashed(sk)); sk_add_node(sk, &unix_socket_table[sk->sk_hash]); } @@ -554,9 +554,9 @@ static void unix_sock_destructor(struct sock *sk) u->oob_skb = NULL; } #endif - WARN_ON(refcount_read(&sk->sk_wmem_alloc)); - WARN_ON(!sk_unhashed(sk)); - WARN_ON(sk->sk_socket); + DEBUG_NET_WARN_ON_ONCE(refcount_read(&sk->sk_wmem_alloc)); + DEBUG_NET_WARN_ON_ONCE(!sk_unhashed(sk)); + DEBUG_NET_WARN_ON_ONCE(sk->sk_socket); if (!sock_flag(sk, SOCK_DEAD)) { pr_info("Attempt to release alive unix socket: %p\n", sk); return; From patchwork Tue Jun 7 17:17:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12872185 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0393CCA47C for ; Tue, 7 Jun 2022 17:18:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345501AbiFGRSB (ORCPT ); Tue, 7 Jun 2022 13:18:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345498AbiFGRRx (ORCPT ); Tue, 7 Jun 2022 13:17:53 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99F8571D95 for ; Tue, 7 Jun 2022 10:17:51 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id n18so15362290plg.5 for ; Tue, 07 Jun 2022 10:17:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Erpi5T5vsmcmL5HzySima+v0cDynsgqf2csS6PQALjs=; b=T1hty5uA8ZBjyQJ6ic8Ku3+Upd4Ys1KwcnKDkE22qrsAZOBcaFJb9L1JhYwPSV81oZ pbvH+ZW67oiG0MBzyy7OPL8mmYTKanfuGqAme76HvRYNtkg6JXhFuXG1nb8cL00R0kge hErd1G1QPrnHVmu/G+0wcLY6mGLJFGoZgmo2Wy6QdBnOteLMjQyh7iNLFmA59wJROzbI oQ/xAsGWQWmN4sJ3EM0B7uA+aI0zuSgCUm6Gwg5xeOb/fQnYejlqplBRak/aLVFbD+nJ o1yXTL7tcc+6Qj8GRkiwyiLWfSKrZ/UJ7ZRS0KVr0Wcfnmrt723E0MGrUNHm6lrFFcUj s4bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Erpi5T5vsmcmL5HzySima+v0cDynsgqf2csS6PQALjs=; b=6YyPs1kbXWwt51SWfwaT4nFoco1l90Fc+fTo4iyYQRbO73UsmMJ7Sw4hs5UfyLpKkN TBlEFNlWlBOG7qcWXYfd6YI+aYfivvTmzKdtEVi8GN7pLWNA3A8+yqwa/asaRWta42Uk 6WhESScwuuma5LKIW4r4Cp93rxuW1Vzf3CtEs+5MHkR15ZZcy2kJ1Cg5xYnDLs0UaYpm iDt0kZsu084K8ejOgGa0yBa6AfIa1v4U2JpOWEZf+U9g13qW+4YM+k1CQCs94mqsp/T2 DbVF7KcN+MUXOio/+pqkEpJ4+LoaPgMndoQ7vX4D1G4s5TAxmbcm2oe8+ESpvt1ROK6W j0FA== X-Gm-Message-State: AOAM530JQ15qFyBCdsxz31ZQ04tfMoWz6JufOqyEZn/PStMEpWFjzH1w rVTWx+t2kmInTw8mBDG2Psf8Y+EI9nY= X-Google-Smtp-Source: ABdhPJzRK+Fuo4oTO1XWnSJ1cFy++YQZk8RbROTatF44l73AsMXweoEkvZPNwVojgd8sULEZ41GSvg== X-Received: by 2002:a17:90b:180b:b0:1e3:2871:6be3 with SMTP id lw11-20020a17090b180b00b001e328716be3mr32700414pjb.85.1654622271036; Tue, 07 Jun 2022 10:17:51 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:191a:13a7:b80a:f36e]) by smtp.gmail.com with ESMTPSA id d4-20020a621d04000000b0051b930b7bbesm13001616pfd.135.2022.06.07.10.17.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 10:17:50 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev , Eric Dumazet , Eric Dumazet Subject: [PATCH net-next 6/8] net: use DEBUG_NET_WARN_ON_ONCE() in skb_release_head_state() Date: Tue, 7 Jun 2022 10:17:30 -0700 Message-Id: <20220607171732.21191-7-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog In-Reply-To: <20220607171732.21191-1-eric.dumazet@gmail.com> References: <20220607171732.21191-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Eric Dumazet Remove this check from fast path unless CONFIG_DEBUG_NET=y Signed-off-by: Eric Dumazet --- net/core/skbuff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index b661040c100efbb59aea58ed31247f820292bd64..cf83d9b8f41dc28ae11391f2651e5abee3dcde8f 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -728,7 +728,7 @@ void skb_release_head_state(struct sk_buff *skb) { skb_dst_drop(skb); if (skb->destructor) { - WARN_ON(in_hardirq()); + DEBUG_NET_WARN_ON_ONCE(in_hardirq()); skb->destructor(skb); } #if IS_ENABLED(CONFIG_NF_CONNTRACK) From patchwork Tue Jun 7 17:17:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12872186 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79AE2C43334 for ; Tue, 7 Jun 2022 17:18:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345506AbiFGRSC (ORCPT ); Tue, 7 Jun 2022 13:18:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345503AbiFGRR6 (ORCPT ); Tue, 7 Jun 2022 13:17:58 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B082077F02 for ; Tue, 7 Jun 2022 10:17:54 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id e11so16073517pfj.5 for ; Tue, 07 Jun 2022 10:17:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=z0Lo7KdcQV5V1+hy9GBEXahSN5MlosYjYm/RYugMrYw=; b=AtO3vumNPd4lBLaz8y0mGRuQhOsZwkUZEx6Oj/7d6Hmf4ylQuBnL9dBgmiloaYDZKA lIoyLy173ln0AfIHY/UtarmMXKYtY/Wc+JFW0+iJUor5wDYGw/R8DBUao3kwuj4sNHUg 8pRcjWYPN/m2xUKpVOS845jPJSJpynC2tRbRVSwzfnKkDSxo9oYADyMCmOSbru5/fhiH yP9mnM1QPqAT2M+uQ6Y9lUMU1SBy2RSsEaZ6ddps1VGyyVjILT33uQ/QQEGAR+XoA3H2 AWMV/i3fwmJox2HV0EFNDyScCpdfcFkxm6zsGxD/3RouBya0VX4M8cKO91M5WU1bec8y iUCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=z0Lo7KdcQV5V1+hy9GBEXahSN5MlosYjYm/RYugMrYw=; b=HgkNbaSgj9QlWgHrlxI4NbEVm7bVVSwAJ1JmeBa61SkSgS0GmGg4m9GEdLJ8gP6Dvi Qr2lV9YGB+NQLauwGfCV0CD/WCopJtnTXHXx0ePrE4v3ODIE0xH20IXQPILVNNovTAKl 0EpHqnnDdgBBwO/v+/S9ROTZRSU4X9s1UDpNf8xhZ+pfq58tMlX0EwHYDw2A81cdfjGC m+y3h3J5FeE8oDdV4+X7Oydfo4QdqBgh3wwve5OMDxD2Iq2E3UCagJMRmPvqCbU6llKQ 00gN4zjw6e8bvnRSAPKHZ6M92pJatxnigjnBwCIkrNDRhRx6PPlCtreRII28S2rUEc6/ M65g== X-Gm-Message-State: AOAM530VC9vAlQ0x1x0ayyhCoNUXwaulCk6jOnJO1BF1QZsTBm9V8+a6 HArTmIlCjgub/S6NcK36BGR2e127ScY= X-Google-Smtp-Source: ABdhPJxkQk8/rY7wZmFH7Q50mXwOUhh5kkyXRGtcZBOn1th9Nz1oP7lM8VVnLqenuzvQQ5jr7BEl4Q== X-Received: by 2002:a65:618e:0:b0:3fb:177f:d365 with SMTP id c14-20020a65618e000000b003fb177fd365mr26229532pgv.265.1654622274252; Tue, 07 Jun 2022 10:17:54 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:191a:13a7:b80a:f36e]) by smtp.gmail.com with ESMTPSA id d4-20020a621d04000000b0051b930b7bbesm13001616pfd.135.2022.06.07.10.17.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 10:17:52 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev , Eric Dumazet , Eric Dumazet Subject: [PATCH net-next 7/8] net: add debug checks in napi_consume_skb and __napi_alloc_skb() Date: Tue, 7 Jun 2022 10:17:31 -0700 Message-Id: <20220607171732.21191-8-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog In-Reply-To: <20220607171732.21191-1-eric.dumazet@gmail.com> References: <20220607171732.21191-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Eric Dumazet Commit 6454eca81eae ("net: Use lockdep_assert_in_softirq() in napi_consume_skb()") added a check in napi_consume_skb() which is a bit weak. napi_consume_skb() and __napi_alloc_skb() should only be used from BH context, not from hard irq or nmi context, otherwise we could have races. Signed-off-by: Eric Dumazet --- net/core/skbuff.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index cf83d9b8f41dc28ae11391f2651e5abee3dcde8f..fec75f8bf1f416f05c14f76009a15412b2559b6e 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -560,6 +560,7 @@ struct sk_buff *__napi_alloc_skb(struct napi_struct *napi, unsigned int len, struct sk_buff *skb; void *data; + DEBUG_NET_WARN_ON_ONCE(!in_softirq()); len += NET_SKB_PAD + NET_IP_ALIGN; /* If requested length is either too small or too big, @@ -981,7 +982,7 @@ void napi_consume_skb(struct sk_buff *skb, int budget) return; } - lockdep_assert_in_softirq(); + DEBUG_NET_WARN_ON_ONCE(!in_softirq()); if (!skb_unref(skb)) return; From patchwork Tue Jun 7 17:17:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12872187 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E0B5CCA47E for ; Tue, 7 Jun 2022 17:18:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345507AbiFGRSD (ORCPT ); Tue, 7 Jun 2022 13:18:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345504AbiFGRR7 (ORCPT ); Tue, 7 Jun 2022 13:17:59 -0400 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C5DE74DC5 for ; Tue, 7 Jun 2022 10:17:56 -0700 (PDT) Received: by mail-pf1-x434.google.com with SMTP id 187so16068639pfu.9 for ; Tue, 07 Jun 2022 10:17:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=57cyzJoBPE7FvApVXx2h64j/hlX4+tffn7QLQfhu8gE=; b=kJGzch64mvLQOnlCNITM6GUuQRrL0SxXbvTx+fLHOdB3rEDv1Mrn082kRx3FOvDFg+ gUbaVQCLRVkXQVQbi5hRqxMIkflL8itvSyFD2hosUiEBwdQsbTd/4b4d4lYLAwMSjVOV PHpAOhE63SXeVGtLJjZGAUOG0T0hyCcvNNalM5kaS3ZBncURDi942uW8gAITKNf+xRX2 B3HkFu8G3hrvaunW7Gw9gDDvfxGDvzYJcVfyezFkWM1wAk57Q67BY+KXBAcQdI3qerWG 3J0i/AQvlqrW4tGLi8U0NeAbosd5C6RYJZWI8FZ4Pz4axjxX+jIkhhkEpqUXPZHTVKj9 0asw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=57cyzJoBPE7FvApVXx2h64j/hlX4+tffn7QLQfhu8gE=; b=VrNxmug84MtbnJ/1aPEns+6L2Np60ENgzFGqXz7siiOkywDamCm0tVs/DrP4al/BL2 Lz1Gnv+TihvGg8t9sgc2ILXm/lNu2uVuC4SRwo3yRsk7wlivB+uoQXiPTnzOInZPVFR9 JekdZL8HwaIy30B5EbSvebjivVdnkSMsoLSe+wK8PVFtH6tfW80tmOCNj0QHbe604zRZ 7EUgnPcRr936Al27sQz/y5EpyuUI0VUrfkldITc8az5za7qwfg4RpGO5w/0XEPQaF+nH PW7Uh2iFRn/68NnJiXkJZk20XpmtPaGSD7R7dBNm2eYhSLsw8RDzcltr+eE9/LWOBQJp kxYg== X-Gm-Message-State: AOAM530yEAqwuhOAZl7N2bCIpYqZRDJ4hkQFalOx/NNTxL1K8IvxBiVI GyWe9fifiXhYR4HoLzgIl4ogK7KYkzE= X-Google-Smtp-Source: ABdhPJxzIZfN5DeDanoJurkdVMap8nE6NfDYu0RbLDJiBOIY2WB8ulxkeVBbNSIkzsZacxUnpLaexw== X-Received: by 2002:a63:5711:0:b0:3fd:b97e:3c0c with SMTP id l17-20020a635711000000b003fdb97e3c0cmr10241989pgb.570.1654622276063; Tue, 07 Jun 2022 10:17:56 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:191a:13a7:b80a:f36e]) by smtp.gmail.com with ESMTPSA id d4-20020a621d04000000b0051b930b7bbesm13001616pfd.135.2022.06.07.10.17.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 10:17:55 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev , Eric Dumazet , Eric Dumazet Subject: [PATCH net-next 8/8] net: add napi_get_frags_check() helper Date: Tue, 7 Jun 2022 10:17:32 -0700 Message-Id: <20220607171732.21191-9-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog In-Reply-To: <20220607171732.21191-1-eric.dumazet@gmail.com> References: <20220607171732.21191-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Eric Dumazet This is a follow up of commit 3226b158e67c ("net: avoid 32 x truesize under-estimation for tiny skbs") When/if we increase MAX_SKB_FRAGS, we better make sure the old bug will not come back. Adding a check in napi_get_frags() would be costly, even if using DEBUG_NET_WARN_ON_ONCE(). Signed-off-by: Eric Dumazet --- net/core/dev.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/net/core/dev.c b/net/core/dev.c index 27ad09ad80a4550097ce4d113719a558b5e2a811..4ce9b2563a116066d85bae7a862e38fb160ef0e2 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -6351,6 +6351,23 @@ int dev_set_threaded(struct net_device *dev, bool threaded) } EXPORT_SYMBOL(dev_set_threaded); +/* Double check that napi_get_frags() allocates skbs with + * skb->head being backed by slab, not a page fragment. + * This is to make sure bug fixed in 3226b158e67c + * ("net: avoid 32 x truesize under-estimation for tiny skbs") + * does not accidentally come back. + */ +static void napi_get_frags_check(struct napi_struct *napi) +{ + struct sk_buff *skb; + + local_bh_disable(); + skb = napi_get_frags(napi); + WARN_ON_ONCE(skb && skb->head_frag); + napi_free_frags(napi); + local_bh_enable(); +} + void netif_napi_add_weight(struct net_device *dev, struct napi_struct *napi, int (*poll)(struct napi_struct *, int), int weight) { @@ -6378,6 +6395,7 @@ void netif_napi_add_weight(struct net_device *dev, struct napi_struct *napi, set_bit(NAPI_STATE_NPSVC, &napi->state); list_add_rcu(&napi->dev_list, &dev->napi_list); napi_hash_add(napi); + napi_get_frags_check(napi); /* Create kthread for this napi if dev->threaded is set. * Clear dev->threaded if kthread creation failed so that * threaded mode will not be enabled in napi_enable().