[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87lem2yavb.fsf@cloudflare.com>
Date: Mon, 16 Jan 2023 12:27:10 +0100
From: Jakub Sitnicki <jakub@...udflare.com>
To: Eric Dumazet <edumazet@...gle.com>
Cc: Dan Carpenter <error27@...il.com>, oe-kbuild@...ts.linux.dev,
netdev@...r.kernel.org, lkp@...el.com,
oe-kbuild-all@...ts.linux.dev, kernel-team@...udflare.com,
John Fastabend <john.fastabend@...il.com>,
Daniel Borkmann <daniel@...earbox.net>,
Alexei Starovoitov <ast@...nel.org>,
Andrii Nakryiko <andrii@...nel.org>,
syzbot+04c21ed96d861dccc5cd@...kaller.appspotmail.com
Subject: Re: [PATCH bpf 1/3] bpf, sockmap: Check for any of tcp_bpf_prots
when cloning a listener
On Mon, Jan 16, 2023 at 11:39 AM +01, Eric Dumazet wrote:
> We might add a generic helper to make all this a bit more clear ?
>
> +#define is_insidevar(PTR, VAR) ( \
> + ((void *)(PTR) <= (void *)(VAR)) && \
> + ((void *)(PTR) <= (void *)(VAR) + sizeof(VAR)))
> +
>
>
> ...
>
> if (is_insidevar(prot, tcp_bpf_prots))
> newsk->sk_prot = sk->sk_prot_creator;
Sure can do. Thanks for the suggestion. I adjusted it a bit:
- added cast to char * so we don't offend -Wpointer-arith,
- fixed the lower and upper bound check.
Final form would look like:
#define is_insidevar(ptr, var) \
((void *)(ptr) >= (void *)(var)) && \
((void *)(ptr) < (void *)((char *)(var) + sizeof(var)))
Not sure where to stuff it. I propose include/linux/util_macros.h.
Powered by blists - more mailing lists