Message ID | 20221013112825.61869-1-avromanov@sberdevices.ru |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp222336wrs; Thu, 13 Oct 2022 04:36:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5EaB+HMyKXquPBnl18l9p3C8T1GLotdzTa+E1w8TIDMF2at4Lk6RAx9pMvTDdKbsmPjmpF X-Received: by 2002:a17:907:2e01:b0:78d:f24b:7330 with SMTP id ig1-20020a1709072e0100b0078df24b7330mr6390967ejc.604.1665661005935; Thu, 13 Oct 2022 04:36:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665661005; cv=none; d=google.com; s=arc-20160816; b=RDbFI22TE4PeCe5+3AFy9qhrTSZEyGfOXV6hCJCmMfUChlR69bhzBt6OTaoM91gbrT TDLJEPBiWk4Bm8NMTlsEzW+CUs1ukvZLyC0ci/9O9b3R1Vf3WFyrud9TUlSmfNum935o I8jbCgr4Ygiu+CRCUqLB/h07UTR8u9NIVH/6S2gJowgEYkLIsXyglkcs3Pl02efNH42n pwE+FlhzjSbnyMZDE0Ke5ED5KJYDW2gUPEvs7jPEt0+/GUtcnhICdvX0jPRD8zl33wO2 FR4TYy+AVuCprbF301HPyQjANLobP+JTgw6Z/CrCKp0CcGEi5cLg1CIJKn14h4yrwZVo 5CmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=I+EwayS2mXiTVYC1YgiXzkHmIUayGLlFvMVLY98UxeQ=; b=nkcmbGUQoxjItHw/C12T2K61L6spzEMNys7VxQ2Apx+Bra/ddzotfal8fXmBKLE3Rw P5CTUPCj9for3hbObdfHr8x1JB/TqGaIgTcozQclqgsucMaLN/hFiRJn19VrokcwqMOB I2GJoZ8p1/g0b5wp8/NalLP4HltbnA7+P87N0uraDe89+2c3faxbozmrNz5uVD2jq0uA zGNu7qpXJm1346FR217zL9WvKXjn0dtTJbgxjFro8NEdNwoTyTrrCod8zq10+DGypoN5 b/jXpCmKYOPyzBEEEsaq5fp+J4Lsh0ZH4v1cQzzR8xvmkJXVwV+FwCD9YR0T1mRnr7uY l7lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=W0aYpoC6; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sberdevices.ru Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nd16-20020a170907629000b0077bc1269f8esi18910259ejc.424.2022.10.13.04.36.18; Thu, 13 Oct 2022 04:36:45 -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=@sberdevices.ru header.s=mail header.b=W0aYpoC6; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sberdevices.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229815AbiJML2x (ORCPT <rfc822;ouuuleilei@gmail.com> + 99 others); Thu, 13 Oct 2022 07:28:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229711AbiJML2r (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 13 Oct 2022 07:28:47 -0400 Received: from mail.sberdevices.ru (mail.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13AC6125853 for <linux-kernel@vger.kernel.org>; Thu, 13 Oct 2022 04:28:39 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mail.sberdevices.ru (Postfix) with ESMTP id 27F155FD02; Thu, 13 Oct 2022 14:28:36 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1665660516; bh=I+EwayS2mXiTVYC1YgiXzkHmIUayGLlFvMVLY98UxeQ=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=W0aYpoC6nbXXubmUlI+Q9zdZHp9twEt3VMTvrO6o9Sa6TzimBpUS3j0ZtcRFhaQJQ QPEBgCXZnX8CpIFvtcEFLxcdJxMpb/xmRO0tR2PKukmgjbJG15j9SqzC86A1b1DcCe A6nVMambHSTvzdmnPyRzd2ucbNwVyD/eAQS22mueZ15uw/mfTPHTIKBqgsijt2xfxV wRH06UbZ7WwAY5hF4Uvpd18VEIzVTa+r32aNIsXjk7dB8yTdEjkG4rRwk5O7MIP6Ci 4FgNIddcFShvX4FPmMigDdUFSddiFq3/i0B9UmHP+Ac3cjv4onKeKgcMVHIg0YQEfO X0czXvbfkodIA== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mail.sberdevices.ru (Postfix) with ESMTP; Thu, 13 Oct 2022 14:28:34 +0300 (MSK) From: Alexey Romanov <avromanov@sberdevices.ru> To: <minchan@kernel.org>, <senozhatsky@chromium.org>, <ngupta@vflare.org>, <akpm@linux-foundation.org> CC: <linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>, <kernel@sberdevices.ru>, Alexey Romanov <avromanov@sberdevices.ru> Subject: [PATCH v1] zsmalloc: zs_destroy_pool: add size_class NULL check Date: Thu, 13 Oct 2022 14:28:25 +0300 Message-ID: <20221013112825.61869-1-avromanov@sberdevices.ru> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.16.1.6] X-ClientProxiedBy: S-MS-EXCH02.sberdevices.ru (172.16.1.5) To S-MS-EXCH01.sberdevices.ru (172.16.1.4) X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2022/10/13 08:08:00 #20452392 X-KSMG-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746572155049035311?= X-GMAIL-MSGID: =?utf-8?q?1746572155049035311?= |
Series |
[v1] zsmalloc: zs_destroy_pool: add size_class NULL check
|
|
Commit Message
Alexey Romanov
Oct. 13, 2022, 11:28 a.m. UTC
Inside the zs_destroy_pool() function, there can still
be NULL size_class pointers: if when the next size_class is
allocated, inside zs_create_pool() function, kzalloc will
return NULL and handling the error condition, zs_create_pool()
will call zs_destroy_pool().
Fixes: f24263a5a076 ("zsmalloc: remove unnecessary size_class NULL check")
Signed-off-by: Alexey Romanov <avromanov@sberdevices.ru>
---
mm/zsmalloc.c | 3 +++
1 file changed, 3 insertions(+)
Comments
On (22/10/13 14:28), Alexey Romanov wrote: > Inside the zs_destroy_pool() function, there can still > be NULL size_class pointers: if when the next size_class is > allocated, inside zs_create_pool() function, kzalloc will > return NULL and handling the error condition, zs_create_pool() > will call zs_destroy_pool(). > > Fixes: f24263a5a076 ("zsmalloc: remove unnecessary size_class NULL check") > Signed-off-by: Alexey Romanov <avromanov@sberdevices.ru> > --- > mm/zsmalloc.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c > index 525758713a55..d03941cace2c 100644 > --- a/mm/zsmalloc.c > +++ b/mm/zsmalloc.c > @@ -2311,6 +2311,9 @@ void zs_destroy_pool(struct zs_pool *pool) > int fg; > struct size_class *class = pool->size_class[i]; > > + if (!class) > + continue; > + > if (class->index != i) > continue; Yeah, OK... And totally my fault! I think, I, personally, am done with the "remove if" patches at this point, they are too painful. Alexey, is there anything else we missed? FWIW, Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org> Andrew, The allocation in question should be of a "too small to fail" size, below PAGE_ALLOC_COSTLY_ORDER. So unless that unspoken rule has changed, we should be "fine", since that kmalloc() simply should not fail. It still makes sense to have that particular check in place, just in case. Can you please pull this patch in? And, like I said, I'm going to NAK all future micro-optimizations.
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 525758713a55..d03941cace2c 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -2311,6 +2311,9 @@ void zs_destroy_pool(struct zs_pool *pool) int fg; struct size_class *class = pool->size_class[i]; + if (!class) + continue; + if (class->index != i) continue;