lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 05 Oct 2021 17:51:31 -0700
From:   Joe Perches <joe@...ches.com>
To:     Randy Dunlap <rdunlap@...radead.org>,
        Kees Cook <keescook@...omium.org>
Cc:     Jonathan Corbet <corbet@....net>,
        Alexey Dobriyan <adobriyan@...il.com>,
        Nick Desaulniers <ndesaulniers@...gle.com>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Rasmus Villemoes <linux@...musvillemoes.dk>,
        Andrew Morton <akpm@...ux-foundation.org>,
        linux-kernel@...r.kernel.org, linux-doc@...r.kernel.org,
        linux-hardening@...r.kernel.org,
        Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
Subject: Re: [PATCH v5] docs: Explain the desired position of function
 attributes

On Tue, 2021-10-05 at 12:15 -0700, Randy Dunlap wrote:
> On 10/5/21 10:04 AM, Kees Cook wrote:
> > On Tue, Oct 05, 2021 at 08:39:14AM -0700, Joe Perches wrote:
> > > On Tue, 2021-10-05 at 08:26 -0700, Kees Cook wrote:
> > > > While discussing how to format the addition of various function
> > > > attributes, some "unwritten rules" of ordering surfaced[1]. Capture as
> > > > close as possible to Linus's preferences for future reference.
> > > > +For example, using this function declaration example::
> > > > +
> > > > + __init void * __must_check action(enum magic value, size_t size, u8 count,
> > > > +				   char *fmt, ...) __printf(4, 5) __malloc;
> > > 
> > > trivia: almost all fmt declarations should be const char *
> > 
> > Heh, good point!
> > 
> > > > +Note that for a function **definition** (i.e. the actual function body),
> > > > +the compiler does not allow function parameter attributes after the
> > > > +function parameters. In these cases, they should go after the storage
> > > > +class attributes (e.g. note the changed position of ``__printf(4, 5)``
> > > > +below, compared to the **declaration** example above)::
> > > > +
> > > > + static __always_inline __init __printf(4, 5) void * __must_check action(enum magic value,
> > > > +		size_t size, u8 count, char *fmt, ...) __malloc
> > > 
> > > here too, and 80 columns?
> > 
> > Kernel standard is now 100. *shrug*
> 
> That's more for exceptions, not the common rule.
> AFAIUI.

And for function definitions that are not static inline, when
separate function declarations exist, the function definition
does not need any attribute marking at all.


Powered by blists - more mailing lists