Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp935419rwb; Wed, 28 Sep 2022 10:54:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4B6gX/Uaworz7Ikt4SsJlA/Adq+0BNk3iqjSS+WL+26Q7iqbjGAM2X7oHejgBtsioExWzl X-Received: by 2002:a17:902:dad2:b0:178:401c:f66d with SMTP id q18-20020a170902dad200b00178401cf66dmr928697plx.157.1664387689095; Wed, 28 Sep 2022 10:54:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664387689; cv=none; d=google.com; s=arc-20160816; b=IhU0tIKl0IiIWVdEHd4RZuYZdcYVP9Hd+bGYEBcex599JOZC9G1fssN8e9DUBnz4Ro uuOMvAaVerd9bkGb5qEnDziMJEisYwzkbeds1oL1FtKz+qLhM15/jw04TBNEdoe25WPZ Evg8nej3Lwt6wT6etSOuCwfEdW94zrHfIHVjmavBBGOYR0Ko5LpC8D4uNWTYtTBzpTS6 o5FRefBRjaJQOLWHrBU/RNB4a8TAD6Pl7xEQW0A6+V9u4zfuDkdhJ3d8PCX9RqFb26Q6 q2c4O3HjTTBi2A58UQRaOGBAJyWz8a5LAST9CT1zocD5S0Q/Jys1DEfqt6ixBPq1w4vN d5gA== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=d6n7vVcWWAUhY50nx1oX+SjTLgFqeY1Yq8iTalyfqd0=; b=yWCWG0CzwjR195ks3jNQTg6J2VZNjO9m83SBAURu/frOq92HGSqAckfk1noYLN8+as DW1Bzvy7k7ZiGYLoDikj/7K8sW1p3Mnwu9qi6BEtjYS0E+BduBbn+Posqs2lT4IG6jOW CL4Dan1TwaCxap4cJQFK4aDksmLMxOrEoVX4pfJEg/vcsSzeuxoWQx3AofaUqpLBhUvA 5B/SY5+CL3OxNmJY/vmIgM4RT+v/55nu1mxjmzYRYHI5C8++xbDGvfzMgCGrgtI84XrT UQZy7ojNXwg6WRHHJsAmmm1BkuYz53zQrZzWyqBYrFT4lEXrjDaB2gq+ud6MFy1o9z1k CReA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=lIRHIZiW; 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=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c1-20020a6566c1000000b00439ac9ab8d3si5775108pgw.113.2022.09.28.10.54.37; Wed, 28 Sep 2022 10:54:49 -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=@chromium.org header.s=google header.b=lIRHIZiW; 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=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234530AbiI1RON (ORCPT + 99 others); Wed, 28 Sep 2022 13:14:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234488AbiI1RNp (ORCPT ); Wed, 28 Sep 2022 13:13:45 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89D1EF1856 for ; Wed, 28 Sep 2022 10:13:15 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id h8-20020a17090a054800b00205ccbae31eso3159006pjf.5 for ; Wed, 28 Sep 2022 10:13:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date; bh=d6n7vVcWWAUhY50nx1oX+SjTLgFqeY1Yq8iTalyfqd0=; b=lIRHIZiWHITqRmakxRZHSG2SU2bpWinoR3Swar+fPYJBmT1qOO/MT6WnWN5yBDlhGu /lQXgjvlz0O4V2+hnYy+98Yh09p4wB3YUjZ22bnBWEa9dMSwUm7gVI6Ae5kXcacwBn8L BoOjiPYblWsCdJGhH6goLGXzHmU5/JoB80oyI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date; bh=d6n7vVcWWAUhY50nx1oX+SjTLgFqeY1Yq8iTalyfqd0=; b=c614Q7tnAkRUtbTujMVAYmbsI+JEK523oo4s59lMCvI1EKWK20AWL5Vo5pLcmsXGgg ic4UQhEYYEdREMvsNWXa1pbBdtxpwXPMiO3KAQ1RykjWsGfLy0la4f7Myl6gyf/2lSne 9Fw0eRpkevm21siavoLJLgzcL8V56eYCJVcraLBwgOHTAKN4N/R7+pnlZU4JexqLsKru kNsEKwU1IB75yHMrv81IztcWTVWHz16TeS2t/S17KmeXHEG8o6QO+uzTV1DI2YdIx/U8 uxQ4w+pWETwTohy6sWNP7ReFYjvdsdZMFsqWv5bpuo1XmGYXYhJV6jAykxU9W3iW6Ym5 NXZw== X-Gm-Message-State: ACrzQf295qD2aFW8R/r9y/iZvINmwCi9FYL0g/s5o1f2yHifQrDjHID5 Zr8RPmmJADDPjwJoBPuGRjaCMw== X-Received: by 2002:a17:902:db08:b0:176:d40e:4b57 with SMTP id m8-20020a170902db0800b00176d40e4b57mr799977plx.172.1664385194575; Wed, 28 Sep 2022 10:13:14 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id q3-20020a170902dac300b00177faf558b5sm4082449plx.250.2022.09.28.10.13.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 10:13:13 -0700 (PDT) Date: Wed, 28 Sep 2022 10:13:12 -0700 From: Kees Cook To: Geert Uytterhoeven Cc: 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 , Christian =?iso-8859-1?Q?K=F6nig?= , 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 Subject: Re: [PATCH v2 01/16] slab: Remove __malloc attribute from realloc functions Message-ID: <202209281011.66DD717D@keescook> References: <20220923202822.2667581-1-keescook@chromium.org> <20220923202822.2667581-2-keescook@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 Wed, Sep 28, 2022 at 09:26:15AM +0200, Geert Uytterhoeven wrote: > Hi Kees, > > On Fri, Sep 23, 2022 at 10:35 PM Kees Cook wrote: > > The __malloc attribute should not be applied to "realloc" functions, as > > the returned pointer may alias the storage of the prior pointer. Instead > > of splitting __malloc from __alloc_size, which would be a huge amount of > > churn, just create __realloc_size for the few cases where it is needed. > > > > 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 ‘__alloc_reserved_percpu’: > ././include/linux/compiler_types.h:279:30: error: expected > declaration specifiers before ‘__alloc_size__’ > #define __alloc_size(x, ...) __alloc_size__(x, ## __VA_ARGS__) __malloc > ^~~~~~~~~~~~~~ > ./include/linux/percpu.h:120:74: note: in expansion of macro ‘__alloc_size’ > [...] > > It's building fine with e.g. gcc-9 (which is my usual m68k cross-compiler). > 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/1bd8b75fe6adeaa89d02968bdd811ffe708cf839/ Eek! Thanks for letting me know. I'm confused about this -- __alloc_size__ wasn't optional in compiler_attributes.h -- but obviously I broke something! I'll go figure this out. -Kees -- Kees Cook