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:   Thu, 17 Nov 2022 16:54:33 -0800
From:   Kees Cook <keescook@...omium.org>
To:     sdf@...gle.com
Cc:     wangkailong@...i.cn, linux-kernel@...r.kernel.org,
        bpf@...r.kernel.org
Subject: Re: [PATCH] samples/seccomp: fix array_size.cocci warning

On Mon, Nov 14, 2022 at 09:15:35AM -0800, sdf@...gle.com wrote:
> On 11/13, wangkailong@...i.cn wrote:
> > Fix following coccicheck warning:
> 
> > samples/seccomp/bpf-fancy.c:83:39-40: WARNING: Use ARRAY_SIZE
> > samples/seccomp/bpf-fancy.c:86:44-45: WARNING: Use ARRAY_SIZE
> 
> Not sure this should go via bpf tree. CC'ed Kees
> 
> > Signed-off-by: KaiLong Wang <wangkailong@...i.cn>
> > ---
> >   samples/seccomp/bpf-fancy.c | 4 ++--
> >   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> > diff --git a/samples/seccomp/bpf-fancy.c b/samples/seccomp/bpf-fancy.c
> > index 1ccb435025b6..548f038924d6 100644
> > --- a/samples/seccomp/bpf-fancy.c
> > +++ b/samples/seccomp/bpf-fancy.c
> > @@ -80,10 +80,10 @@ int main(int argc, char **argv)
> >   	};
> >   	struct sock_fprog prog = {
> >   		.filter = filter,
> > -		.len = (unsigned short)(sizeof(filter)/sizeof(filter[0])),
> > +		.len = (unsigned short)(ARRAY_SIZE(filter)),
> >   	};
> >   	ssize_t bytes;
> > -	bpf_resolve_jumps(&l, filter, sizeof(filter)/sizeof(*filter));
> > +	bpf_resolve_jumps(&l, filter, ARRAY_SIZE(filter));

Hm, this is the "samples" tree, so this was intentionally avoiding these
kinds of kernel-isms, but perhaps that doesn't realistically matter?

-Kees

> 
> >   	if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)) {
> >   		perror("prctl(NO_NEW_PRIVS)");
> > --
> > 2.25.1

-- 
Kees Cook

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ