Patch "radix-tree: must check __radix_tree_preload() return value" has been added to the 4.12-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
radix-tree: must check __radix_tree_preload() return value
to the 4.12-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
radix-tree-must-check-__radix_tree_preload-return-value.patch
and it can be found in the queue-4.12 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
bc9ae2247ac92fd4d962507bafa3afffff6660ffMon Sep 17 00:00:00 2001
From: Eric Dumazet <[email protected]>
Date: Fri, 8 Sep 2017 16:15:54 -0700
Subject: radix-tree: must check __radix_tree_preload() return value
From: Eric Dumazet <[email protected]>
commit bc9ae2247ac92fd4d962507bafa3afffff6660ff upstream.
__radix_tree_preload() only disables preemption if no error is returned.
So we really need to make sure callers always check the return value.
idr_preload() contract is to always disable preemption, so we need to add a missing preempt_disable() if an error happened.
Similarly, ida_pre_get() only needs to call preempt_enable() in the case no error happened.
--- lib/radix-tree.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
lib/radix-tree.c +5 -4
@@ -463,7 +463,7 @@ radix_tree_node_free(struct radix_tree_n* To make use of this facility, the radix tree must be initialised without * __GFP_DIRECT_RECLAIM being passed to INIT_RADIX_TREE(). */ -static int __radix_tree_preload (gfp_t gfp_mask,unsigned nr) +static __must_check int __radix_tree_preload (gfp_t gfp_mask,unsigned nr) {struct radix_tree_preload *rtp;struct radix_tree_node *node;
@@ -2103,7 +2103,8 @@ EXPORT_SYMBOL(radix_tree_tagged);*/ void idr_preload (gfp_t gfp_mask) { -__radix_tree_preload (gfp_mask,IDR_PRELOAD_SIZE ); +if (__radix_tree_preload (gfp_mask,IDR_PRELOAD_SIZE )) +preempt_disable (); }EXPORT_SYMBOL (idr_preload);
@@ -2117,13 +2118,13 @@ EXPORT_SYMBOL(idr_preload);*/ int ida_pre_get (struct ida *ida,gfp_t gfp) { -__radix_tree_preload (gfp,IDA_PRELOAD_SIZE );/* * The IDA API has no preload_end() equivalent. Instead, * ida_get_new() can return -EAGAIN, prompting the caller * to return to the ida_pre_get() step. */ -preempt_enable (); +if (!__radix_tree_preload (gfp,IDA_PRELOAD_SIZE )) +preempt_enable ();if (!this_cpu_read (ida_bitmap)) {struct ida_bitmap *bitmap =kmalloc (sizeof (*bitmap), gfp);
Patches currently in stable-queue which might be from [email protected] are
queue-4.12/radix-tree-must-check-__radix_tree_preload-return-value.patch