From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B33E138515D7; Fri, 18 Nov 2022 23:57:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B33E138515D7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668815832; bh=j3YS6x/+Z6242Qbid7YsSFxdXNJXZOFyUGUYyKovbnU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=PcFVNb/TstgGWG/ylApIffWv+bba04Tj9pGPbTj19OVAUwp78BN47/cer0SmGIrPJ zkCM+kdTN/tc5jMAEc9XlDihAn8XNBtqcpKYQj6VuiTSVEDJnHGv9gyJPDInuyWtlU EGB5oQs4uv7p+NOtLHHqZGpuhQmO2TzCPBKRhPgU= From: "pageexec at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug ipa/96503] attribute alloc_size effect lost after inlining Date: Fri, 18 Nov 2022 23:57:08 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: ipa X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: pageexec at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96503 PaX Team changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |pageexec at gmail dot com --- Comment #2 from Siddhesh Poyarekar --- (In reply to Kees Cook from comment #1) > Created attachment 53643 [details] > PoC showing unexpected __bdos results across inlines >=20 > Fixing this is needed for the Linux kernel to do much useful with > alloc_size. Most of the allocators are inline wrappers, for example. For cases where the size doesn't really change across the inlines, it ought= to be sufficient to annotate the non-inlined implementation function, e.g. in = case of kvmalloc, annotate kvmalloc_node as __alloc_size(1). For other cases it may be less trivial, e.g.: /* Some padding the wrapper adds to the actual allocation. */ size_t metadata_size; __attribute__ ((alloc_size (1))) void *alloc_wrapper (size_t sz) { return real_alloc (size + metadata_size); } extern void *real_alloc (size_t) __attribute__ ((alloc_size(1))); here the compiler will end up seeing the padded size, which may not be corr= ect. To fix this we'll have to store the alloc_size info somewhere (ptr_info see= ms to be aliasing-specific, so maybe a new member to tree_ssa_name) during inlining and then teach the tree-object-size pass to access it.=