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 38C76C32771 for ; Wed, 28 Sep 2022 21:40:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A0AEF6B0072; Wed, 28 Sep 2022 17:40:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9B9446B0074; Wed, 28 Sep 2022 17:40:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 881D56B0075; Wed, 28 Sep 2022 17:40:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 7A2E56B0072 for ; Wed, 28 Sep 2022 17:40:51 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 53224C0AEA for ; Wed, 28 Sep 2022 21:40:51 +0000 (UTC) X-FDA: 79962814302.14.6F165D8 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf11.hostedemail.com (Postfix) with ESMTP id 8B0E640005 for ; Wed, 28 Sep 2022 21:40:49 +0000 (UTC) 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664401250; 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:dkim-signature; bh=C18vkSCkEp0R0j/E8doyhXlqBRc6MmmoczHaFz5Tq/o=; b=VU0eTJanY2BgXr5u4zQ4giG7zJv3UBUPtz+fZ907UYkoUwNxq6wOuYD+D2qXVvzu+/TN// 0aVRwRSlNwnmCrd+MCpq87GGXfJ1NAvHHrHrZFEjxNCNnzuV2C2VJSRiSMwaFgnJOpgqfR 9NONNWKavNEVxAfMapdqnaYdi7duLLA= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=O8ZKN2zJ; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=QuVwGzEY; spf=pass (imf11.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664401250; a=rsa-sha256; cv=none; b=d2UGIFaee0iLDsKpkhj6XWHgP5yabfvyk4/X34MT5r4VkdxpMlNKkZxcgr1I8BL8ROJxRI WPJk19B9JkpH3VdJJZqNUdE4M/x2Kh8viNEJ1Y30UfC6Zv8CYCDGV9HT1dAhSeW9cPDTyF 79LxAUJqkk1gVGH9gksGmA9MUZ+sl/w= X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 8B0E640005 Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=O8ZKN2zJ; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=QuVwGzEY; spf=pass (imf11.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none X-Stat-Signature: sfc7imr6xm8dgufakzux7fmegxhtc4io X-HE-Tag: 1664401249-876080 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 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 >