[linux] 01/02: cpumask: use nr_cpumask_bits for parsing functions (Closes: #848682)

debian-kernel at lists.debian.org debian-kernel at lists.debian.org
Tue Feb 7 01:44:41 UTC 2017


This is an automated email from the git hooks/post-receive script.

benh pushed a commit to branch sid
in repository linux.

commit abd788f1da45687579fe905729ab9b82bf3c62d5
Author: Ben Hutchings <ben at decadent.org.uk>
Date:   Tue Feb 7 01:40:13 2017 +0000

    cpumask: use nr_cpumask_bits for parsing functions (Closes: #848682)
---
 debian/changelog                                   |  1 +
 ...use-nr_cpumask_bits-for-parsing-functions.patch | 77 ++++++++++++++++++++++
 debian/patches/series                              |  1 +
 3 files changed, 79 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 94a7dfe..9ac310f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -126,6 +126,7 @@ linux (4.9.8-1) UNRELEASED; urgency=medium
     - radix-tree: use local locks
     - softirq: wake the timer softirq if needed
     - cpuset: Convert callback_lock to raw_spinlock_t
+  * cpumask: use nr_cpumask_bits for parsing functions (Closes: #848682)
 
   [ Roger Shimizu ]
   * [armel] ARM: dts: orion5x-lschl: Fix model name
diff --git a/debian/patches/bugfix/all/cpumask-use-nr_cpumask_bits-for-parsing-functions.patch b/debian/patches/bugfix/all/cpumask-use-nr_cpumask_bits-for-parsing-functions.patch
new file mode 100644
index 0000000..1d36806
--- /dev/null
+++ b/debian/patches/bugfix/all/cpumask-use-nr_cpumask_bits-for-parsing-functions.patch
@@ -0,0 +1,77 @@
+Date: Mon, 6 Feb 2017 13:24:42 -0500
+From: Tejun Heo <tj at kernel.org>
+Subject: cpumask: use nr_cpumask_bits for parsing functions
+Bug-Debian: https://bugs.debian.org/848682
+Origin: https://lkml.org/lkml/2017/2/6/720
+
+513e3d2d11c9 ("cpumask: always use nr_cpu_ids in formatting and
+parsing functions") converted both cpumask printing and parsing
+functions to use nr_cpu_ids instead of nr_cpumask_bits.  While this
+was okay for the printing functions as it just picked one of the two
+output formats that we were alternating between depending on a kernel
+config, doing the same for parsing wasn't okay.
+
+nr_cpumask_bits can be either nr_cpu_ids or NR_CPUS.  We can always
+use nr_cpu_ids but that is a variable while NR_CPUS is a constant, so
+it can be more efficient to use NR_CPUS when we can get away with it.
+Converting the printing functions to nr_cpu_ids makes sense because it
+affects how the masks get presented to userspace and doesn't break
+anything; however, using nr_cpu_ids for parsing functions can
+incorrectly leave the higher bits uninitialized while reading in these
+masks from userland.  As all testing and comparison functions use
+nr_cpumask_bits which can be larger than nr_cpu_ids, the parsed
+cpumasks can erroneously yield false negative results.
+
+This made the taskstats interface incorrectly return -EINVAL even when
+the inputs were correct.
+
+Fix it by restoring the parse functions to use nr_cpumask_bits instead
+of nr_cpu_ids.
+
+Signed-off-by: Tejun Heo <tj at kernel.org>
+Fixes: 513e3d2d11c9 ("cpumask: always use nr_cpu_ids in formatting and parsing functions")
+Cc: stable at vger.kernel.org # v4.0+
+Reported-by: Martin Steigerwald <martin.steigerwald at teamix.de>
+Debugged-by: Ben Hutchings <ben.hutchings at codethink.co.uk>
+---
+ include/linux/cpumask.h |    8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+--- a/include/linux/cpumask.h
++++ b/include/linux/cpumask.h
+@@ -560,7 +560,7 @@ static inline void cpumask_copy(struct c
+ static inline int cpumask_parse_user(const char __user *buf, int len,
+ 				     struct cpumask *dstp)
+ {
+-	return bitmap_parse_user(buf, len, cpumask_bits(dstp), nr_cpu_ids);
++	return bitmap_parse_user(buf, len, cpumask_bits(dstp), nr_cpumask_bits);
+ }
+ 
+ /**
+@@ -575,7 +575,7 @@ static inline int cpumask_parselist_user
+ 				     struct cpumask *dstp)
+ {
+ 	return bitmap_parselist_user(buf, len, cpumask_bits(dstp),
+-				     nr_cpu_ids);
++				     nr_cpumask_bits);
+ }
+ 
+ /**
+@@ -590,7 +590,7 @@ static inline int cpumask_parse(const ch
+ 	char *nl = strchr(buf, '\n');
+ 	unsigned int len = nl ? (unsigned int)(nl - buf) : strlen(buf);
+ 
+-	return bitmap_parse(buf, len, cpumask_bits(dstp), nr_cpu_ids);
++	return bitmap_parse(buf, len, cpumask_bits(dstp), nr_cpumask_bits);
+ }
+ 
+ /**
+@@ -602,7 +602,7 @@ static inline int cpumask_parse(const ch
+  */
+ static inline int cpulist_parse(const char *buf, struct cpumask *dstp)
+ {
+-	return bitmap_parselist(buf, cpumask_bits(dstp), nr_cpu_ids);
++	return bitmap_parselist(buf, cpumask_bits(dstp), nr_cpumask_bits);
+ }
+ 
+ /**
diff --git a/debian/patches/series b/debian/patches/series
index 1daceb9..7b8d419 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -74,6 +74,7 @@ bugfix/all/partially-revert-usb-kconfig-using-select-for-usb_co.patch
 bugfix/all/nbd-use-loff_t-for-blocksize-and-nbd_set_size-args.patch
 bugfix/all/ath9k-fix-null-pointer-dereference.patch
 bugfix/all/nbd-fix-64-bit-division.patch
+bugfix/all/cpumask-use-nr_cpumask_bits-for-parsing-functions.patch
 
 # Miscellaneous features
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/kernel/linux.git



More information about the Kernel-svn-changes mailing list