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:   Fri, 20 Jan 2023 15:40:39 +0000
From:   Dmitry Safonov <dima@...sta.com>
To:     Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>
Cc:     netdev@...r.kernel.org, eric.dumazet@...il.com,
        Steffen Klassert <steffen.klassert@...unet.com>,
        "David S . Miller" <davem@...emloft.net>,
        Paolo Abeni <pabeni@...hat.com>
Subject: Re: [PATCH net] xfrm/compat: prevent potential spectre v1 gadget in
 xfrm_xlate32_attr()

On 1/20/23 13:02, Eric Dumazet wrote:
>   int type = nla_type(nla);
> 
>   if (type > XFRMA_MAX) {
>             return -EOPNOTSUPP;
>   }
> 
> @type is then used as an array index and can be used
> as a Spectre v1 gadget.
> 
>   if (nla_len(nla) < compat_policy[type].len) {
> 
> array_index_nospec() can be used to prevent leaking
> content of kernel memory to malicious users.
> 
> Fixes: 5106f4a8acff ("xfrm/compat: Add 32=>64-bit messages translator")
> Signed-off-by: Eric Dumazet <edumazet@...gle.com>
> Cc: Dmitry Safonov <dima@...sta.com>
> Cc: Steffen Klassert <steffen.klassert@...unet.com>

Reviewed-by: Dmitry Safonov <dima@...sta.com>

Thanks, Eric!

> ---
>  net/xfrm/xfrm_compat.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/net/xfrm/xfrm_compat.c b/net/xfrm/xfrm_compat.c
> index a0f62fa02e06e0aa97901aaf226dc84895f6a8ec..46bb239e4f06d56abbf3deecd89ac26625efb560 100644
> --- a/net/xfrm/xfrm_compat.c
> +++ b/net/xfrm/xfrm_compat.c
> @@ -5,6 +5,7 @@
>   * Based on code and translator idea by: Florian Westphal <fw@...len.de>
>   */
>  #include <linux/compat.h>
> +#include <linux/nospec.h>
>  #include <linux/xfrm.h>
>  #include <net/xfrm.h>
>  
> @@ -437,6 +438,7 @@ static int xfrm_xlate32_attr(void *dst, const struct nlattr *nla,
>  		NL_SET_ERR_MSG(extack, "Bad attribute");
>  		return -EOPNOTSUPP;
>  	}
> +	type = array_index_nospec(type, XFRMA_MAX + 1);
>  	if (nla_len(nla) < compat_policy[type].len) {
>  		NL_SET_ERR_MSG(extack, "Attribute bad length");
>  		return -EOPNOTSUPP;

-- 
          Dmitry

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ