From patchwork Thu May 12 06:26:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 12847155 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 9DAD7C433F5 for ; Thu, 12 May 2022 06:27:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350370AbiELG1D (ORCPT ); Thu, 12 May 2022 02:27:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350171AbiELG0y (ORCPT ); Thu, 12 May 2022 02:26:54 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A6EA5C86B; Wed, 11 May 2022 23:26:50 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id v10so3712231pgl.11; Wed, 11 May 2022 23:26: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=jj3Vsqhtkkm1RpfY/9Xvn3iKl3HTI+1EXSJInVx3Io0=; b=YFL2t/LDgfhTvDefT84RQFkMGOEIuDXGKntAtrBFgd0oZ5mDKu5DxCqk9Ma0ENXPFk YDyY5xynaoQYyP8CV7SEmjkYfHvW2zMxyybEh0yW0f4QFBn/B1rbWGlo2Ha9Ph9Qnezn M1KEzku5FIEoVSeS9Uih97Ap0mmfTs5t3Ak34UQ4waxEzQzwtFc2qrQmRweb6gWbSCRS 6uL4XUo9glJNbwrsUziaui3A8tTUiEN7fontoKjVovHhba4X2FdryaDg/WYHgV2tZVwe n2ToJfuuPzPV8uZkY+mm/ty1mKimi8/VXZtv8tmgY234tikQHLlnaAKdNY+ObhGLQVks RZsQ== 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=jj3Vsqhtkkm1RpfY/9Xvn3iKl3HTI+1EXSJInVx3Io0=; b=7s8PwgkiCSE/uomwvfWe1izJCXtAMneptDdIN/hGzT+2nbsV93Vm2LKBGUaJhMS08y 0mPEXvSCL0DSiTG33ZmXh5mkjeOJrH7FM0dKDbkzr6lLMK7t/rw9/2yWgrIWpWk39791 JgcdmHqYZK61jCX/PgrD6Xr6NYOl5pijHZxYXllet+5G77E3VFI1kvSj3rrYnFEKZrcM 9sib7oESnhT7B2tIXmZdTC57t8/K9HQATcZ8i7ubeLQ6wegn1L+SDOzCmGH7DwwSylqd 6VUApVjZzZ28ePdK0cwSiV3weRYS6aHOp3mql56fx9IUGN3iyrWG+9tGsHN+Ay2f7uLv N41w== X-Gm-Message-State: AOAM530sQljmIXnmqtPjRHKCoDajwO/3dCwU5mfe4vpZL5XrQRC/3okE ShQyraBfQyaPWhUdJmCsCPA= X-Google-Smtp-Source: ABdhPJyhAI6t/te98dvpLeUtTxAvqLHumurGzd2StGz37tEaryYvdUpxdCF9c+yfPZRQg92lQL7rRA== X-Received: by 2002:a65:6552:0:b0:3db:772a:2465 with SMTP id a18-20020a656552000000b003db772a2465mr243103pgw.225.1652336809711; Wed, 11 May 2022 23:26:49 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.114]) by smtp.gmail.com with ESMTPSA id gn21-20020a17090ac79500b001d903861194sm999748pjb.30.2022.05.11.23.26.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 May 2022 23:26:49 -0700 (PDT) From: menglong8.dong@gmail.com X-Google-Original-From: imagedong@tencent.com To: kuba@kernel.org Cc: nhorman@tuxdriver.com, davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, yoshfuji@linux-ipv6.org, dsahern@kernel.org, imagedong@tencent.com, kafai@fb.com, talalahmad@google.com, keescook@chromium.org, asml.silence@gmail.com, willemb@google.com, vasily.averin@linux.dev, ilias.apalodimas@linaro.org, luiz.von.dentz@intel.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next 1/4] net: dm: check the boundary of skb drop reasons Date: Thu, 12 May 2022 14:26:26 +0800 Message-Id: <20220512062629.10286-2-imagedong@tencent.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220512062629.10286-1-imagedong@tencent.com> References: <20220512062629.10286-1-imagedong@tencent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Menglong Dong The 'reason' will be set to 'SKB_DROP_REASON_NOT_SPECIFIED' if it not small that SKB_DROP_REASON_MAX in net_dm_packet_trace_kfree_skb_hit(), but it can't avoid it to be 0, which is invalid and can cause NULL pointer in drop_reasons. Therefore, reset it to SKB_DROP_REASON_NOT_SPECIFIED when 'reason <= 0'. Signed-off-by: Menglong Dong --- net/core/drop_monitor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/drop_monitor.c b/net/core/drop_monitor.c index b89e3e95bffc..020ac5f214d0 100644 --- a/net/core/drop_monitor.c +++ b/net/core/drop_monitor.c @@ -517,7 +517,7 @@ static void net_dm_packet_trace_kfree_skb_hit(void *ignore, if (!nskb) return; - if ((unsigned int)reason >= SKB_DROP_REASON_MAX) + if (reason >= SKB_DROP_REASON_MAX || reason <= 0) reason = SKB_DROP_REASON_NOT_SPECIFIED; cb = NET_DM_SKB_CB(nskb); cb->reason = reason; From patchwork Thu May 12 06:26:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 12847156 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 7D6B5C433EF for ; Thu, 12 May 2022 06:27:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350390AbiELG1F (ORCPT ); Thu, 12 May 2022 02:27:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350369AbiELG04 (ORCPT ); Thu, 12 May 2022 02:26:56 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C1765C675; Wed, 11 May 2022 23:26:54 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id x52so3894925pfu.11; Wed, 11 May 2022 23:26: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=0V/g4vf7d52LTUG/UsmwgEG5VgHlj0HZXVekJyZLmLw=; b=JAvvl9iVFuRWt0giu6Rwh3EdHz0j+mUXfhVs1/bb/cMKT82K/sFGAYYspCHfUPShse O1vD4wYWSOxdKvs/quqWY0WDC5ilC4f6Lk5slDAvnwduQ/HDmf8844QCxMP8KW758Oco mhuO5jwmMSgqiWnlOpfhGKw4PHY6tMR+1CsGFCrh7H8KB479SVUPNx3Okm/TDp0SxNEf TTzlyEo1SAzEj7WNGABDdgBS0lyKYDm8kph82798x0WwVXHyqcgC8jOfAaTPqpWpXuDP c0F8Cvx1t3IRjMw0kVMIzlcrDWuVl2ZZe3HEs3FETcANOkr7KPC5JWbdXJ1gBUajzijX aoJA== 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=0V/g4vf7d52LTUG/UsmwgEG5VgHlj0HZXVekJyZLmLw=; b=AAXSwOOk9zmz+SAVMA8uoc674ptc9lN9A13VdynT03yUBbu8SYoI2CBQSORibybPv4 ThwpfAr9TyCw8yazQQfm/h08Y3C61LjvnG/Eu6mOD6/v3vfJN7UuCkYFg7DqnKl468zb XXv3US7LOabQGD2Te7mXiPCHTIN4G0gufA+l+B4srquSNd3vw+IcdPZdrtuD9IvNrWDv BP2F2yRDgpLB4gPRbI3hLs2sShxYO1F9PFFDInanNEwTH2AgA4LPu+LdBTcjJbsBJihp Qa9Ou1iuX7dNrHMt2c30OqZRGDmEZAH8Y5XGTRo26/ImaemrVnFbbokOtPt0aMWPvKNL HlQQ== X-Gm-Message-State: AOAM531jW4SXnOmEGzOmFmsIsXDHnTvXLavdek+ZNpqZBnXoaqMUXOdh 8QiKJcrbQqWrwBc12QPV05I= X-Google-Smtp-Source: ABdhPJwumZvA6vnB3QhkMlMBeBllxIQd1AH+g8+eQJ+ErANn77c0uvTvU3gq1vA4OKtwL/bIUkKjiQ== X-Received: by 2002:a05:6a00:234b:b0:510:4161:781a with SMTP id j11-20020a056a00234b00b005104161781amr28761397pfj.5.1652336814066; Wed, 11 May 2022 23:26:54 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.114]) by smtp.gmail.com with ESMTPSA id gn21-20020a17090ac79500b001d903861194sm999748pjb.30.2022.05.11.23.26.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 May 2022 23:26:53 -0700 (PDT) From: menglong8.dong@gmail.com X-Google-Original-From: imagedong@tencent.com To: kuba@kernel.org Cc: nhorman@tuxdriver.com, davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, yoshfuji@linux-ipv6.org, dsahern@kernel.org, imagedong@tencent.com, kafai@fb.com, talalahmad@google.com, keescook@chromium.org, asml.silence@gmail.com, willemb@google.com, vasily.averin@linux.dev, ilias.apalodimas@linaro.org, luiz.von.dentz@intel.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next 2/4] net: skb: check the boundrary of drop reason in kfree_skb_reason() Date: Thu, 12 May 2022 14:26:27 +0800 Message-Id: <20220512062629.10286-3-imagedong@tencent.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220512062629.10286-1-imagedong@tencent.com> References: <20220512062629.10286-1-imagedong@tencent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Menglong Dong Sometimes, we may forget to reset skb drop reason to NOT_SPECIFIED after we make it the return value of the functions with return type of enum skb_drop_reason, such as tcp_inbound_md5_hash. Therefore, its value can be SKB_NOT_DROPPED_YET(0), which is invalid for kfree_skb_reason(). So we check the range of drop reason in kfree_skb_reason() and reset it to NOT_SPECIFIED and print a warning with DEBUG_NET_WARN_ON_ONCE() if it is invalid. Signed-off-by: Menglong Dong --- net/core/skbuff.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 15f7b6f99a8f..e49e43d4c34d 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -771,6 +771,11 @@ void kfree_skb_reason(struct sk_buff *skb, enum skb_drop_reason reason) if (!skb_unref(skb)) return; + if (unlikely(reason <= 0 || reason >= SKB_DROP_REASON_MAX)) { + DEBUG_NET_WARN_ON_ONCE(1); + reason = SKB_DROP_REASON_NOT_SPECIFIED; + } + trace_kfree_skb(skb, __builtin_return_address(0), reason); __kfree_skb(skb); } From patchwork Thu May 12 06:26:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 12847157 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 03AAFC433F5 for ; Thu, 12 May 2022 06:27:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350438AbiELG1a (ORCPT ); Thu, 12 May 2022 02:27:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350362AbiELG1A (ORCPT ); Thu, 12 May 2022 02:27:00 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B7EB5C67B; Wed, 11 May 2022 23:26:59 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id fv2so4248764pjb.4; Wed, 11 May 2022 23:26: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=AQyVf61Zw24XGBWdK94LwS39cWxpJFLHyqDT1duRJA8=; b=Hd1A0pZLbviVe+sZYYD9GXxR5xCoEbyEc8QK7Pf8cwynIK8Lt+oQw282zHddPoNvF7 QGAuQmMyUFLnvkWKCXxSa5Sz33j1KEAOIyJrG6y610/7ABo50tmfcWO4ris6x660pPjS Bf7kBdY3vq2CpyGOdkXvmMXKnrV4Xn/T4zh3+SO5YGW013PvhPP4uLTyEi46s4ZWXY9M 8cN8rRKLpqm9uFouG/v5x+TMAYjeLp/AoXL3j25xG768cBt1y4RbkOPBsIgQEs0FovlX oq8qeQ7Nure1tLh0K5+7ASz99RZMN+UxProvMaYmlH7jH9eB/Nw+w2SvTg8immEaPlIt uF3Q== 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=AQyVf61Zw24XGBWdK94LwS39cWxpJFLHyqDT1duRJA8=; b=A46VwSo8Ox4+dLTz7sGTt91a2PiZPR+ZFOa75ZEzN8fhBOlDBZlpAmgK2NGnPDAf0z V9N53giMUSmI1wVYLM9qnB9bklbgDrAo5z8U/RK/TDYzb0SQsSR0L4znSshWqZNS7xA9 ZIwZ9pRVbrzZccutrd6T2TkBHqsGUMrRtlsXPxHpukQDNN37BmXeJLslUh49gy6dewAO PA/D49GlseZvi5p+PFTxQ7BkyZ7Hw9+OQQ6kxn6umMMLC4SU4Y4B9TERnksJ/lYzjzAf qlWR+UMtPYojgJvhY8iyvZE+D0zI4OVgPnSsRYBEmgkWy02dhn8qND9HJPHpBdcBbpai 5V0g== X-Gm-Message-State: AOAM531PfX1g+YG2x2uUWQwPAe1utUcQT7ITPW0tYVPZIldOlj8QFs0C /ULD3pCdOPrPWZDJSdhQiig= X-Google-Smtp-Source: ABdhPJwU+2+Np2VZNOV3fQHUSGSxPzVkWHf2VurRw7XdVaMLK2E+CRDo7IcrBP7+0z5uxrfl6H/Bog== X-Received: by 2002:a17:90a:730b:b0:1d9:7fc0:47c5 with SMTP id m11-20020a17090a730b00b001d97fc047c5mr9254242pjk.60.1652336818424; Wed, 11 May 2022 23:26:58 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.114]) by smtp.gmail.com with ESMTPSA id gn21-20020a17090ac79500b001d903861194sm999748pjb.30.2022.05.11.23.26.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 May 2022 23:26:57 -0700 (PDT) From: menglong8.dong@gmail.com X-Google-Original-From: imagedong@tencent.com To: kuba@kernel.org Cc: nhorman@tuxdriver.com, davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, yoshfuji@linux-ipv6.org, dsahern@kernel.org, imagedong@tencent.com, kafai@fb.com, talalahmad@google.com, keescook@chromium.org, asml.silence@gmail.com, willemb@google.com, vasily.averin@linux.dev, ilias.apalodimas@linaro.org, luiz.von.dentz@intel.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next 3/4] net: skb: change the definition SKB_DR_SET() Date: Thu, 12 May 2022 14:26:28 +0800 Message-Id: <20220512062629.10286-4-imagedong@tencent.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220512062629.10286-1-imagedong@tencent.com> References: <20220512062629.10286-1-imagedong@tencent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Menglong Dong The SKB_DR_OR() is used to set the drop reason to a value when it is not set or specified yet. SKB_NOT_DROPPED_YET should also be considered as not set. Signed-off-by: Menglong Dong --- include/linux/skbuff.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 5c2599e3fe7d..818347b0180e 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -480,7 +480,8 @@ enum skb_drop_reason { (name = SKB_DROP_REASON_##reason) #define SKB_DR_OR(name, reason) \ do { \ - if (name == SKB_DROP_REASON_NOT_SPECIFIED) \ + if (name == SKB_DROP_REASON_NOT_SPECIFIED || \ + name == SKB_NOT_DROPPED_YET) \ SKB_DR_SET(name, reason); \ } while (0) From patchwork Thu May 12 06:26:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 12847158 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 498C2C433EF for ; Thu, 12 May 2022 06:27:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350460AbiELG1d (ORCPT ); Thu, 12 May 2022 02:27:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350396AbiELG1M (ORCPT ); Thu, 12 May 2022 02:27:12 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4A8A5C870; Wed, 11 May 2022 23:27:03 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id cq17-20020a17090af99100b001dc0386cd8fso3989277pjb.5; Wed, 11 May 2022 23:27:03 -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=SId0BSKGJByzADGTc0Pg51EQum2GGJlUi90u8v9tdUk=; b=WECu1swx+WybchdEtIuAQaqI4jZ9KRW+ZyK8KnsDwP4klZxjdt9tcrf0JuZhFzC8sx hOwdTQo5S5H5yabn+YWtsYnFqtCyo1Ar9K9Uyrl6O+vKO3Qc/R/fASlcgZVNhEjDiKaB 5W1N531AtdQ6+btW89Cw5D+JyleqgvzMXkmhTvn6MJl8aNeTTcweeLjrZtGadBUDpDhN b0RaChgaCqMloQ9afgUeRUj1fR5aHCvDM+z+u5eXa51aD/qpbHHbJj1L76ogf8vufOek RmNxfpXAsYHvK3qa/jE52i7NGQT0Toz1upe3a00w6H7OSx9nbD1PC8DJGlb+lYpURz4t X3Pg== 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=SId0BSKGJByzADGTc0Pg51EQum2GGJlUi90u8v9tdUk=; b=bT6ojLUPJ1r1+OO9zTOOCwh6ufuki4Z6uJ2wWGUcGKYT1mw6/9WoZqQh3ixTpJiMyZ 9a1J5yKUidHnM2uYMSnj2GAe6/25PqzuzVFOcL88x+1O+Yiugi+uAAjTUN9flqpSNbr9 5lYOMzJPTP6PIY6kY3vobW9zUUtDM0M5W6VRFB3v3KQp7nktzNCR6fqwerySZZgVusQI DqgZyUXg/EmREWOfEkwny1ViVfcEtqHNena5pULWy+JgL5pNP/QeQPq0JkWIlAVwo26I +bpw53OjbJRiAyQXmwYPrqdNoDFNPiunssqaIJl75tF12qjXIax74v7dD9OZ52h5+yNl rIzQ== X-Gm-Message-State: AOAM532jpdqC58Nh+4In2L9t/14uXs7oDlmP74aYaf3uDWsOfUW6z+xU BwBG31kzKljA5MkZv59GG9M= X-Google-Smtp-Source: ABdhPJyA7aM0RLXM7wBs20dQIFZCRvUi6LExaQDa7qsMHUdY+nLD3+Ep9+Df5QI+ZVPq6bmdlAaCwQ== X-Received: by 2002:a17:902:dac5:b0:15e:8ba0:a73d with SMTP id q5-20020a170902dac500b0015e8ba0a73dmr28551468plx.22.1652336823205; Wed, 11 May 2022 23:27:03 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.114]) by smtp.gmail.com with ESMTPSA id gn21-20020a17090ac79500b001d903861194sm999748pjb.30.2022.05.11.23.26.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 May 2022 23:27:02 -0700 (PDT) From: menglong8.dong@gmail.com X-Google-Original-From: imagedong@tencent.com To: kuba@kernel.org Cc: nhorman@tuxdriver.com, davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, yoshfuji@linux-ipv6.org, dsahern@kernel.org, imagedong@tencent.com, kafai@fb.com, talalahmad@google.com, keescook@chromium.org, asml.silence@gmail.com, willemb@google.com, vasily.averin@linux.dev, ilias.apalodimas@linaro.org, luiz.von.dentz@intel.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next 4/4] net: tcp: reset skb drop reason to NOT_SPCIFIED in tcp_v4_rcv() Date: Thu, 12 May 2022 14:26:29 +0800 Message-Id: <20220512062629.10286-5-imagedong@tencent.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220512062629.10286-1-imagedong@tencent.com> References: <20220512062629.10286-1-imagedong@tencent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Menglong Dong The 'drop_reason' that passed to kfree_skb_reason() in tcp_v4_rcv() can be SKB_NOT_DROPPED_YET(0), as it is used as the return value of tcp_inbound_md5_hash(). And it can panic the kernel with NULL pointer in net_dm_packet_report_size() if the reason is 0, as drop_reasons[0] is NULL. Fixes: 1330b6ef3313 ("skb: make drop reason booleanable") Signed-off-by: Menglong Dong --- net/ipv4/tcp_ipv4.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 918816ec5dd4..24eb42497a71 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -2101,6 +2101,7 @@ int tcp_v4_rcv(struct sk_buff *skb) } discard_it: + SKB_DR_OR(drop_reason, NOT_SPECIFIED); /* Discard frame. */ kfree_skb_reason(skb, drop_reason); return 0;