From patchwork Wed Jun 8 16:04: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: 12874208 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 47E65C43334 for ; Wed, 8 Jun 2022 16:04:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245082AbiFHQEx (ORCPT ); Wed, 8 Jun 2022 12:04:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245075AbiFHQEu (ORCPT ); Wed, 8 Jun 2022 12:04:50 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 875FB27CCF4 for ; Wed, 8 Jun 2022 09:04:43 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id h1so18001506plf.11 for ; Wed, 08 Jun 2022 09:04: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=WhhA7d4SgDuLNJh5qxna0pplxrOZt4lEvQ8XEOxrYyM=; b=aTuuNO+SiJwBAaLU/ddUjM2dJuFvdLiQzGxiS1XhO6jYuSZcheTTTfe6XiWsO0d8QI ChXOv+ERhgu914Bw2MXDp4dnjzg+VRjhy8Y36a0Dsp6/BohPFNST/fFSJqvQBI0/hd6s pOfZoAyQFpwNGUYS6vyDiIWoBgJh1PDZ/OBbE4ibmrKtNcs2/rHIfrasdYt7P9R8dk+Z 7t12kcPeyKTOxJYcRNuvhWcjbqviTKjgKzG0ylpsmuwewoA40iC+dG/wpMwfKLtLfsj6 etksOlzi4wbgtzFEoNly4C+Ykg5NrgTLJK7jHu3gnw/YmhtUYbYeM/zRIZ1Qd/P3xS7m O2iA== 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=WhhA7d4SgDuLNJh5qxna0pplxrOZt4lEvQ8XEOxrYyM=; b=vhJw2HRw8LWdBB9iY9yJfozaiXYGhJHtRPjEEjThkADNVm40KpyHfAUVWBheSdK/YC vfjIYr/h7yvXhUzaAEfWq8weZZGu2C0TRGT8rqLR5/c1cyPXtyVPwXFXtfLuGlnUIzh5 FD/FWuoQgX54XwjVX+af806fJZG1JMmABBEHZsjGBGGWoI8TIc0ZEAVKVSGDohxunCB9 2yp8mDttSiWI+8jmYBa70TANwKmJcEfSZHfOhc7MY+CmIILymXXDvYbtKqnBpPICalCM i3AEinUjTTExq7xm2Onbs9WyOOzpZ+UVEdz3fn6VHCpgen9ImthNK0DCLLWRZN8DYSv2 cUdQ== X-Gm-Message-State: AOAM532D5iYvF/qv+1lE+b0cEZItxGGM2OjaYVabo2ZJpaeZ04+htXva k97sup3y62egZZ3mrT3YgLE= X-Google-Smtp-Source: ABdhPJzOxN9uQ0p2+RTKKWowm2yW8hh6MVqkWkpgk8SL+VQ8AHCVOYSJxN6qSTcHlo8ranSyyQPGbQ== X-Received: by 2002:a17:90b:180e:b0:1e8:3023:eeb9 with SMTP id lw14-20020a17090b180e00b001e83023eeb9mr30821439pjb.55.1654704282609; Wed, 08 Jun 2022 09:04:42 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:f579:a14f:f943:9d9a]) by smtp.gmail.com with ESMTPSA id ju10-20020a17090b20ca00b001df264610c4sm18622019pjb.0.2022.06.08.09.04.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 09:04:42 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev , Eric Dumazet , Eric Dumazet Subject: [PATCH v2 net-next 1/8] net: use DEBUG_NET_WARN_ON_ONCE() in __release_sock() Date: Wed, 8 Jun 2022 09:04:31 -0700 Message-Id: <20220608160438.1342569-2-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog In-Reply-To: <20220608160438.1342569-1-eric.dumazet@gmail.com> References: <20220608160438.1342569-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 omly 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 Wed Jun 8 16:04: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: 12874210 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 E0CD0C433EF for ; Wed, 8 Jun 2022 16:05:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245097AbiFHQE7 (ORCPT ); Wed, 8 Jun 2022 12:04:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245077AbiFHQEu (ORCPT ); Wed, 8 Jun 2022 12:04:50 -0400 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87A4727CD47 for ; Wed, 8 Jun 2022 09:04:44 -0700 (PDT) Received: by mail-pg1-x52a.google.com with SMTP id e66so19285080pgc.8 for ; Wed, 08 Jun 2022 09:04: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=PICl5jzHxj29QCkg1nTQLSxnyB2qIPaUZxTd+gFaC1UULxznmKCuhJT9IY60q6k3VQ ON+EaKLYQqurOuuXf2yHKTKrqzwfwMg5ky9X1V0BVkrPyzcXZTaI+uXrFw8Z/WLnEYqb uAqT1fTh8stJa2AC+N7hRqZ697jLGvM/ntlLPTIx1zF1SxTNc2eSa507L3FsWcIvIDHo ezqS9YoViTFju2+3cGEgayuBt5adnT/kgxRMr2dw8SXz5h8LO7i4gUWZq5kbQqsSm+hS WjghCMi+aaryJuZjtZDzOJ44Fvmo/yf0zYPJCqsaRGyAsvYohHXB4aliygA2urav90P0 pQeA== 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=vZlHTWBvO2BS9r6fVEVsXOSTZUZ1oI7A47M16Dm61AE/thIqHJj+H5dLFRG7PDEKrk 90G/AGzuormcrVXvSoMiKOei1bv+tJX/6toM4OFYPEsOIFu0KyxN5zQwqpHwkYbs6agC hEMXdkVLmu3uIiod9KTkpfj95rpRuPCpFIPYOBUDErIHhroDyuXY6wAtMZqcXNgfGKpO r7tFa8ayNWouuHi/bI/XCuMq3Zg7Razupm8efi4npbzkjJMgxzz82gn5qYmDXdNOyie+ MeLhEILqAvsZejzC71i+YXWex/GFPE8W4CMnItzyE0K6IS2x0FSh5eptut9LZvczsUdy XYbQ== X-Gm-Message-State: AOAM531Uht/kf93fKyOhJTCdl0CvSd8tQPzDWcAR61dI/dTIzIhVN7/1 kYeFuw9U863Tt3mYfc5B0UU= X-Google-Smtp-Source: ABdhPJx2i8ncNsNDhkhF6jQVdHVX7znlDqg6Pi1+vnY10pIgWBveR0olLKChOOU12RUiLgfwFU3z+Q== X-Received: by 2002:a63:4514:0:b0:3fc:20d2:2e74 with SMTP id s20-20020a634514000000b003fc20d22e74mr30781347pga.623.1654704284278; Wed, 08 Jun 2022 09:04:44 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:f579:a14f:f943:9d9a]) by smtp.gmail.com with ESMTPSA id ju10-20020a17090b20ca00b001df264610c4sm18622019pjb.0.2022.06.08.09.04.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 09:04:44 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev , Eric Dumazet , Eric Dumazet Subject: [PATCH v2 net-next 2/8] net: use DEBUG_NET_WARN_ON_ONCE() in dev_loopback_xmit() Date: Wed, 8 Jun 2022 09:04:32 -0700 Message-Id: <20220608160438.1342569-3-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog In-Reply-To: <20220608160438.1342569-1-eric.dumazet@gmail.com> References: <20220608160438.1342569-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 Wed Jun 8 16:04:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12874206 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 0F298C433EF for ; Wed, 8 Jun 2022 16:04:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245076AbiFHQEu (ORCPT ); Wed, 8 Jun 2022 12:04:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244799AbiFHQEs (ORCPT ); Wed, 8 Jun 2022 12:04:48 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9244327CD6A for ; Wed, 8 Jun 2022 09:04:46 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id z17so18705727pff.7 for ; Wed, 08 Jun 2022 09:04: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=3qmIlwzFDR6fdFmAUyrSAM3P3hLoEa2XcvXoRMhOA5Y=; b=DtUhv3nZZG1hiufCai0WOO4f6QTDVj0gx8ZyoXMfMP/GhqQHK/nBp8CdH1LNr40cdh LcgWTcrjQE5CFZ9cvvwdER8Ggip0pgWsiLFlmls5oMk1A4KyQEmdCRHnFO1pFnAPd5zk /7rAmT9hzQMsEp4Q0YgQCikLkQxDlXg5/jlk/MNrKPSTmRMeHqZJi5qhj9g3d7bi68Sz 0R90Gnd3aiZVEtDuhfixil04jsGqEGGt6nxdasJM8uL4x3X1IpuGi7S/eL3rnaK2DGE7 s6YwnmVpa+hIJeMuC/Cfko/dVM0Sbu6DZY2F4CQ9UWsRNxIgOD4gCQmAVM44fR/X6UcT rr5Q== 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=3qmIlwzFDR6fdFmAUyrSAM3P3hLoEa2XcvXoRMhOA5Y=; b=7YI3xFGUjEIeHYo5gf7j4quL+gqr858jHGf5Juodg6zPnztDC0lG0IEqxiN2DbMu8Y 5UwvMnQF3uYSr9GsgVlnHfI6o8COJY3qkZVVu+QmwAqcZV7C5O2aMXEx2t7XydAe9ZKT RjY/wiUca/A0TwgLZHP+UQndVtmeoxOvo7z4QrMkuFsxfxO9OKfvov45RW4WqF1DUccT ujcyiQJEEzQ0Ks6WHL5RiS2iYuEJOgmn2yoxcQRU5A1Z7hNJXaNay6raFBk0PifhgUs6 ++Vp0nEJxH81p4blCEw8vJxApSydQcyd6mvexZWVitf/JPOCSEQ3s4E38S5LvwsY7E6t AKQw== X-Gm-Message-State: AOAM532VH8r02qqTj+jZYbbSiTAPP8juJ1NoiQHPgVBGcUMmxBSNnDuf +s2LI3T/niZfkn7WuFpj23oWOZqexr4= X-Google-Smtp-Source: ABdhPJwCK+kIJbvZCk4DI6oEFrgZEqCrt80MPCBSMJ5VJVMLS+RgxiIJ2uWdCWjWa815BlnfG0Ud1w== X-Received: by 2002:a63:5610:0:b0:3f2:7e19:1697 with SMTP id k16-20020a635610000000b003f27e191697mr30232043pgb.74.1654704285588; Wed, 08 Jun 2022 09:04:45 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:f579:a14f:f943:9d9a]) by smtp.gmail.com with ESMTPSA id ju10-20020a17090b20ca00b001df264610c4sm18622019pjb.0.2022.06.08.09.04.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 09:04:45 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev , Eric Dumazet , Eric Dumazet Subject: [PATCH v2 net-next 3/8] net: use WARN_ON_ONCE() in inet_sock_destruct() Date: Wed, 8 Jun 2022 09:04:33 -0700 Message-Id: <20220608160438.1342569-4-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog In-Reply-To: <20220608160438.1342569-1-eric.dumazet@gmail.com> References: <20220608160438.1342569-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. 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..30e0e8992085d5d4ac5941b5f3a101f798588be9 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)); + WARN_ON_ONCE(atomic_read(&sk->sk_rmem_alloc)); + WARN_ON_ONCE(refcount_read(&sk->sk_wmem_alloc)); + WARN_ON_ONCE(sk->sk_wmem_queued); + 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 Wed Jun 8 16:04:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12874209 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 CDB53C433EF for ; Wed, 8 Jun 2022 16:04:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245090AbiFHQE4 (ORCPT ); Wed, 8 Jun 2022 12:04:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245079AbiFHQEu (ORCPT ); Wed, 8 Jun 2022 12:04:50 -0400 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EF7D27EBCA for ; Wed, 8 Jun 2022 09:04:48 -0700 (PDT) Received: by mail-pg1-x529.google.com with SMTP id r71so19343551pgr.0 for ; Wed, 08 Jun 2022 09:04:48 -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=s/yjgAWN6ga6buAhDAV9p3FMONiUhJ1Xnyb57YPRcdg=; b=be2yqTzc4suwMQb845QjAzjSwZBOEM1X8h8Uc5ft62whkCOjpdpFiA8am46rBd0X4O KehCNoC9oSEFBkigAeX2tbRpj6R0M4fabapJR7HwygAPQA6HcEBnEdKoMzYpkNSxUq9g 7n4xIJnnZilW+zIhpbd7q8iM5qkV7+vuDdlJvLDi/WtiIp8EMtPApjnjknflsfn/z61z wOFjtRowm+mF6itF5TwXb7beA5cx5Lj6Y8q9cfqYEYQ/h92an7326FoGBa7LwRfRAguk 4mLLPpJhogL85pLkhQPTeJtdnol/DPMdqUZYhH+YyCzW1kzz5/oTRL+Oo9VDS0+D7xw6 jXYA== 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=s/yjgAWN6ga6buAhDAV9p3FMONiUhJ1Xnyb57YPRcdg=; b=ndmCsSy0Js/nD3pYBNlcpk8MYn4lnzc3GIn+EiIHwUtTTqhlXj3IKes7yatuUr4/pQ 6eOgwUiv2+ZKzC17Boz0zLdxHjSGWE17s9SJvtIkWZkqHRHlr4YkwZGz2RAToChC0M1i Ft+XbdlTfr6Ute1GrtUk+w18o6NFmWCxU57oLWZmNdws4ukSVkLGH9pyuwZ9Bu2IRkOT 4gaFcL/ggHvSWNLu2SYp7Ub4MsO72qr5acu+gH73sQWoKpO4rHYHWbtyaphWhQeG87FU 78qjKZ9p1d4ujdyGm8OcxTbDjrNUHuXUBYlMbJ0fNpSpXE34ZtR1Duk1Eap/E6pPqVNu fMBQ== X-Gm-Message-State: AOAM532yRvLAWtcSx1eQCG/0l0XJnAGz7CW3vNNZYG2zPy55Qh+uOWs5 Q8Ly/+V+Q4hZHfQhSlsWfyc= X-Google-Smtp-Source: ABdhPJxLckQ41XwJfT7PLMjiUZZrTxgFkJtsKlXvD+OXcqL+6htbSbPCBX/B44ekpkndOEEQu/JvJQ== X-Received: by 2002:a63:5515:0:b0:3fd:9833:d9f7 with SMTP id j21-20020a635515000000b003fd9833d9f7mr16934374pgb.16.1654704287261; Wed, 08 Jun 2022 09:04:47 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:f579:a14f:f943:9d9a]) by smtp.gmail.com with ESMTPSA id ju10-20020a17090b20ca00b001df264610c4sm18622019pjb.0.2022.06.08.09.04.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 09:04:47 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev , Eric Dumazet , Eric Dumazet Subject: [PATCH v2 net-next 4/8] net: use WARN_ON_ONCE() in sk_stream_kill_queues() Date: Wed, 8 Jun 2022 09:04:34 -0700 Message-Id: <20220608160438.1342569-5-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog In-Reply-To: <20220608160438.1342569-1-eric.dumazet@gmail.com> References: <20220608160438.1342569-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. 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..ccc083cdef23266dc100368a7183bdeb0e99cbb7 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)); + 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); + WARN_ON_ONCE(sk->sk_wmem_queued); + 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 Wed Jun 8 16:04:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12874211 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 A81BEC433EF for ; Wed, 8 Jun 2022 16:05:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245105AbiFHQFC (ORCPT ); Wed, 8 Jun 2022 12:05:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245084AbiFHQEu (ORCPT ); Wed, 8 Jun 2022 12:04:50 -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 18AA927F477 for ; Wed, 8 Jun 2022 09:04:49 -0700 (PDT) Received: by mail-pj1-x102a.google.com with SMTP id gc3-20020a17090b310300b001e33092c737so18696627pjb.3 for ; Wed, 08 Jun 2022 09:04: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=hk2j4KT4epHlqbZHiLJkBlPuG//+NAA3DEVO2L3G2Nbovsc0c7q/MAg4E1vvL5ra79 Hor/ExkYq6GlMJVLGK/mAhuL84IXJnutfr6MwwuDfk8AlgAOSQ4T6ZP+QFz/tE1nLqcB ZtTBp1d73ayVc+8Gq9oLhwRVjZ1LnopXIHUN1oRMHRbaXC7XFLFwfckVktGto7BgyHT0 PYC4ljS2ziRk0yqjkx02y5UWE5Fy+5pobXu5arEQ8lUcGWZckAVWAg4fK8boyDI3c6C0 HalAL4x0tA2eVNPfciBD38X3z8W5VfkVdFWleJavCjG7bY53dOwvxGq1OaevrzpzH1sJ Lp2g== 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=usV6667CYB79pFMXG834MykTZtJyfMSytneL1XLJw4d8TIxfjAKWqEXyh4N1XXGwlZ oyh11gztKIzS6IoQ27YJroTDc1/fs9UCJ0CIRNclvMPRSowBsWTzKkv/cbs9hMLQUFeL i8kXmSkpYrfzsoa0SGd7sVEpnPeghVUkCbQ/wDtSFyQ+G1EHILhnqAKob3Apt6OTkPQp YvpPZVhXEjyODcDwl8xjY5tL12Ao3LPgwKl20RP7S793/ixsLY3CEfsRdR4GYcOtEEz6 xkzhQJfnIlBGxhh+SAXsVKMdrftpLO41ehuplCaUbPe2wqXIu6PGdWhzRKtcHPuU0Ys8 ZF0Q== X-Gm-Message-State: AOAM532+ubp5QoSdVMW/0M/hEChg4cJCx/9mo/IqiA8eqAzn/7Rj41VU /oLyXAotvubDIBwrCfEdiW4= X-Google-Smtp-Source: ABdhPJz9ugGBaT2B0AolRRXP7XbcnUsfibp0pIgkkrZHMH/AQXafpKLHRIwH6Oz4oTB26ymyPARe+g== X-Received: by 2002:a17:903:246:b0:153:84fe:a9b0 with SMTP id j6-20020a170903024600b0015384fea9b0mr34644464plh.163.1654704288504; Wed, 08 Jun 2022 09:04:48 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:f579:a14f:f943:9d9a]) by smtp.gmail.com with ESMTPSA id ju10-20020a17090b20ca00b001df264610c4sm18622019pjb.0.2022.06.08.09.04.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 09:04:48 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev , Eric Dumazet , Eric Dumazet Subject: [PATCH v2 net-next 5/8] af_unix: use DEBUG_NET_WARN_ON_ONCE() Date: Wed, 8 Jun 2022 09:04:35 -0700 Message-Id: <20220608160438.1342569-6-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog In-Reply-To: <20220608160438.1342569-1-eric.dumazet@gmail.com> References: <20220608160438.1342569-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 Wed Jun 8 16:04:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12874212 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 31E1AC433EF for ; Wed, 8 Jun 2022 16:05:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245091AbiFHQFG (ORCPT ); Wed, 8 Jun 2022 12:05:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245061AbiFHQEw (ORCPT ); Wed, 8 Jun 2022 12:04:52 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 383A227CCE1 for ; Wed, 8 Jun 2022 09:04:50 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id q18so17999027pln.12 for ; Wed, 08 Jun 2022 09:04:50 -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=Unqkl6bfVR5eWUmXek9FUuaQgAF/5XOU6ElF57/IR66+xEHZ9WEQaWHSjWWRIrBlMX X3hE16eJL8WByXD8MGw1jWJG0g0dgoyMvKb1ichJz7VLiK0ZCsGnwKAK/7MSskRdZtA7 Q4KB52xdx1sx0FI0m2VrLpfqzmFZW/noSl7dHYdx5AC2nHNEgOjBzZAAsLUtjjB4kZ2N dF8VDLVDn8CHVauoRuJ3AuMS+ES8jU/HKJnwq3j9qVivRhNwgm7aQlTTihIQOHI8XeoU E1MS3UnKR5m80/EolTQ2p5bTBlAw9QmXEQweVi4UzKQ2bVtNF6tYSCK8UnqUw/1XakeO 1MTQ== 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=f1UBzbY1lwba2Yz322GMdy8OVmpuG3v7YjeHsFRt2eNyEYGzge/oFx4jUe0d8LoCr4 GT5hYSFxNqVmNcbyIb+6rc3QNLI7WR6aFYxT+5cWdd/qMYwQC7216tydHX3IAUPbj55X NBbSuNSSSWvYtEQ5DB3bmH5+1C/GfzOKCJ/LRi3on/kYFkGVt9L+mKxUQHiS1SKuCaow FDux9F2nfww2ttVxUi+o3k4XnJ0r571Ce/90VzeepxTQHHAwI5vV3q8L/olasy1OhJjw 5TJNtj1vGJIQ8eB0QaCJVgk+nn0YePLhH8S5z3AJjERIrMTafaDWBo/waubPIs0mRrrc 5bSA== X-Gm-Message-State: AOAM533cbC686igEIcvZ8Ei4gPPL6rlv7RI4IMpNybTpRUymvrG1+9VG 1TXcAVa8D3ioqqX+koF2MV6wMkxSlWw= X-Google-Smtp-Source: ABdhPJzLD033NN618dcWkMwMpWVtwSjyHXBlQ78lOtmGW7KP4FD/+BzKhH6Okti5sZEpty4ko/MnHw== X-Received: by 2002:a17:902:b689:b0:167:8b69:d1a7 with SMTP id c9-20020a170902b68900b001678b69d1a7mr11786758pls.156.1654704289732; Wed, 08 Jun 2022 09:04:49 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:f579:a14f:f943:9d9a]) by smtp.gmail.com with ESMTPSA id ju10-20020a17090b20ca00b001df264610c4sm18622019pjb.0.2022.06.08.09.04.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 09:04:49 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev , Eric Dumazet , Eric Dumazet Subject: [PATCH v2 net-next 6/8] net: use DEBUG_NET_WARN_ON_ONCE() in skb_release_head_state() Date: Wed, 8 Jun 2022 09:04:36 -0700 Message-Id: <20220608160438.1342569-7-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog In-Reply-To: <20220608160438.1342569-1-eric.dumazet@gmail.com> References: <20220608160438.1342569-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 Wed Jun 8 16:04:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12874214 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 877F3CCA47B for ; Wed, 8 Jun 2022 16:05:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245121AbiFHQFN (ORCPT ); Wed, 8 Jun 2022 12:05:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245096AbiFHQE6 (ORCPT ); Wed, 8 Jun 2022 12:04:58 -0400 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67CA427CD47 for ; Wed, 8 Jun 2022 09:04:51 -0700 (PDT) Received: by mail-pf1-x42d.google.com with SMTP id b135so18697987pfb.12 for ; Wed, 08 Jun 2022 09:04: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=z0Lo7KdcQV5V1+hy9GBEXahSN5MlosYjYm/RYugMrYw=; b=KI7WDV/w0e5o51062ZdbcFaTTBh9UGIi78wkqFmqNvBUY6KPF5U3ielo5OmZByfCsd 02MHv1+ymnao8EHS19QpOlEFh82Az1ZB5nJdnVB1+FmHg1FBsVSurKAsqmleHtFxOIHX YmqnlsC//xeMApumcAKs0/syg/2tbJSsj7kw6XGfX3Fh2D41fiYc6sY+EUX9Q4UzQ9Vm lvFuQywvcyMc9quhVbha6PrpYhk3gzYcb3CK+XXKu/K0x2+d6VqcTmCVyIX6Mnw4+/n2 LGmY425q7g+xZjR55uBYk6k01jheb0snW73FcoSTLzvTks6ou1zqysdGIgLpmO6Z8dYS FFxQ== 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=7Ufwht1wZzNjpRBksHMm1Xo3CJ0cNSpXdVDPmkRk/0kfDrSMRgPG3ozrTpUFwwIsi7 O+OOLWOO/p5RGi2RszfGg6K+BHbhTg40O8UwofKglXm1f4p9bU8377CRtxLwkl7vPySQ 0gW50loJAdogfT+Xl6Yo2EUA7KR4JvH6sj+1/ctRogHgMGnclegK77EnDAn6oGgCNnms l4aq1kxEa+ElkfEAm4TJsUnuPziNXFlujpM2uPB0Bfx/iq70Qfz57Typ7vJreXXK6++b XsDpn1CMKgz63L011mfj7WS4O8FeFA+bj6R+614v5Jfa7F7FOT2Ii7a+srIhBTjZzAM7 IZJg== X-Gm-Message-State: AOAM531LCEqWYwSmFay+Sosf22Cyx65rmZqSRcs8E8BJHPFDYcgixap4 UWfk58jUtrM7ZQwgT47eS3s= X-Google-Smtp-Source: ABdhPJy8Xatn7GRhKTUAPY1AtBPXNRx44N0MSGi8vsuUG6MTzA2g5Z7zzZvyZwHPK1VvN+UjMbfl/A== X-Received: by 2002:a62:544:0:b0:51b:a90d:64d3 with SMTP id 65-20020a620544000000b0051ba90d64d3mr35432462pff.40.1654704290936; Wed, 08 Jun 2022 09:04:50 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:f579:a14f:f943:9d9a]) by smtp.gmail.com with ESMTPSA id ju10-20020a17090b20ca00b001df264610c4sm18622019pjb.0.2022.06.08.09.04.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 09:04:50 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev , Eric Dumazet , Eric Dumazet Subject: [PATCH v2 net-next 7/8] net: add debug checks in napi_consume_skb and __napi_alloc_skb() Date: Wed, 8 Jun 2022 09:04:37 -0700 Message-Id: <20220608160438.1342569-8-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog In-Reply-To: <20220608160438.1342569-1-eric.dumazet@gmail.com> References: <20220608160438.1342569-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 Wed Jun 8 16:04:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12874213 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 1FC88C43334 for ; Wed, 8 Jun 2022 16:05:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245114AbiFHQFL (ORCPT ); Wed, 8 Jun 2022 12:05:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245088AbiFHQEy (ORCPT ); Wed, 8 Jun 2022 12:04:54 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 429C427F5FD for ; Wed, 8 Jun 2022 09:04:53 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id h1so18001506plf.11 for ; Wed, 08 Jun 2022 09:04:53 -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=CBqNoz3lw4byw6JuohqwVQykFbv7bK5KmSvFDQV2CbYeJRzxc25uwetVke2/8Tg91d J8vupRKBatko26oXgQmuF4pGpeVqtV2dXswPK9hOvjUMEfGK2wHETAtCQqdwN1KLEvBg VYL77RMenB4LV6M/zaGsuHMOs8bVC8vPdQV/gJJZ5W3DC2nVZBmQY58GCfF+KXOar71s tLtvihrpT07D5LfBrA6671VvCWTRzw4ldEdtjW8ml7n6ffK36/RvUNFElYvxxZsZaHPY GsBZQpPoMtcYCc3qJQlChAnnbtA5decgfvjdJG0ofjjWGJqc5tcsIsIllrJSW3/J5kF3 O4rQ== 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=U8aj6oRP89ze+Tuf1vAYXTPjm4u/ZUmuO4fB3hkXLyaWlG4hbdiGMDSSn7o1eafUgM UkC7Vrji0gvVGo2ip1xurj2m+9ib3fjPOT7BH6DmKytlo0si21G91z5TD5itoYz/2mDt BQNKcgZswlxpusecSpMBjySMyE0RRLEvqYT2X7OUgBxsaHW8j7oFHsMGw7gjFmcD4rZx /+TOgsdn9vGUEkYK8COPAhM+s+xy7RFyQDoksST0WPKTVzDGQCAzYX/JCyu2ByDxrwBE TpcV6aTyejljbNvidxYpZARBY7b0fL+szZlfhCXaUPdOBjbpA5L1vkUgzcLQ38iKFLJZ ePMA== X-Gm-Message-State: AOAM533x0oCAa+4G22yruwZcYJwzY6Eu+XokzWBk+Ci/ixXvKNlHKyl2 R+EWf20zAXMVSAzAW2SvVe8= X-Google-Smtp-Source: ABdhPJyb0+g6o4Oy+H8nAKmZC1sBP3BGPuU4M8cMQDrRk2tX1kc4+7WCJHocuIGNMJFi0kzXxIystg== X-Received: by 2002:a17:902:ea08:b0:163:ec68:ae08 with SMTP id s8-20020a170902ea0800b00163ec68ae08mr4226846plg.52.1654704292879; Wed, 08 Jun 2022 09:04:52 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:f579:a14f:f943:9d9a]) by smtp.gmail.com with ESMTPSA id ju10-20020a17090b20ca00b001df264610c4sm18622019pjb.0.2022.06.08.09.04.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 09:04:52 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev , Eric Dumazet , Eric Dumazet Subject: [PATCH v2 net-next 8/8] net: add napi_get_frags_check() helper Date: Wed, 8 Jun 2022 09:04:38 -0700 Message-Id: <20220608160438.1342569-9-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog In-Reply-To: <20220608160438.1342569-1-eric.dumazet@gmail.com> References: <20220608160438.1342569-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().