From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 105FE358360 for ; Wed, 22 Apr 2026 10:01:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776852081; cv=none; b=LFaPUzeTD+erjdux1tKh/tLStytf/COphQb19BjL1azkuPk4cqJ+DbqTYEXZKzRwmYgE0zPZguuxbKtrypp/ttHO8iNuuAgJdz2aEC3ZXX3iyC7vnOz8o6zq1KRD5RjZ4F6TREOoz0P0fzJVaOUrLDbSgf2zkRLP96xXUQWzVlU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776852081; c=relaxed/simple; bh=g1HmJeGW/EthYdybdQs2ev875savaWtrQ8MUgqb1L5M=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QbQD6OmL8zGk17JVvJupo0J9dISZLnewQcU1WSRkdGOmRhyAwSaSJUT3xjESMwmn2YeqMTJM4wB8XUNwCocAlDFN02d0KYr3NeFH+1S3YPI7Fqb+UFWyJlhoXu4nBVOEvSJW4qh1nxHQ/KU3r4VyRrLoaUEqpzqe8abPcs9ELSE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=QPRqRut+; arc=none smtp.client-ip=209.85.221.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QPRqRut+" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-43d70c30767so3593816f8f.0 for ; Wed, 22 Apr 2026 03:01:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776852078; x=1777456878; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=b8nPO4S00DJRZysggbb4Syo2J9M2MZr/N8yyymN7fts=; b=QPRqRut+i3l9SvMzQlhZR23fiFRV61y02SEejpIlEMWHNFeM+k0ilJTZsL2dikVR0s rZOOTvSz5qfDuiZsGKzXI3Y37NvJErMNq5HW4W9m4VIRDYuhOPjJ1DgOSYtmp51+8TPy cEJE8d29L51mXobPKApu0geR4I9QGlZ81vGk2GJUFCnymOP0SG2cTwDiKnO65owbsi6a SMijC+ZezwJVHir/DqXREkJBn2Du/cFz041TIhM2nsQzID1UdWVjI6T7fcL5D0Zog6QZ Tf4Dts5031pHYjXrevTDcjdrCzdD5cBxCBcVpp9ZjSjyIYqJpPLyrPt2z7NStd+gbZM5 8qUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776852078; x=1777456878; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=b8nPO4S00DJRZysggbb4Syo2J9M2MZr/N8yyymN7fts=; b=hX5DZ2Sx5DIB813cWJCT7eqeSa49GCSmuQ3K09jvWkwmS91ZA3zy9WsaYsGZ9UluoK J216kwq23LBsII3Lq2vC2nL9K/Fpa17JUaJU59l02ohe+oBah/+yBWDdkEv0B+C3QqM2 zUAAKWQ6GlMBU6oM5xe8L0KeaeaV2/Vuq9lf2CFNxVQMOq0U0VjpTxEtcVVHaeqY2o6b ZWfLVNdaRLdPsplUjiwW4amnbUE2KN5GBPvx/d0kxGJharGBP8ROervJOfZQYZNKnL0N XSNrdEuPoyl3DkyEMTQiO2JTfkSbuUXWIzPnxL79/ogwlvNAKUyOvQLj8/+j6HlYsc1u ytLQ== X-Forwarded-Encrypted: i=1; AFNElJ8sTI8L7sdQn+v3VPbNYIMvgrDpO+Z8CYocg1NJ2b96cN8lXxnsx0iaA3ADrVWDPBFi+qb7IqaQH/yZOEU=@vger.kernel.org X-Gm-Message-State: AOJu0Yy5/ZAvIyg6twkWnayGuyeR2K3auFAahZz0Y7roXHFBrCkg5wzW uRMhKwoUzAm9qOHjZgG6lJL2hmUaZuxBWjqmnHYIxKik3zpnkmapcXdPu1oVSmxl X-Gm-Gg: AeBDievC+iK7kJXs95lBfINM/UnkUYLsSTrBLJzCSqw+7hJI9eE+sJkAc6qxNxJRfX/ iDQzivcp1SRrrvalq7foE7yUeKKi+sBCsqevDWbk2+Sodc2dRAt1Jl69kUKdYMtnUDKJv2WnrUN ma8x5VsIgrLmHuoxJy7Uh703cCT85e5UkU0+gvzewm4BWj6YnPsb8zF/BR63hkq/Qj/eRgSJdzs A7Lasi2MWfflkAHMx2QSyYoApjZ9wGKRj3JuY7WzqgC9yFcs2YeiZcPkcwxb9NNKFKWtDz2ZbLE oKr9ArtTum6NNceYgtsBECm+Fbd8yLy5ub817UKypZ2w5Gy7hqCvUAtvbaTLQ72xmzdgRbYaO1Q xsvwSzv/nb9lCHmlLN+k1wUjUzqXndXQjW1dMeIti/kYBQmlvzmnccCRiDDhKzD6z5xHqHpOw4e Q0vAFb1q70pOGZnc9Z0cQY42uUOJRj7RQCP+T7zdDgj0KpgDXK6WVNsvbdc/k1XUB/Nn/6P/WsS w0= X-Received: by 2002:a05:6000:2d8a:b0:439:adc3:f0e7 with SMTP id ffacd0b85a97d-43fe4043f54mr22091920f8f.9.1776852078192; Wed, 22 Apr 2026 03:01:18 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43fe4e4d6casm40375198f8f.32.2026.04.22.03.01.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Apr 2026 03:01:16 -0700 (PDT) Date: Wed, 22 Apr 2026 11:01:14 +0100 From: David Laight To: Marco Elver Cc: kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, Arnd Bergmann , Miguel Ojeda , Dmitry Vyukov , Nathan Chancellor , llvm@lists.linux.dev Subject: Re: [PATCH 1/2] Compiler Attributes: Add __access macro Message-ID: <20260422110114.0f48d109@pumpkin> In-Reply-To: <20260421190351.1976329-1-elver@google.com> References: <20260421190351.1976329-1-elver@google.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 21 Apr 2026 21:03:47 +0200 Marco Elver wrote: > 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 No need to the initial 'x', you can just do: # define __access(...) __attribute__((__access__(__VA_ARGS__))) Putting the actual syntax in the comment would help, eg as: __access__(read_only|read_write|write_only|none, param_number[, size]) David > + > /* > * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alias-function-attribute > */