Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1203363rwb; Wed, 28 Sep 2022 14:57:19 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6ONrb+dP2DtbGBnVI0mjpURUkGtKXKR7WQaJ3hrx8HsPpEsZv2sWa0lEggaz29mleeHzLJ X-Received: by 2002:a05:6a00:27a0:b0:54b:e645:d5d8 with SMTP id bd32-20020a056a0027a000b0054be645d5d8mr12717pfb.86.1664402239118; Wed, 28 Sep 2022 14:57:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664402239; cv=none; d=google.com; s=arc-20160816; b=eC68RuDD/oJ6chf1p3EyELYigy7S6DckojWv5+Dsi9tERlN6pvzHucxjMWvb0e09i2 7UUOgfI5CLwQ0PeKFkpnByrpbmLJVzt9HlHEzdOLqwnu6pDXil49Pn4VqbtXxvcICFj3 kKAg55PWro91mZo7P25DHh40LZ440EM99ekwdmRbITGlXvh7Ao1TlSxS8F5lPBmK61aL raX3mM9qNEt7y35vzgFU54YdWbJVdyDaaYeWGNIAM47wvgNS+cEEa3qIC0LnOrP0pYEq q1IrpCBaBT+l9tcJHEaXVeGIlFUrrN4nRtmaTqrxQ7Clhzpp04Wv/kUtV/CxlO/oHc3Z GFLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-signature; bh=C18vkSCkEp0R0j/E8doyhXlqBRc6MmmoczHaFz5Tq/o=; b=HfoBUSCk7PPCpy12yiKi9IOheRUII/T+6Cn5l6POL5fnfky4ezwzAJuWK12HhLXbNb TtTftTzZKeTeAN21jpUiL8glhd0WS/6yB/jdtQ6RfC9pl/FZYjCCp3pq6qbfTZ7uUhvu 0Fq9KY8gs5TgmYCrCpwJOHRDY7fIgRi8V+zuCJNytaKX/sisUxW/z/w9xNR3LoZdMh+a BstSk4JvYppCmmNlwXyBSHeueKwL1cmtoZkR0wVAUo4iZShhumjQB9vDD6uIfKnJaKSR EkoO2vawEQCOYisPGGmZ/ENvnDY02jBHDRFWSufS4qp8yE1wqa92xPhtXF7y1m4CTGSm hCNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=O8ZKN2zJ; dkim=neutral (no key) header.i=@suse.cz header.b=QuVwGzEY; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b8-20020a170903228800b0017829a3e7dcsi7710983plh.572.2022.09.28.14.57.08; Wed, 28 Sep 2022 14:57:19 -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=@suse.cz header.s=susede2_rsa header.b=O8ZKN2zJ; dkim=neutral (no key) header.i=@suse.cz header.b=QuVwGzEY; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233060AbiI1Vk4 (ORCPT + 99 others); Wed, 28 Sep 2022 17:40:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231949AbiI1Vky (ORCPT ); Wed, 28 Sep 2022 17:40:54 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38444AA367; Wed, 28 Sep 2022 14:40:51 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 19CC21F45F; Wed, 28 Sep 2022 21:40:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1664401248; h=from:from:reply-to: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=C18vkSCkEp0R0j/E8doyhXlqBRc6MmmoczHaFz5Tq/o=; b=O8ZKN2zJZST2anqWW6kCZ7PFlJtkR+DhFF/E1xFtpBjfMisY/NEE2VUHIT0ctG6+BRKpcm TFzItcWnIOwSwp96McUWnDjo0baCWUX3p/6aNYk16N1G1gVpmFAU0HxXjLM93Ltz5am9pC 6mcBPOCE9PClr4mk2WyQ3I6f95q7OjY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1664401248; h=from:from:reply-to: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=C18vkSCkEp0R0j/E8doyhXlqBRc6MmmoczHaFz5Tq/o=; b=QuVwGzEY77p785Z+8T99wXOp96mLv9PVymdpRO3H5bysX/SgsIeBkJWmKXpwJqWMN6hRxn P80vd3XHeULykLAg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id DA18F13A84; Wed, 28 Sep 2022 21:40:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id pwxsNF6/NGNaHwAAMHmgww (envelope-from ); Wed, 28 Sep 2022 21:40:46 +0000 Message-ID: Date: Wed, 28 Sep 2022 23:39:06 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Subject: Re: [PATCH v2 01/16] slab: Remove __malloc attribute from realloc functions Content-Language: en-US To: Kees Cook , Geert Uytterhoeven Cc: 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 References: <20220923202822.2667581-1-keescook@chromium.org> <20220923202822.2667581-2-keescook@chromium.org> <202209281011.66DD717D@keescook> From: Vlastimil Babka In-Reply-To: <202209281011.66DD717D@keescook> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, 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: X-Mailing-List: linux-kernel@vger.kernel.org On 9/28/22 19:13, Kees Cook wrote: > 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. Even in latest next I can see at the end of include/linux/compiler-gcc.h /* * Prior to 9.1, -Wno-alloc-size-larger-than (and therefore the "alloc_size" * attribute) do not work, and must be disabled. */ #if GCC_VERSION < 90100 #undef __alloc_size__ #endif > -Kees >