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:   Wed, 23 Dec 2020 23:31:58 -0800
From:   Yonghong Song <yhs@...com>
To:     YANG LI <abaci-bugfix@...ux.alibaba.com>, <ast@...nel.org>
CC:     <daniel@...earbox.net>, <davem@...emloft.net>, <kuba@...nel.org>,
        <hawk@...nel.org>, <john.fastabend@...il.com>, <andrii@...nel.org>,
        <kafai@...com>, <songliubraving@...com>, <kpsingh@...nel.org>,
        <netdev@...r.kernel.org>, <bpf@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] bpf: fix: address of local auto-variable assigned to a
 function parameter.



On 12/23/20 11:01 PM, YANG LI wrote:
> Assigning local variable txq to the outputting parameter xdp->txq is not
> safe, txq will be released after the end of the function call.
> Then the result of using xdp is unpredictable.
> 
> Fix this error by defining the struct xdp_txq_info in function
> dev_map_run_prog() as a static type.
> 
> Signed-off-by: YANG LI <abaci-bugfix@...ux.alibaba.com>
> Reported-by: Abaci <abaci@...ux.alibaba.com>
> ---
>   kernel/bpf/devmap.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
> index f6e9c68..af6f004 100644
> --- a/kernel/bpf/devmap.c
> +++ b/kernel/bpf/devmap.c
> @@ -454,7 +454,7 @@ static struct xdp_buff *dev_map_run_prog(struct net_device *dev,
>   					 struct xdp_buff *xdp,
>   					 struct bpf_prog *xdp_prog)
>   {
> -	struct xdp_txq_info txq = { .dev = dev };
> +	static struct xdp_txq_info txq = { .dev = dev };
>   	u32 act;
>   
>   	xdp_set_data_meta_invalid(xdp);

exposing txq outside the routine with 'static' definition is not
a good practice. maybe just reset xdp->txq = NULl right before
function return?

diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
index f6e9c68afdd4..50f5c20a33a3 100644
--- a/kernel/bpf/devmap.c
+++ b/kernel/bpf/devmap.c
@@ -475,6 +475,7 @@ static struct xdp_buff *dev_map_run_prog(struct 
net_device *dev,
         }

         xdp_return_buff(xdp);
+       xdp->txq = NULL;
         return NULL;
  }

-bash-4.4$

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ