From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F66AC433B4 for ; Thu, 13 May 2021 03:12:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E3380613FB for ; Thu, 13 May 2021 03:12:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E3380613FB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 54F5E6B0036; Wed, 12 May 2021 23:12:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4D9A96B006E; Wed, 12 May 2021 23:12:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 32B976B0070; Wed, 12 May 2021 23:12:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0082.hostedemail.com [216.40.44.82]) by kanga.kvack.org (Postfix) with ESMTP id F16646B0036 for ; Wed, 12 May 2021 23:12:27 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 9B382B9EB for ; Thu, 13 May 2021 03:12:27 +0000 (UTC) X-FDA: 78134734734.30.4593654 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by imf02.hostedemail.com (Postfix) with ESMTP id 7F73240002F7 for ; Thu, 13 May 2021 03:11:53 +0000 (UTC) Received: by mail-pf1-f176.google.com with SMTP id a5so13360075pfa.11 for ; Wed, 12 May 2021 20:12:27 -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=k5MpPYekuKpSay9luzRshdNrd49caNx1oHfOjwSd+gKI3D9I4ahw1UAr0UvVsHkVyF N4XLlBlWQ3wOf8pg3pSJarsvKeUoDGWpju4xKvnaYx6tBBFqGo6nGcFEYfzO0opyfURQ tGSySuuD+/14bUQDGlnOSyE+85nrV+Ya/Fw46OdAyLnQ+BezEawG8D5JNzE7a62RhJBN itwW2hwv+xVtopcjb2n9JjbLOkTKJc+9Ks0fK+53ya4pSrHct+/5EHwfy7n89c/R8NcN tBRp+C2jediNAFEbIGCrwM/TqTV3oDdC7RAMzeYoV/KpJAfxdkv4QxdRqWrWIjLJQgzV WEBw== X-Gm-Message-State: AOAM5313cJLTvPCYt0NWIblA/EqmbQ64QJpizhzg5SL7TOkvqZE4MfQk DrzXggP1hc6Td4cgK27LqfU= X-Google-Smtp-Source: ABdhPJzStzG/udPZzt469bOoqFcBL73cSbisYcGoO+yQpZx+qdgmsOKXlt8LoDRNYLiKXovFhdvXlw== 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> X-Rspamd-Queue-Id: 7F73240002F7 Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=hLIBicSa; spf=pass (imf02.hostedemail.com: domain of 42hyeyoo@gmail.com designates 209.85.210.176 as permitted sender) smtp.mailfrom=42hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam04 X-Stat-Signature: d13od8pgpsbbmzufwpjqederctyzr3m4 Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf02; identity=mailfrom; envelope-from="<42.hyeyoo@gmail.com>"; helo=mail-pf1-f176.google.com; client-ip=209.85.210.176 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620875513-896477 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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.