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 DC263C02194 for ; Thu, 6 Feb 2025 18:13:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7793B6B0088; Thu, 6 Feb 2025 13:13:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 70BA56B0089; Thu, 6 Feb 2025 13:13:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5C94D6B008A; Thu, 6 Feb 2025 13:13:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 3C5D56B0088 for ; Thu, 6 Feb 2025 13:13:25 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id C37031413BE for ; Thu, 6 Feb 2025 18:13:24 +0000 (UTC) X-FDA: 83090317128.28.0D93469 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf10.hostedemail.com (Postfix) with ESMTP id 31736C0015 for ; Thu, 6 Feb 2025 18:13:23 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=c3N7A39F; spf=pass (imf10.hostedemail.com: domain of kees@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=kees@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1738865603; a=rsa-sha256; cv=none; b=kSbO+GrDamJ6hryyEBUG7gQ+luMBFi94Vo3QWiCpwyI3kBOoMUxEr3P73yvqeuR0OTNAEp JHHX3g1RaHLlXjjizb1JMizoOzWzJQidhCk+HbtNA4ez3qiQDof95V7HIbFQlLEBLgHuKn sfjUz5WtD6uxtDRBzQB87cqrKAJqEZ4= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=c3N7A39F; spf=pass (imf10.hostedemail.com: domain of kees@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=kees@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1738865603; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Kzu52x2lEDsLYaCWFqPvqTosTZfyFCN3TQlUShpn7qA=; b=oqPNKxvztVlcXIuqXY68UGNx4M5oFV6iBuYfXUtLJ881kx5beO0kJwyws55r3+2/nAWhZ9 wQywwf2ZpCJCzwvw6UOJNLMPeN/4+oslDsukn/k/KKLngPJepRqpyR8nhkaMUx2mdjq3GH jE15wa8zt1Wrfm8lzwJ+jjxBrHzzvLk= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 64F70A42767; Thu, 6 Feb 2025 18:11:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 090E9C4CEDD; Thu, 6 Feb 2025 18:13:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738865602; bh=zm/qQh7A8Swkkid0PIiYsRoSC0ki1h+Dn600rblvx7c=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=c3N7A39F+dLefEgu2q45RFYpyvOIEmAaOGNzkzVw2uKB2GRoJNsW6lRKsb0OUK+GP cN/BIpUWwabpPMBvLeSWEynr+Nf7a4eVH9CanUn+PF/+vCgKAiyGX+oKSb6+NxrRac I/VIZaQo+lCGxeEwcDNDgqocktPprxjIIRUL6Sk3rTOWgqdG5melRJHg2w9MITRFqa ebwNZ2tSCB2N/fTAmfLuOdn8yW4InGKJwcHh/VUNEWPkZZg0R4rXA7pxV3+GfHpam4 bw0UL29sNEwGJDHSPN9XSBtwUhBoyaBl1Efhdppx52MiHHQ1pPPU6DKH6IPq+Kv1pH c0LNQmDU4bL9A== Date: Thu, 6 Feb 2025 10:13:21 -0800 From: Kees Cook To: Kent Overstreet Cc: Suren Baghdasaryan , akpm@linux-foundation.org, nathan@kernel.org, ndesaulniers@google.com, morbo@google.com, justinstitt@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, kernel test robot Subject: Re: [PATCH 1/1] alloc_tag: work around clang-14 issue with __builtin_object_size() Message-ID: <202502061011.BD9611CEA@keescook> References: <20250201200503.2532357-1-surenb@google.com> <202502051056.B910C691C@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Stat-Signature: my5f3ohw8px3md3s7yh4hky9ty4biaqo X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 31736C0015 X-Rspam-User: X-HE-Tag: 1738865603-496442 X-HE-Meta: U2FsdGVkX1/7P9B9wAQ1Y7fPvr8V0QoJoHBPuzGlZSSaY4Lkn3BXixWskearx9jJgJQUoGi3b5BeaU4p+PQqr3YLYo8OuPDLHkIXcdpylw/gBteu62em6ZHTI7oN6uK9Zk+8NnWgN+W/ZgaKi94KefikUSuQ00DrLJTqRIr2SORHx+WM7YTuJap1/F+PZcw16cnERBq3ausZEDIcu21oqUL48KgJwk8dUICvSL4pL2LwBuBfY5FQqolcGxogtx0uqtt79cb4O+NhPNG5tAn4DG8eUFrcTm+zkIQ6iIC0GpwUJVDZU3AehoxVcwehJsLsXpka1Yxa9fLa/5faeOdjDyfzguDp4bbtLuZ1bP5xiIJQn1iQtM2P+e2vdrrDEEBDMNK+vNtk+UQglcwl5/3VWXLIoKtJvK3royCx0mLrGpJk2DNbDkw2qDgIPGhFYNKhr9GJ/jrEcTQQ7uvV6Zxia6hDmZFD626Ci0O8QX4owpmgNngl/nmvaYZVMNKs1lNTcDnhKIkaZHAN3E7jyqeloNBy3tWt5JHuoetw9XEjzrJY4X2bjFvis3bZC71SkvohH4AjkqRPDFALl31PJpcEsJLzhk258CzvFaWKOv1UJiU2IGXaeLtx/peHh92F3CTKcAwWrIe+O2eJ6Pmcy5MOat1n480AvYP9qU7iQ9sS7fVgIov8h6vph1FwzTVyL1B/7IAO+CZbz1syerQWSK/ghWydZp2G5IeW++Q8n2vs1pSajE7B8a6rivJgripttEXb8SjbOxjpNeQimpjTzBBAtT7rDXgCA0TpexOu7JCSnlG9y0KBGm5502lVoAc4i0cQkJNWx+mD9pDwka0i2RCm1fdLPXKcjvQPSJ9FCjbGoxkHIAT4wPFxCZaTl7QDRUDVSlXEPJ9A3p5uHMKquojWr/ilF+ELRoYxeYf7GKRn2A9XKemtWPm79fxCO0unwt8LfKpEn0FpuVy7cDVF/Vk SGBOv0uG dKJFxyYKwSHru6faJTkD8E2lGdp97FEc22UYz6M3syc9CrO/JTEa1KLQZosIlONTWvnbmEZ02FfJMPC+RJhPs25NpBTVq3uaqr4i15MTkY0g6dPE1ht7mJPAwNnCKKrxwCeKClCWTPQ98joQiXmSC25+mRXT6MbniphhxVCIOTML7TQA/jBAtNrPgpeLmY1QAFct8JZbFXPfXlWF5j/+wDUD8Hu9RQDo72VRJeQRQIDBPn0Gn3grFAPU8o4BBwwsgzVRgf3j+HsFkRwVL9fKc6RChwLaCi13v6pFwdfXQkeHIZo067fV0GahTXxpWP8qjhNp4 X-Bogosity: Ham, tests=bogofilter, spamicity=0.027047, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Wed, Feb 05, 2025 at 03:16:12PM -0500, Kent Overstreet wrote: > On Wed, Feb 05, 2025 at 11:18:35AM -0800, Kees Cook wrote: > > On Sat, Feb 01, 2025 at 12:05:03PM -0800, Suren Baghdasaryan wrote: > > To Kent's comment[1], I believe I was using __builtin_object_size() here > > because I have a knee-jerk aversion to sizeof() due to it blowing up on > > flexible arrays, but that's not relevant here. ARRAY_SIZE() would work, > > but only if type checking to "char *" succeeds, as Kent suggests. > > Yeah, that rational for __builtin_object_size() makes sense - although > it's not what the gcc docs say, those talk about getting the size from > an attribute on the allocation function (!). > > ARRAY_SIZE() is sizeof() underneath, just used creatively to guarantee > that the input is an array - although that property is probably what we > want here, since strtomem_pad() really only makes sense on static or > flex-arrays, no? Okay, here's my proposed fix, and confirmed that it solves the problem: https://lore.kernel.org/lkml/20250206175216.work.225-kees@kernel.org -Kees -- Kees Cook