* [PATCH V3 bpf] xdp: add NULL pointer check in __xdp_return()
@ 2018-07-26 14:17 Taehee Yoo
2018-07-26 16:02 ` Björn Töpel
2018-07-27 1:44 ` Daniel Borkmann
0 siblings, 2 replies; 3+ messages in thread
From: Taehee Yoo @ 2018-07-26 14:17 UTC (permalink / raw)
To: daniel, ast
Cc: netdev, bjorn.topel, brouer, kafai, jakub.kicinski, Taehee Yoo
rhashtable_lookup() can return NULL. so that NULL pointer
check routine should be added.
Fixes: 02b55e5657c3 ("xdp: add MEM_TYPE_ZERO_COPY")
Acked-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Taehee Yoo <ap420073@gmail.com>
---
V3 : reduce code line
V2 : add WARN_ON_ONCE when xa is NULL.
net/core/xdp.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/core/xdp.c b/net/core/xdp.c
index 9d1f220..6771f18 100644
--- a/net/core/xdp.c
+++ b/net/core/xdp.c
@@ -345,7 +345,8 @@ static void __xdp_return(void *data, struct xdp_mem_info *mem, bool napi_direct,
rcu_read_lock();
/* mem->id is valid, checked in xdp_rxq_info_reg_mem_model() */
xa = rhashtable_lookup(mem_id_ht, &mem->id, mem_id_rht_params);
- xa->zc_alloc->free(xa->zc_alloc, handle);
+ if (!WARN_ON_ONCE(!xa))
+ xa->zc_alloc->free(xa->zc_alloc, handle);
rcu_read_unlock();
default:
/* Not possible, checked in xdp_rxq_info_reg_mem_model() */
--
2.9.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH V3 bpf] xdp: add NULL pointer check in __xdp_return()
2018-07-26 14:17 [PATCH V3 bpf] xdp: add NULL pointer check in __xdp_return() Taehee Yoo
@ 2018-07-26 16:02 ` Björn Töpel
2018-07-27 1:44 ` Daniel Borkmann
1 sibling, 0 replies; 3+ messages in thread
From: Björn Töpel @ 2018-07-26 16:02 UTC (permalink / raw)
To: Taehee Yoo
Cc: Daniel Borkmann, ast, Netdev, Björn Töpel,
Jesper Dangaard Brouer, kafai, Jakub Kicinski
Den tors 26 juli 2018 kl 16:18 skrev Taehee Yoo <ap420073@gmail.com>:
>
> rhashtable_lookup() can return NULL. so that NULL pointer
> check routine should be added.
>
Thanks Taehee!
Acked-by: Björn Töpel <bjorn.topel@intel.com>
> Fixes: 02b55e5657c3 ("xdp: add MEM_TYPE_ZERO_COPY")
> Acked-by: Martin KaFai Lau <kafai@fb.com>
> Signed-off-by: Taehee Yoo <ap420073@gmail.com>
> ---
> V3 : reduce code line
> V2 : add WARN_ON_ONCE when xa is NULL.
> net/core/xdp.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/net/core/xdp.c b/net/core/xdp.c
> index 9d1f220..6771f18 100644
> --- a/net/core/xdp.c
> +++ b/net/core/xdp.c
> @@ -345,7 +345,8 @@ static void __xdp_return(void *data, struct xdp_mem_info *mem, bool napi_direct,
> rcu_read_lock();
> /* mem->id is valid, checked in xdp_rxq_info_reg_mem_model() */
> xa = rhashtable_lookup(mem_id_ht, &mem->id, mem_id_rht_params);
> - xa->zc_alloc->free(xa->zc_alloc, handle);
> + if (!WARN_ON_ONCE(!xa))
> + xa->zc_alloc->free(xa->zc_alloc, handle);
> rcu_read_unlock();
> default:
> /* Not possible, checked in xdp_rxq_info_reg_mem_model() */
> --
> 2.9.3
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH V3 bpf] xdp: add NULL pointer check in __xdp_return()
2018-07-26 14:17 [PATCH V3 bpf] xdp: add NULL pointer check in __xdp_return() Taehee Yoo
2018-07-26 16:02 ` Björn Töpel
@ 2018-07-27 1:44 ` Daniel Borkmann
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Borkmann @ 2018-07-27 1:44 UTC (permalink / raw)
To: Taehee Yoo, ast; +Cc: netdev, bjorn.topel, brouer, kafai, jakub.kicinski
On 07/26/2018 04:17 PM, Taehee Yoo wrote:
> rhashtable_lookup() can return NULL. so that NULL pointer
> check routine should be added.
>
> Fixes: 02b55e5657c3 ("xdp: add MEM_TYPE_ZERO_COPY")
> Acked-by: Martin KaFai Lau <kafai@fb.com>
> Signed-off-by: Taehee Yoo <ap420073@gmail.com>
Applied to bpf, thanks Taehee!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-07-27 3:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-26 14:17 [PATCH V3 bpf] xdp: add NULL pointer check in __xdp_return() Taehee Yoo
2018-07-26 16:02 ` Björn Töpel
2018-07-27 1:44 ` Daniel Borkmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).