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]
Message-ID: <20170103084418.GC30111@dhcp22.suse.cz>
Date:   Tue, 3 Jan 2017 09:44:19 +0100
From:   Michal Hocko <mhocko@...nel.org>
To:     Anshuman Khandual <khandual@...ux.vnet.ibm.com>
Cc:     linux-kernel@...r.kernel.org, linux-mm@...ck.org, vbabka@...e.cz,
        akpm@...ux-foundation.org
Subject: Re: [RFC] nodemask: Consider MAX_NUMNODES inside node_isset

On Tue 03-01-17 13:57:53, Anshuman Khandual wrote:
> node_isset can give incorrect result if the node number is beyond the
> bitmask size (MAX_NUMNODES in this case) which is not checked inside
> test_bit. Hence check for the bit limits (MAX_NUMNODES) inside the
> node_isset function before calling test_bit.

Could you be more specific when such a thing might happen? Have you seen
any in-kernel user who would give such a bogus node?

> Signed-off-by: Anshuman Khandual <khandual@...ux.vnet.ibm.com>
> ---
>  include/linux/nodemask.h | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h
> index 6e66cfd..0aee588b 100644
> --- a/include/linux/nodemask.h
> +++ b/include/linux/nodemask.h
> @@ -139,7 +139,13 @@ static inline void __nodes_clear(nodemask_t *dstp, unsigned int nbits)
>  }
>  
>  /* No static inline type checking - see Subtlety (1) above. */
> -#define node_isset(node, nodemask) test_bit((node), (nodemask).bits)
> +#define node_isset(node, nodemask) node_test_bit(node, nodemask, MAX_NUMNODES)
> +static inline int node_test_bit(int node, nodemask_t nodemask, int maxnodes)
> +{
> +	if (node >= maxnodes)
> +		return 0;
> +	return test_bit((node), (nodemask).bits);
> +}
>  
>  #define node_test_and_set(node, nodemask) \
>  			__node_test_and_set((node), &(nodemask))
> -- 
> 1.8.3.1
> 

-- 
Michal Hocko
SUSE Labs

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ