[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180725205025.2v2z6dbahbpn4rlk@kafai-mbp.dhcp.thefacebook.com>
Date: Wed, 25 Jul 2018 13:50:25 -0700
From: Martin KaFai Lau <kafai@...com>
To: Taehee Yoo <ap420073@...il.com>
CC: <daniel@...earbox.net>, <ast@...nel.org>, <bjorn.topel@...el.com>,
<brouer@...hat.com>, <netdev@...r.kernel.org>
Subject: Re: [PATCH V2 bpf] xdp: add NULL pointer check in __xdp_return()
On Thu, Jul 26, 2018 at 12:09:50AM +0900, 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")
> Signed-off-by: Taehee Yoo <ap420073@...il.com>
Acked-by: Martin KaFai Lau <kafai@...com>
> ---
> V2 : add WARN_ON_ONCE when xa is NULL.
>
> net/core/xdp.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/net/core/xdp.c b/net/core/xdp.c
> index 9d1f220..786fdbe 100644
> --- a/net/core/xdp.c
> +++ b/net/core/xdp.c
> @@ -345,7 +345,10 @@ 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 (!xa)
> + WARN_ON_ONCE(1);
> + else
> + 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
>
Powered by blists - more mailing lists