Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp365219rwe; Thu, 1 Sep 2022 00:14:11 -0700 (PDT) X-Google-Smtp-Source: AA6agR5K531V9SsW3WbczVcrOh8pLVGIBiK1NfOWr69zrypwbQWR2jIONZTXLkzOH6jCyEC79yNg X-Received: by 2002:a17:906:5a5a:b0:741:559f:f539 with SMTP id my26-20020a1709065a5a00b00741559ff539mr15588930ejc.3.1662016451027; Thu, 01 Sep 2022 00:14:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662016451; cv=none; d=google.com; s=arc-20160816; b=yUuTrDodClo9mZg2SsiY+mAWQ+CkJYk0g3UaT2GhBTeXP5WHPnO0bEfEp2OycyhGwN FvHiiMFTTR+9BzrR6qHFKK1GidetRGL5Hr79hCfQ783z9MjXkwIyXXD3GeSSzdxEcaRk Qk7rLmodRbZ5oYHAe5GXiYtMwT3+VUlaFfTTBDK+T0y07k5e1zlCelYQUaH2+N6XhSoG 2AsS56e7DTbHfaI+kxBhigzal3s9wMI885+N+BLml9fT+5B4FO0AkGdNcvE7RKkyqwUn mg0aWZ7Gnnx6+iA0xR9M5fO031dHtN2fWNl6KaF0+jjmYISHJpl3mSkfghAvsyUveuzh 8U4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=i383AFik6yhsG3iX8RnrTI6xwTdG+YMrBsOjo22c5D0=; b=pMs6QfdVc0Sl/q1SmfGR3I23W2J9jNJ5+9LUUwWFk1b8kzN40d9NiS9K0DoR+JGsCC 8pIoVJwUi/4n08ltk5Z9UB3dEedYQrDbne0+glKqYra8Wb9ftr5uCAfBZgvlfajqDZni pcPSqoKWAlofefUUCYnR+GTzZb/APOy4MJ2ye6obym82sy8YlzAuVMDuEiZx1tG3b9VP 6L63IPcnqpJWmoNZv7ClhUg7BM1uvKzRASF1aJ+4lP7q5MFVJ1wsFzv9j8koqAu5GAn8 r079Dieq6hQAPTGzNEVSUzLCL/HLwI5FzkICWWaAVSmPlIVa8VMV8s/O6NXXXteGLzV7 TK4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ffOiZdh+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q8-20020a056402518800b004479b1d0dbfsi1374173edd.205.2022.09.01.00.13.45; Thu, 01 Sep 2022 00:14:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ffOiZdh+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233431AbiIAHEh (ORCPT + 99 others); Thu, 1 Sep 2022 03:04:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233498AbiIAHEQ (ORCPT ); Thu, 1 Sep 2022 03:04:16 -0400 Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19CDB122697; Thu, 1 Sep 2022 00:04:05 -0700 (PDT) Received: by mail-io1-xd2c.google.com with SMTP id 10so13850935iou.2; Thu, 01 Sep 2022 00:04:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=i383AFik6yhsG3iX8RnrTI6xwTdG+YMrBsOjo22c5D0=; b=ffOiZdh+jXh3qPYSKprm0GZhBE7CDrzYPAQGXFDWZxwlLLJoNTCVqwXaGa5WgDKTc+ Zt5y/pM/SYacoDCtW6mw9azEBvAxi4fdA35C5FkYPeGmpcTjziE2SenK/l2HoxQiOGNr ZxMsJB2PPXzrzG/D0Pl2iCk4Qzy4f5mvBpklYarIMYp8BT6z46ZY2orBhMXiPLgBLllw DmiGxMcysqbSX5yDTHCD9RG2FGAuLbHT5ffTwngf1w2MPhIMCFKydng0pdQmx9Ltp0Xr UsJhcPwMDwFtaFZ7+57STIUQHRAv0/xwxOrHqRMrXGW8/SargF7R9f0ZKGU8H/6nkntA z/ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=i383AFik6yhsG3iX8RnrTI6xwTdG+YMrBsOjo22c5D0=; b=TRnQEpHUJqaDcjwdwI5e36jVt8wGjyprUoxPlQzlAEwfuu0glq8B/YNjffl8khqoaf KmIz67L+zSO7MnntETh+PJh6MN3cnJ8xiu37hE8/7A9qdt46EzryMGGrOVcp283CjhI4 nfRc7xcxDLDBpaDXaqPAY2QQN33XCCYw+kDzmE/zW5kbeha0VGUON3roT0AG/MMmx1gN CXcId/Rrp5pRdFBIM528UX/8PJuOAt2/beE+yjxOtBO1vwx6fwnElqCcXE/TKKTwmMHb lRmTPW4LzAkvQUg9oBlkEVmR+3GRAI/URNG2FQHdJyHTo8mxVmKovgOE+cmpYaxtlJSz W5lQ== X-Gm-Message-State: ACgBeo0FM5D/nS275o2kZaHCTPnlbP4Ba7fqO3qEjp/D6VMoyYQcRU3u jnLB138r3TZR/ldmpH0QdX70NdkzkaEGGFEJZp4= X-Received: by 2002:a6b:5f08:0:b0:688:9846:2f61 with SMTP id t8-20020a6b5f08000000b0068898462f61mr13831703iob.65.1662015845142; Thu, 01 Sep 2022 00:04:05 -0700 (PDT) MIME-Version: 1.0 References: <00000000000092839d0581fd74ad@google.com> <20220901040307.4674-1-khalid.masum.92@gmail.com> In-Reply-To: From: Khalid Masum Date: Thu, 1 Sep 2022 13:03:53 +0600 Message-ID: Subject: Re: [PATCH v3] xfrm: Update ipcomp_scratches with NULL if not allocated To: Herbert Xu Cc: "open list:NETWORKING [GENERAL]" , Linux Kernel Mailing List , syzkaller-bugs , Steffen Klassert , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel-mentees , Shuah Khan , syzbot+5ec9bb042ddfe9644773@syzkaller.appspotmail.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 1, 2022 at 10:18 AM Herbert Xu wrote: > > On Thu, Sep 01, 2022 at 10:03:07AM +0600, Khalid Masum wrote: > > > > diff --git a/net/xfrm/xfrm_ipcomp.c b/net/xfrm/xfrm_ipcomp.c > > index cb40ff0ff28d..3774d07c5819 100644 > > --- a/net/xfrm/xfrm_ipcomp.c > > +++ b/net/xfrm/xfrm_ipcomp.c > > @@ -203,6 +203,7 @@ static void ipcomp_free_scratches(void) > > vfree(*per_cpu_ptr(scratches, i)); > > > > free_percpu(scratches); > > + ipcomp_scratches = NULL; > > } > > Good catch! This is probably the root cause of all the crashes. > > > static void * __percpu *ipcomp_alloc_scratches(void) > > @@ -215,7 +216,7 @@ static void * __percpu *ipcomp_alloc_scratches(void) > > > > scratches = alloc_percpu(void *); > > if (!scratches) > > - return NULL; > > + return ipcomp_scratches = NULL; > > This is unnecessary as with your first hunk, ipcomp_scratches > is guaranteed to be NULL. > > Thanks, > -- You are right. Instead of setting it to NULL at both places, it makes more sense to do it when memory is freed. I shall send a v4 with the suggested change. thanks, -- Khalid Masum