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-next>] [day] [month] [year] [list]
Date:	Thu, 6 Jan 2011 16:42:06 -0800 (PST)
From:	David Rientjes <rientjes@...gle.com>
To:	Andrew Morton <akpm@...ux-foundation.org>
cc:	mm-commits@...r.kernel.org, mhocko@...e.cz, caiqian@...hat.com,
	nacc@...ibm.com, linux-kernel@...r.kernel.org
Subject: Re: + hugetlb-handle-nodemask_alloc-failure-correctly.patch added
 to -mm tree

On Thu, 6 Jan 2011, akpm@...ux-foundation.org wrote:

> diff -puN mm/hugetlb.c~hugetlb-handle-nodemask_alloc-failure-correctly mm/hugetlb.c
> --- a/mm/hugetlb.c~hugetlb-handle-nodemask_alloc-failure-correctly
> +++ a/mm/hugetlb.c
> @@ -1374,14 +1374,19 @@ static ssize_t nr_hugepages_store_common
>  	struct hstate *h;
>  	NODEMASK_ALLOC(nodemask_t, nodes_allowed, GFP_KERNEL | __GFP_NORETRY);
>  
> +	if (!nodes_allowed) {
> +		err = -ENOMEM;
> +		goto out;
> +	}
> +
>  	err = strict_strtoul(buf, 10, &count);
>  	if (err)
> -		goto out;
> +		goto out_free_mask;
>  
>  	h = kobj_to_hstate(kobj, &nid);
>  	if (h->order >= MAX_ORDER) {
>  		err = -EINVAL;
> -		goto out;
> +		goto out_free_mask;
>  	}
>  
>  	if (nid == NUMA_NO_NODE) {
> @@ -1409,8 +1414,9 @@ static ssize_t nr_hugepages_store_common
>  		NODEMASK_FREE(nodes_allowed);
>  
>  	return len;
> -out:
> +out_free_mask:
>  	NODEMASK_FREE(nodes_allowed);
> +out:
>  	return err;
>  }
>  
> @@ -1886,6 +1892,12 @@ static int hugetlb_sysctl_handler_common
>  	if (write) {
>  		NODEMASK_ALLOC(nodemask_t, nodes_allowed,
>  						GFP_KERNEL | __GFP_NORETRY);
> +
> +		if (!nodes_allowed) {
> +			ret = -ENOMEM;
> +			goto out;
> +		}
> +
>  		if (!(obey_mempolicy &&
>  			       init_nodemask_of_mempolicy(nodes_allowed))) {
>  			NODEMASK_FREE(nodes_allowed);

This patch is wrong, both functions may handle a NULL nodes_allowed, which 
is why the __GFP_NORETRY is explicitly part of the gfp mask.

In both functions, init_nodemask_of_mempolicy() will immediately return 
false if the mask is NULL.  If so, it is set to node_states[N_HIGH_MEMORY] 
in the caller and we're careful to avoid calling the NODMASK_FREE() in 
that case.  They are carefully coded in this way so they operate over all 
nodes with memory rather than failing with -ENOMEM.

 [ On a seperate topic, all users of NODEMASK_ALLOC() that may gracefully 
   fail and have error handling should also use __GFP_NORETRY, such as in
   all the cpuset users. ]
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ