All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next v1 1/1] bpf: Fix bpf_xdp_pointer return pointer
@ 2022-07-22 22:01 Joanne Koong
  2022-07-25 20:16 ` Martin KaFai Lau
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Joanne Koong @ 2022-07-22 22:01 UTC (permalink / raw)
  To: bpf; +Cc: lorenzo, andrii, daniel, ast, Joanne Koong

For the case where offset + len == size, bpf_xdp_pointer should return a
valid pointer to the addr because that access is permitted. We should
only return NULL in the case where offset + len exceeds size.

Fixes: 3f364222d032 ("net: xdp: introduce bpf_xdp_pointer utility routine")
Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
---
 net/core/filter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/filter.c b/net/core/filter.c
index 289614887ed5..4307a75eeb4c 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -3918,7 +3918,7 @@ static void *bpf_xdp_pointer(struct xdp_buff *xdp, u32 offset, u32 len)
 		offset -= frag_size;
 	}
 out:
-	return offset + len < size ? addr + offset : NULL;
+	return offset + len <= size ? addr + offset : NULL;
 }
 
 BPF_CALL_4(bpf_xdp_load_bytes, struct xdp_buff *, xdp, u32, offset,
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH bpf-next v1 1/1] bpf: Fix bpf_xdp_pointer return pointer
  2022-07-22 22:01 [PATCH bpf-next v1 1/1] bpf: Fix bpf_xdp_pointer return pointer Joanne Koong
@ 2022-07-25 20:16 ` Martin KaFai Lau
  2022-07-25 21:55   ` Joanne Koong
  2022-07-25 21:28 ` Lorenzo Bianconi
  2022-07-26 11:20 ` patchwork-bot+netdevbpf
  2 siblings, 1 reply; 6+ messages in thread
From: Martin KaFai Lau @ 2022-07-25 20:16 UTC (permalink / raw)
  To: Joanne Koong; +Cc: bpf, lorenzo, andrii, daniel, ast

On Fri, Jul 22, 2022 at 03:01:05PM -0700, Joanne Koong wrote:
> For the case where offset + len == size, bpf_xdp_pointer should return a
> valid pointer to the addr because that access is permitted. We should
> only return NULL in the case where offset + len exceeds size.
> 
> Fixes: 3f364222d032 ("net: xdp: introduce bpf_xdp_pointer utility routine")
> Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
> ---
>  net/core/filter.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/core/filter.c b/net/core/filter.c
> index 289614887ed5..4307a75eeb4c 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -3918,7 +3918,7 @@ static void *bpf_xdp_pointer(struct xdp_buff *xdp, u32 offset, u32 len)
>  		offset -= frag_size;
>  	}
>  out:
> -	return offset + len < size ? addr + offset : NULL;
> +	return offset + len <= size ? addr + offset : NULL;
This fix should be for the bpf tree.

Acked-by: Martin KaFai Lau <kafai@fb.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH bpf-next v1 1/1] bpf: Fix bpf_xdp_pointer return pointer
  2022-07-22 22:01 [PATCH bpf-next v1 1/1] bpf: Fix bpf_xdp_pointer return pointer Joanne Koong
  2022-07-25 20:16 ` Martin KaFai Lau
@ 2022-07-25 21:28 ` Lorenzo Bianconi
  2022-07-26 11:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 6+ messages in thread
From: Lorenzo Bianconi @ 2022-07-25 21:28 UTC (permalink / raw)
  To: Joanne Koong; +Cc: bpf, andrii, daniel, ast

[-- Attachment #1: Type: text/plain, Size: 1002 bytes --]

> For the case where offset + len == size, bpf_xdp_pointer should return a
> valid pointer to the addr because that access is permitted. We should
> only return NULL in the case where offset + len exceeds size.
> 
> Fixes: 3f364222d032 ("net: xdp: introduce bpf_xdp_pointer utility routine")
> Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
> ---
>  net/core/filter.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/core/filter.c b/net/core/filter.c
> index 289614887ed5..4307a75eeb4c 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -3918,7 +3918,7 @@ static void *bpf_xdp_pointer(struct xdp_buff *xdp, u32 offset, u32 len)
>  		offset -= frag_size;
>  	}
>  out:
> -	return offset + len < size ? addr + offset : NULL;
> +	return offset + len <= size ? addr + offset : NULL;
>  }
>  
>  BPF_CALL_4(bpf_xdp_load_bytes, struct xdp_buff *, xdp, u32, offset,
> -- 
> 2.30.2
> 

Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH bpf-next v1 1/1] bpf: Fix bpf_xdp_pointer return pointer
  2022-07-25 20:16 ` Martin KaFai Lau
@ 2022-07-25 21:55   ` Joanne Koong
  2022-07-26 11:19     ` Daniel Borkmann
  0 siblings, 1 reply; 6+ messages in thread
From: Joanne Koong @ 2022-07-25 21:55 UTC (permalink / raw)
  To: Martin KaFai Lau
  Cc: bpf, Lorenzo Bianconi, Andrii Nakryiko, Daniel Borkmann,
	Alexei Starovoitov

On Mon, Jul 25, 2022 at 1:17 PM Martin KaFai Lau <kafai@fb.com> wrote:
>
> On Fri, Jul 22, 2022 at 03:01:05PM -0700, Joanne Koong wrote:
> > For the case where offset + len == size, bpf_xdp_pointer should return a
> > valid pointer to the addr because that access is permitted. We should
> > only return NULL in the case where offset + len exceeds size.
> >
> > Fixes: 3f364222d032 ("net: xdp: introduce bpf_xdp_pointer utility routine")
> > Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
> > ---
> >  net/core/filter.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/net/core/filter.c b/net/core/filter.c
> > index 289614887ed5..4307a75eeb4c 100644
> > --- a/net/core/filter.c
> > +++ b/net/core/filter.c
> > @@ -3918,7 +3918,7 @@ static void *bpf_xdp_pointer(struct xdp_buff *xdp, u32 offset, u32 len)
> >               offset -= frag_size;
> >       }
> >  out:
> > -     return offset + len < size ? addr + offset : NULL;
> > +     return offset + len <= size ? addr + offset : NULL;
> This fix should be for the bpf tree.
Ah I see. To confirm my understanding, fixes should always go to the
bpf tree (unless it's fixing a patch that only resides in the bpf-next
tree), correct?
>
> Acked-by: Martin KaFai Lau <kafai@fb.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH bpf-next v1 1/1] bpf: Fix bpf_xdp_pointer return pointer
  2022-07-25 21:55   ` Joanne Koong
@ 2022-07-26 11:19     ` Daniel Borkmann
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Borkmann @ 2022-07-26 11:19 UTC (permalink / raw)
  To: Joanne Koong, Martin KaFai Lau
  Cc: bpf, Lorenzo Bianconi, Andrii Nakryiko, Alexei Starovoitov

On 7/25/22 11:55 PM, Joanne Koong wrote:
> On Mon, Jul 25, 2022 at 1:17 PM Martin KaFai Lau <kafai@fb.com> wrote:
>>
>> On Fri, Jul 22, 2022 at 03:01:05PM -0700, Joanne Koong wrote:
>>> For the case where offset + len == size, bpf_xdp_pointer should return a
>>> valid pointer to the addr because that access is permitted. We should
>>> only return NULL in the case where offset + len exceeds size.
>>>
>>> Fixes: 3f364222d032 ("net: xdp: introduce bpf_xdp_pointer utility routine")
>>> Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
>>> ---
>>>   net/core/filter.c | 2 +-
>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/net/core/filter.c b/net/core/filter.c
>>> index 289614887ed5..4307a75eeb4c 100644
>>> --- a/net/core/filter.c
>>> +++ b/net/core/filter.c
>>> @@ -3918,7 +3918,7 @@ static void *bpf_xdp_pointer(struct xdp_buff *xdp, u32 offset, u32 len)
>>>                offset -= frag_size;
>>>        }
>>>   out:
>>> -     return offset + len < size ? addr + offset : NULL;
>>> +     return offset + len <= size ? addr + offset : NULL;
>> This fix should be for the bpf tree.
> Ah I see. To confirm my understanding, fixes should always go to the
> bpf tree (unless it's fixing a patch that only resides in the bpf-next
> tree), correct?

Yes, correct. Given we're really late in the cycle with rc8 my preference is to
only queue really urgent fixes to bpf tree at this point. This one I just took
to bpf-next given merge window is opening this Sun, thus this will go to Linus'
tree with just few days offset anyway.

Thanks,
Daniel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH bpf-next v1 1/1] bpf: Fix bpf_xdp_pointer return pointer
  2022-07-22 22:01 [PATCH bpf-next v1 1/1] bpf: Fix bpf_xdp_pointer return pointer Joanne Koong
  2022-07-25 20:16 ` Martin KaFai Lau
  2022-07-25 21:28 ` Lorenzo Bianconi
@ 2022-07-26 11:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-07-26 11:20 UTC (permalink / raw)
  To: Joanne Koong; +Cc: bpf, lorenzo, andrii, daniel, ast

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:

On Fri, 22 Jul 2022 15:01:05 -0700 you wrote:
> For the case where offset + len == size, bpf_xdp_pointer should return a
> valid pointer to the addr because that access is permitted. We should
> only return NULL in the case where offset + len exceeds size.
> 
> Fixes: 3f364222d032 ("net: xdp: introduce bpf_xdp_pointer utility routine")
> Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
> 
> [...]

Here is the summary with links:
  - [bpf-next,v1,1/1] bpf: Fix bpf_xdp_pointer return pointer
    https://git.kernel.org/bpf/bpf-next/c/bbd52178e249

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-07-26 11:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-22 22:01 [PATCH bpf-next v1 1/1] bpf: Fix bpf_xdp_pointer return pointer Joanne Koong
2022-07-25 20:16 ` Martin KaFai Lau
2022-07-25 21:55   ` Joanne Koong
2022-07-26 11:19     ` Daniel Borkmann
2022-07-25 21:28 ` Lorenzo Bianconi
2022-07-26 11:20 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.