From patchwork Fri Jan 26 18:39:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alejandro Colomar X-Patchwork-Id: 1891594 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=pXNP/7Uu; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TM61D0wrjz23f9 for ; Sat, 27 Jan 2024 05:39:28 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1F6793858C35 for ; Fri, 26 Jan 2024 18:39:26 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by sourceware.org (Postfix) with ESMTPS id 56F0B3858D35 for ; Fri, 26 Jan 2024 18:39:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 56F0B3858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kernel.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 56F0B3858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2604:1380:4641:c500::1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706294351; cv=none; b=YhY21Wp80VMb9pu48dJFBvJg/H0VgE1L9Hp5qvHdVMEu2U7Nx8sMutnwppSNHHCsqZhlXiK0QWUukhcmavfQUS3XXyagcrp6XnPyaG+4np2k/IXwFLy1EstjxVIjllYTML5upkcTJe9XRSsN4i5moX//SdSUUK5Cx6Vqp47G9sE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706294351; c=relaxed/simple; bh=WRqjyAkiyO3PoCYM1tuIF9cPm76RkHGz5C1ffIOcCEQ=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=FTTm8BKfwukLaoPNyPInGLBkCKJcbaYsuRnC7lXMpP2VaFOaD97bPpilwswbKX8CkBXJFGCdcxjT1T6WNbHT95n8hZhA8wqGsj0vAZcQWHvoqd4cz2g/4NyG2fI2ezsBplXFw/RCW93VKGHX+znVNtrGH44HV504k/MufAENLqQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id F08E9625DF; Fri, 26 Jan 2024 18:39:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B087C43142; Fri, 26 Jan 2024 18:39:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706294349; bh=WRqjyAkiyO3PoCYM1tuIF9cPm76RkHGz5C1ffIOcCEQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pXNP/7UusbMiL5JBG2CESFzrgpJwIhdiC2iLz/y776S5IINjJYr4j6/55aE4C95xS xExdxIdSesWl9LitnVERGb040s8jAv+lCkHRiZkoxXIH1SdJwPy/l2L5+U7tZfMrQY N6B1xX6Da1M9TXzIYCKV6jwQOb4dvqwrsT0zcyawkZzP5YzzEJHMzdlExKF8m/XU0j gSrIwRoGlS9kjRwYnnCi20MCtxG2e9aZMcFkl4RNcvKV/bFI2XGSG8yXn33VrmOqgZ 78dA63aOOR7E3fdMlXD2PWvcAiYDpmt8GB/t+YS+ir+x2wtto5gwj5/QieMq/a68d6 4ba1/wJ/ORYDw== Date: Fri, 26 Jan 2024 19:39:06 +0100 From: Alejandro Colomar To: libc-alpha@sourceware.org Cc: Alejandro Colomar , Arsen =?utf-8?q?Arsenovi=C4=87?= , Andreas Schwab , Xi Ruoyao , Russ Allbery Subject: [PATCH] Use [[gnu::access(none)]] on free(3) Message-ID: <20240126183847.12939-2-alx@kernel.org> X-Mailer: git-send-email 2.43.0 References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org The lifetime of the object expires right at the boundary of the call to free(3), and the function doesn't access (neither read nor write) it, as far as the abstract machine is concerned. Cc: Arsen Arsenović Cc: Andreas Schwab Cc: Xi Ruoyao Cc: Russ Allbery Signed-off-by: Alejandro Colomar --- stdlib/stdlib.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h index 414c49d731..8dfd373bf5 100644 --- a/stdlib/stdlib.h +++ b/stdlib/stdlib.h @@ -684,7 +684,8 @@ extern void *realloc (void *__ptr, size_t __size) __THROW __attribute_warn_unused_result__ __attribute_alloc_size__ ((2)); /* Free a block allocated by `malloc', `realloc' or `calloc'. */ -extern void free (void *__ptr) __THROW; +extern void free (void *__ptr) + __THROW __attr_access ((__none__, 1)); #ifdef __USE_MISC /* Re-allocate the previously allocated block in PTR, making the new