From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4125334C155 for ; Tue, 21 Apr 2026 19:04:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776798247; cv=none; b=VLwmKptcOjOVOdipffVC82/nxzoBRLcngTxiVNjIpYrvE1EwtSWgaJfhrbQg3N/FPb1dNsA0vnCCsmEWuipsgd05u2aismtUO1o3s5/P0ix3zMI1Bh895g+CcP526eh1oU0RkdHJGLJ8RD4uAFN/yR1/VvC3piF6Y7xThxqyrDk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776798247; c=relaxed/simple; bh=itmHKeYdTrXU9RgiqwsA1M7ZjCooCXj0hGK5wGYsCvg=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=TDBcDetA7aWkFly6OiM1EAtI+Ft0iSKYpVC4WEl3joCxZKOMKy3UkEbNgWSHFaO+zcvS+IL2UYxTrH+QSuiA6OG8vXLKZP7+t96Mz0zeySDd4kwNyALH2R/WMmTt8H2pXX99vU0rQpvwAohjzsoa3c1izIlRIWBV5tt9IcF+nNY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--elver.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=hdlBQM35; arc=none smtp.client-ip=209.85.128.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--elver.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="hdlBQM35" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-488d8deb75fso37921715e9.3 for ; Tue, 21 Apr 2026 12:04:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776798245; x=1777403045; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=ZuYemzHrsE4FyqS0s1BFQk1xjd8CwS4JPKuxgVOhZ8o=; b=hdlBQM35kxXNd8OtTjS4jR2Prm8gyjB8eMRqW6F6m/6GQZ7q9RCyJwXCCgnZSXEczb S4gfR5nsXA2avrTuPySEe9t9i/oG7B+spbU4KtoOP1RwDfMehE2wxoBxFmbO5xJgZ70l kaxoNz78vTBFAtsilkFCPDdydxxGXNIt6Jv6JCI5XAc9RNTO9WkGua+zr9/pDsEFPUQr ilB3zEc6ZcuLJ2OtpCIycfPT6sL6feKQ/LZ9IyBet32VtRftO/Vhjy4beXiI8cIT2p8T BT1v3h0UTNOUh5qshFo3YENKf2EjkCNIi4ZMvhUYEGq5OBOibY44jLe1RzCeG1YrJw9q 4ekA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776798245; x=1777403045; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ZuYemzHrsE4FyqS0s1BFQk1xjd8CwS4JPKuxgVOhZ8o=; b=skS1nzt2FhtDx7h9qo6MT7/pbRV+wPS0cql44t6Mpit6zagxHI6WWiD8tB955cxhK9 73V/2ifFNnb13YVL5Wa95DYYts6ynPiA0wxEs5/VHJQyt53Bgp3Vg3oQLC5zIUFQGrM3 ujtulDtR1PAnNPMMBcdgdTw7XKcez/OS3YVCeMhjPeQTBojde1zFQX+J1YDpblz8LDDk h8UGOHADrO8RJ+W6lwrPArX7Y9sJnDh5AoaASdMAneSmAJeyVXN0BvhjK75GAgCnHE3h JD71cZgrDCP1Lg2XPzTD6FX/+jRX1hqjj9lKKORRs7UNVKadwNw4qFiHyg75V/q8xlie ANQQ== X-Forwarded-Encrypted: i=1; AFNElJ+R8ZiEOuwGWmLL30yiCFM9r5vQukISikH2Jpad/UfXcK7wUseSfdlFght9uAWe1aVGrZKPaERcf6Hlm3A=@vger.kernel.org X-Gm-Message-State: AOJu0YyrkTTGkp7A8tXD4/8A8n0rpZozRfuHhu9NohFDsmPu/0vn0ChO uzYXmBkeXA8jJPnYozWgA9L0qcZ+7u020l6Kd7S2THUIxR8yTaXpt1aaeGPWeQLkdiimxt67Fmq RyA== X-Received: from wmkz3.prod.google.com ([2002:a7b:c7c3:0:b0:488:7e69:14c1]) (user=elver job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:6990:b0:48a:5970:1fe1 with SMTP id 5b1f17b1804b1-48a597021eamr12282985e9.4.1776798244496; Tue, 21 Apr 2026 12:04:04 -0700 (PDT) Date: Tue, 21 Apr 2026 21:03:47 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.54.0.rc2.533.g4f5dca5207-goog Message-ID: <20260421190351.1976329-1-elver@google.com> Subject: [PATCH 1/2] Compiler Attributes: Add __access macro From: Marco Elver To: elver@google.com Cc: kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, Arnd Bergmann , Miguel Ojeda , Dmitry Vyukov , Nathan Chancellor , llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" Add support for the `__access__` attribute, which is supported since gcc >= 11 but not currently supported by clang. The attribute allows specifying how a function accesses memory passed via a pointer argument (read_only, write_only, read_write, none) and optionally the size of the access. Per [1] these annotations only affect diagnostics, and should not affect code generation: "The access attribute enables the detection of invalid or unsafe accesses by functions or their callers, as well as write-only accesses to objects that are never read from. Such accesses may be diagnosed by warnings such as -Wstringop-overflow, -Wuninitialized, -Wunused, and others." [1] https://gcc.gnu.org/onlinedocs/gcc/Common-Attributes.html#index-access Signed-off-by: Marco Elver --- include/linux/compiler_attributes.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/linux/compiler_attributes.h b/include/linux/compiler_attributes.h index c16d4199bf92..ef4e279e9872 100644 --- a/include/linux/compiler_attributes.h +++ b/include/linux/compiler_attributes.h @@ -20,6 +20,18 @@ * Provide links to the documentation of each supported compiler, if it exists. */ +/* + * Optional: only supported since gcc >= 11 + * Optional: not supported by clang + * + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Attributes.html#index-access + */ +#if __has_attribute(__access__) +# define __access(x, ...) __attribute__((__access__(x, ## __VA_ARGS__))) +#else +# define __access(x, ...) +#endif + /* * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alias-function-attribute */ -- 2.54.0.rc2.533.g4f5dca5207-goog