Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5036115pxj; Wed, 12 May 2021 20:14:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzd7a0Kjt4+Cp4sYXpMR78CntMN850IhBrJpovFX2U5g8J9adeiq3PksCthJopyXuiz5vNl X-Received: by 2002:a17:906:8904:: with SMTP id fr4mr41662234ejc.146.1620875648198; Wed, 12 May 2021 20:14:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620875648; cv=none; d=google.com; s=arc-20160816; b=SHCry9V2j6YQ1lSPVgeuOUxhdniysHSzJquppfSU6jefWe5XIRdFp6a6QKqC31m7by s+OOiCmUIEAeItKbfhpAjS6p7dgp9x5LW+JZWKY5CylDj3oM2o7/Xy0nfubMuM75TTyb Rtn9Ttu8YzwXV+IF/WkQRaWLXfasMJbdug6UGWIIjK4RDWDe8O5aSz/MOfU3jX/ypFFQ +Ee743LKEC/DPCU0X8RvAJvmPuVq96cSI+mwoq/WwtWScAj2EJf9ThuXr38B6A748Hso w6k24DQ7fU67YA8aKM2mCUltmTUFRCXNGugegIk9nnzm5BGLbf9CJmF8w4G9d37xp3xy KsYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=SS5OHlXmmSNON5KatgyYnmlWm3dX+R80ppvdDgNsI1I=; b=IGxgtLOiULANHOlYhyPvpfL0FPCTD8xBNAloNs7sFXMomnMQ+bhFQkzHDF2IqWSCZl WGbTlENkWUJd2z0pmYYAVZyUY8Lz0zwVEpR5ddSdItfGvBHC6qOAnVC8gMdZGXGY1GXS kvv+If+AxIsPo4cFhLeC6hnqb8HHrKLr+xrK/1fJbdT7uQO6Zcg9Abr/hSqkJiuRVG8M bpSWA/N0cS12Hs3BtYhqAL0NyQDk2hEhfNaye7R7OrmwvmcBskkJa7HKQsdlZhNdlo5b xAqZTbB65L6uCRiZCzksl9YY1Bq41bWYuMH+CaacMFr8dq0Lil3u3xtuMS77yDlCoq7c MuFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hLIBicSa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y8si1817869edw.231.2021.05.12.20.13.20; Wed, 12 May 2021 20:14:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hLIBicSa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S230405AbhEMDNh (ORCPT + 99 others); Wed, 12 May 2021 23:13:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230186AbhEMDNg (ORCPT ); Wed, 12 May 2021 23:13:36 -0400 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3645C061574 for ; Wed, 12 May 2021 20:12:26 -0700 (PDT) Received: by mail-pg1-x536.google.com with SMTP id i5so15252287pgm.0 for ; Wed, 12 May 2021 20:12:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=SS5OHlXmmSNON5KatgyYnmlWm3dX+R80ppvdDgNsI1I=; b=hLIBicSaBf1Lm6AE3HsEV8jzzJrDDMDzlf/h+lonjSqFXlkDEDMYFWoikLpcOvu7Rl jIfWTCGeYZnBaztMzq7peZ/CDhAxMO7k9jDtmlBEcD9BkrtMb2jk1YAewJ6/KKFudNh7 uqNioDipTn0ALysnZwqT6Tu55SZQTEz8L670sO15O9io4BpvQUQn5rzP0sw4cVs57xUs oGO44BTcbVanHwZA5KZLiY68tT/VjDFbWx3qEJPKZX1HxYLNS1pkxFj4FbQ4klf6fltU Xb3zQo59EwfsZsGk0fKP8iv6pOfyn4DcH1UD3oQdnqdUDqm3z8Y5YKO57BPtYKLK0soi jZxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=SS5OHlXmmSNON5KatgyYnmlWm3dX+R80ppvdDgNsI1I=; b=AOcxgQ1G2BdzLTBHtb8MqqWhAgTuGn78TQ6PhTwpON9tD3W+GDrBG3baEino6p3hWJ 0NKrsQlvSRvSE2r0iZktbHZsbCqLMx+0kwRphl9VOFNkFa2FZhhavSNrVuF+PzWjxKQG 3qjIBMvRchUB83fm2giud2tKGfBZ0LJrrgWyxWynVpF74qNJ7PX/k3t6OBaGSz+a4UuO iDSBFoPdPq6ClI+EFf4hQLUJHVIcl2X410eckHke35zBFJ0Liz9bfJueSx/8S4QJhBgY 8/lbTOWcA+oACqPcaR2fqumeUxSuecZV8IBsNZUYuTuNgmtsvzV4OuwsrBvYqbQ9KlKa R8ow== X-Gm-Message-State: AOAM533D6CoOY6pxF6l8H967aKMTO56YGyRABYxYTmMU7S2T7E6tmeov Lw/uQ+oApvkcWptQIrxjjlY= X-Received: by 2002:a62:ce8c:0:b029:28e:cc4c:3b7e with SMTP id y134-20020a62ce8c0000b029028ecc4c3b7emr38109419pfg.67.1620875546300; Wed, 12 May 2021 20:12:26 -0700 (PDT) Received: from hyeyoo ([183.99.11.150]) by smtp.gmail.com with ESMTPSA id x6sm874969pfu.120.2021.05.12.20.12.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 May 2021 20:12:26 -0700 (PDT) Date: Thu, 13 May 2021 12:12:20 +0900 From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Andrew Morton Cc: vbabka@suse.cz, iamjoonsoo.kim@lge.com, rientjes@google.com, penberg@kernel.org, cl@linux.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Marco Elver Subject: Re: [PATCH v3] mm, slub: change run-time assertion in kmalloc_index() to compile-time Message-ID: <20210513031220.GA133011@hyeyoo> References: <20210511173448.GA54466@hyeyoo> <20210512195227.245000695c9014242e9a00e5@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210512195227.245000695c9014242e9a00e5@linux-foundation.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 12, 2021 at 07:52:27PM -0700, Andrew Morton wrote: > This explodes in mysterious ways. The patch as I have it is appended, > for reference. > > gcc-10.3.0 allmodconfig. > > This patch suppresses the error: > > --- a/mm/kfence/kfence_test.c~a > +++ a/mm/kfence/kfence_test.c > @@ -318,13 +318,13 @@ static void test_out_of_bounds_read(stru > > /* Test both sides. */ > > - buf = test_alloc(test, size, GFP_KERNEL, ALLOCATE_LEFT); > + buf = test_alloc(test, 32, GFP_KERNEL, ALLOCATE_LEFT); > expect.addr = buf - 1; > READ_ONCE(*expect.addr); > KUNIT_EXPECT_TRUE(test, report_matches(&expect)); > test_free(buf); > > - buf = test_alloc(test, size, GFP_KERNEL, ALLOCATE_RIGHT); > + buf = test_alloc(test, 32, GFP_KERNEL, ALLOCATE_RIGHT); > expect.addr = buf + size; > READ_ONCE(*expect.addr); > KUNIT_EXPECT_TRUE(test, report_matches(&expect)); > @@ -519,11 +519,11 @@ static void test_free_bulk(struct kunit > const size_t size = setup_test_cache(test, 8 + prandom_u32_max(300), 0, > (iter & 1) ? ctor_set_x : NULL); > void *objects[] = { > - test_alloc(test, size, GFP_KERNEL, ALLOCATE_RIGHT), > - test_alloc(test, size, GFP_KERNEL, ALLOCATE_NONE), > - test_alloc(test, size, GFP_KERNEL, ALLOCATE_LEFT), > - test_alloc(test, size, GFP_KERNEL, ALLOCATE_NONE), > - test_alloc(test, size, GFP_KERNEL, ALLOCATE_NONE), > + test_alloc(test, 32, GFP_KERNEL, ALLOCATE_RIGHT), > + test_alloc(test, 32, GFP_KERNEL, ALLOCATE_NONE), > + test_alloc(test, 32, GFP_KERNEL, ALLOCATE_LEFT), > + test_alloc(test, 32, GFP_KERNEL, ALLOCATE_NONE), > + test_alloc(test, 32, GFP_KERNEL, ALLOCATE_NONE), > }; > > kmem_cache_free_bulk(test_cache, ARRAY_SIZE(objects), objects); > > > Is gcc-10.3.0 simply confused? test_out_of_bounds_read() is clearly > calling kmalloc_index(32) which is OK. > > Anyway, I'll drop this patch for now so I can compile a kernel! > The error messages isn't so clear to me. but one problem I can see is in kfence_test.c, there are many places that are using size which is not constant. in kmalloc if size is not constant, it calls dummy function __kmalloc which does not make use of size.