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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0858C04A95 for ; Thu, 29 Sep 2022 09:00:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2F36D8D0001; Thu, 29 Sep 2022 05:00:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2A2DF6B0074; Thu, 29 Sep 2022 05:00:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 16AA58D0001; Thu, 29 Sep 2022 05:00:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 0513B6B0073 for ; Thu, 29 Sep 2022 05:00:46 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 8AEA3C11D0 for ; Thu, 29 Sep 2022 09:00:45 +0000 (UTC) X-FDA: 79964527650.11.2E5ECB4 Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) by imf26.hostedemail.com (Postfix) with ESMTP id 3488F140011 for ; Thu, 29 Sep 2022 09:00:43 +0000 (UTC) Received: by mail-qt1-f172.google.com with SMTP id w2so379678qtv.9 for ; Thu, 29 Sep 2022 02:00:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date; bh=Ir+IzupNAXvXvPBkZ1yh/qacu5xVXDJ2KC3L3ZMV+D4=; b=E+UOG+MZm/la60TPRPMNSmn+KGAxCEvt6oNAte3eyCkrif5q5HHidjN/I2/ByjqNRD 4YtnEvFjBd343rsPa5g1JWUkp1hEsbw5d52bO0dgKNj0hv77l+uQBSJmmDSzG+ZhlUpr tg7S2GpD/lBaulcHDxx5Ahw/JM1edIWdYixR6U7EpFK6nlqwe4Fpf2DKf4Kf+7lhutaH uPh+bpHlYBOO4xYOIKuthSVdZ16eCz6BmCoKSEfFZJl1ZUmftbgSCEhBuS6BskSjFOV4 EnxzTPIGxYlkWEA47+34gTMOIivK779LRa/bSAcOdbGNNnXsXYZHafcK0Ug8xHHCtz7+ ohJg== X-Gm-Message-State: ACrzQf2OilKSENvFDJfftkJC7UUxd62fltbJjCg/c1Y1GFQNmv53WyKq FDWp0zep0hXo7ZG0b+Fr8NFEvkkrUf1Dlg== X-Google-Smtp-Source: AMsMyM5IpT8Q/0FEUNSEgP8wqgLiDAhm0wCq9NHuKkH7ncb/oKuz9VwUI6y3TkGmDpVtSikpj+bjHA== X-Received: by 2002:a05:622a:64b:b0:35d:5860:ea86 with SMTP id a11-20020a05622a064b00b0035d5860ea86mr1425186qtb.277.1664442043125; Thu, 29 Sep 2022 02:00:43 -0700 (PDT) Received: from mail-yb1-f178.google.com (mail-yb1-f178.google.com. [209.85.219.178]) by smtp.gmail.com with ESMTPSA id e23-20020ac84157000000b0031eb5648b86sm5322100qtm.41.2022.09.29.02.00.41 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Sep 2022 02:00:41 -0700 (PDT) Received: by mail-yb1-f178.google.com with SMTP id f189so736168yba.12 for ; Thu, 29 Sep 2022 02:00:41 -0700 (PDT) X-Received: by 2002:a5b:104:0:b0:6b0:429:3fe9 with SMTP id 4-20020a5b0104000000b006b004293fe9mr2016091ybx.543.1664442041163; Thu, 29 Sep 2022 02:00:41 -0700 (PDT) MIME-Version: 1.0 References: <20220923202822.2667581-1-keescook@chromium.org> <20220923202822.2667581-2-keescook@chromium.org> <202209281011.66DD717D@keescook> <874jwqfuh6.fsf@mpe.ellerman.id.au> In-Reply-To: <874jwqfuh6.fsf@mpe.ellerman.id.au> From: Geert Uytterhoeven Date: Thu, 29 Sep 2022 11:00:28 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 01/16] slab: Remove __malloc attribute from realloc functions To: Michael Ellerman Cc: Kees Cook , Vlastimil Babka , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Marco Elver , linux-mm@kvack.org, "Ruhl, Michael J" , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Greg Kroah-Hartman , Nick Desaulniers , Alex Elder , Josef Bacik , David Sterba , Sumit Semwal , =?UTF-8?Q?Christian_K=C3=B6nig?= , Jesse Brandeburg , Daniel Micay , Yonghong Song , Miguel Ojeda , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-fsdevel@vger.kernel.org, intel-wired-lan@lists.osuosl.org, dev@openvswitch.org, x86@kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664442044; a=rsa-sha256; cv=none; b=2OoNIFC60w+QKys16M8brDkY93GrLL0miSoY9SthXw1lDdGsMLY5SfjxhjEZI0qrpv7F8v saIblS06UQb7UO3hWQ3ZLZOm7ye5pPjjPZITfP5L2pnRedqkFjxFLHCW6PbfJlDFIbK4YK ah14wPI8wB4ZCuoESKtWdERadkKLr2E= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf26.hostedemail.com: domain of geert.uytterhoeven@gmail.com designates 209.85.160.172 as permitted sender) smtp.mailfrom=geert.uytterhoeven@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664442044; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ir+IzupNAXvXvPBkZ1yh/qacu5xVXDJ2KC3L3ZMV+D4=; b=kIOL7+uIPnWk+DVwioxSF+JrMrmmEUpz1YJtt1S/ecTC1YeS/asOyPQ+jAbsZxeLQosmtl AYeSTw2Lrqwm7m+XnUqJD4cXKLVceAWe982VL/Rg54TOWjcHFturpNCmmXPtvsvQi2CsfB kYz6LmmEbL7pGDSMvP1I6jE+Sl/jh8E= X-Stat-Signature: b6zimfizf6a6rzzb6u3nsf4cwcc36f7x X-Rspamd-Queue-Id: 3488F140011 X-Rspamd-Server: rspam04 Authentication-Results: imf26.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf26.hostedemail.com: domain of geert.uytterhoeven@gmail.com designates 209.85.160.172 as permitted sender) smtp.mailfrom=geert.uytterhoeven@gmail.com X-Rspam-User: X-HE-Tag: 1664442043-575787 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: Hi Michael, On Thu, Sep 29, 2022 at 10:36 AM Michael Ellerman wrot= e: > Kees Cook writes: > > On Wed, Sep 28, 2022 at 09:26:15AM +0200, Geert Uytterhoeven wrote: > >> On Fri, Sep 23, 2022 at 10:35 PM Kees Cook wro= te: > >> > The __malloc attribute should not be applied to "realloc" functions,= as > >> > the returned pointer may alias the storage of the prior pointer. Ins= tead > >> > of splitting __malloc from __alloc_size, which would be a huge amoun= t of > >> > churn, just create __realloc_size for the few cases where it is need= ed. > >> > > >> > Additionally removes the conditional test for __alloc_size__, which = is > >> > always defined now. > >> > > >> > Cc: Christoph Lameter > >> > Cc: Pekka Enberg > >> > Cc: David Rientjes > >> > Cc: Joonsoo Kim > >> > Cc: Andrew Morton > >> > Cc: Vlastimil Babka > >> > Cc: Roman Gushchin > >> > Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com> > >> > Cc: Marco Elver > >> > Cc: linux-mm@kvack.org > >> > Signed-off-by: Kees Cook > >> > >> Thanks for your patch, which is now commit 63caa04ec60583b1 ("slab: > >> Remove __malloc attribute from realloc functions") in next-20220927. > >> > >> Noreply@ellerman.id.au reported all gcc8-based builds to fail > >> (e.g. [1], more at [2]): > >> > >> In file included from : > >> ./include/linux/percpu.h: In function =E2=80=98__alloc_reserved_pe= rcpu=E2=80=99: > >> ././include/linux/compiler_types.h:279:30: error: expected > >> declaration specifiers before =E2=80=98__alloc_size__=E2=80=99 > >> #define __alloc_size(x, ...) __alloc_size__(x, ## __VA_ARGS__) __= malloc > >> ^~~~~~~~~~~~~~ > >> ./include/linux/percpu.h:120:74: note: in expansion of macro =E2= =80=98__alloc_size=E2=80=99 > >> [...] > >> > >> It's building fine with e.g. gcc-9 (which is my usual m68k cross-compi= ler). > >> Reverting this commit on next-20220927 fixes the issue. > >> > >> [1] http://kisskb.ellerman.id.au/kisskb/buildresult/14803908/ > >> [2] http://kisskb.ellerman.id.au/kisskb/head/1bd8b75fe6adeaa89d02968bd= d811ffe708cf839/ > > > > Eek! Thanks for letting me know. I'm confused about this -- > > __alloc_size__ wasn't optional in compiler_attributes.h -- but obviousl= y > > I broke something! I'll go figure this out. > > This fixes it for me. Kees submitted a similar patch 20 minutes before: https://lore.kernel.org/all/20220929081642.1932200-1-keescook@chromium.org > --- a/include/linux/compiler_types.h > +++ b/include/linux/compiler_types.h > @@ -275,8 +275,13 @@ struct ftrace_likely_data { > * be performing a _reallocation_, as that may alias the existing pointe= r. > * For these, use __realloc_size(). > */ > -#define __alloc_size(x, ...) __alloc_size__(x, ## __VA_ARGS__) __mallo= c > -#define __realloc_size(x, ...) __alloc_size__(x, ## __VA_ARGS__) > +#ifdef __alloc_size__ > +# define __alloc_size(x, ...) __alloc_size__(x, ## __VA_ARGS__) __mallo= c > +# define __realloc_size(x, ...) __alloc_size__(x, ## __VA_ARGS__) > +#else > +# define __alloc_size(x, ...) __malloc > +# define __realloc_size(x, ...) > +#endif > > #ifndef asm_volatile_goto > #define asm_volatile_goto(x...) asm goto(x) Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k= .org In personal conversations with technical people, I call myself a hacker. Bu= t when I'm talking to journalists I just say "programmer" or something like t= hat. -- Linus Torvalds