Patch "kernel: Initialize cpumask before parsing" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    kernel: Initialize cpumask before parsing

to the 5.10-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:
     kernel-initialize-cpumask-before-parsing.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 4ed2729e83ef221f19201abd4ef243db1e164f40
Author: Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx>
Date:   Thu Apr 1 14:58:23 2021 +0900

    kernel: Initialize cpumask before parsing
    
    [ Upstream commit c5e3a41187ac01425f5ad1abce927905e4ac44e4 ]
    
    KMSAN complains that new_value at cpumask_parse_user() from
    write_irq_affinity() from irq_affinity_proc_write() is uninitialized.
    
      [  148.133411][ T5509] =====================================================
      [  148.135383][ T5509] BUG: KMSAN: uninit-value in find_next_bit+0x325/0x340
      [  148.137819][ T5509]
      [  148.138448][ T5509] Local variable ----new_value.i@irq_affinity_proc_write created at:
      [  148.140768][ T5509]  irq_affinity_proc_write+0xc3/0x3d0
      [  148.142298][ T5509]  irq_affinity_proc_write+0xc3/0x3d0
      [  148.143823][ T5509] =====================================================
    
    Since bitmap_parse() from cpumask_parse_user() calls find_next_bit(),
    any alloc_cpumask_var() + cpumask_parse_user() sequence has possibility
    that find_next_bit() accesses uninitialized cpu mask variable. Fix this
    problem by replacing alloc_cpumask_var() with zalloc_cpumask_var().
    
    Signed-off-by: Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
    Acked-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20210401055823.3929-1-penguin-kernel@xxxxxxxxxxxxxxxxxxx
    Stable-dep-of: 98feccbf32cf ("tracing: Prevent bad count for tracing_cpumask_write")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c
index 72513ed2a5fc..0df62a3a1f37 100644
--- a/kernel/irq/proc.c
+++ b/kernel/irq/proc.c
@@ -144,7 +144,7 @@ static ssize_t write_irq_affinity(int type, struct file *file,
 	if (!irq_can_set_affinity_usr(irq) || no_irq_affinity)
 		return -EIO;
 
-	if (!alloc_cpumask_var(&new_value, GFP_KERNEL))
+	if (!zalloc_cpumask_var(&new_value, GFP_KERNEL))
 		return -ENOMEM;
 
 	if (type)
@@ -238,7 +238,7 @@ static ssize_t default_affinity_write(struct file *file,
 	cpumask_var_t new_value;
 	int err;
 
-	if (!alloc_cpumask_var(&new_value, GFP_KERNEL))
+	if (!zalloc_cpumask_var(&new_value, GFP_KERNEL))
 		return -ENOMEM;
 
 	err = cpumask_parse_user(buffer, count, new_value);
diff --git a/kernel/profile.c b/kernel/profile.c
index 737b1c704aa8..0db1122855c0 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -438,7 +438,7 @@ static ssize_t prof_cpu_mask_proc_write(struct file *file,
 	cpumask_var_t new_value;
 	int err;
 
-	if (!alloc_cpumask_var(&new_value, GFP_KERNEL))
+	if (!zalloc_cpumask_var(&new_value, GFP_KERNEL))
 		return -ENOMEM;
 
 	err = cpumask_parse_user(buffer, count, new_value);
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 9f5b9036f001..3ecd7c700579 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -4910,7 +4910,7 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf,
 	cpumask_var_t tracing_cpumask_new;
 	int err;
 
-	if (!alloc_cpumask_var(&tracing_cpumask_new, GFP_KERNEL))
+	if (!zalloc_cpumask_var(&tracing_cpumask_new, GFP_KERNEL))
 		return -ENOMEM;
 
 	err = cpumask_parse_user(ubuf, count, tracing_cpumask_new);




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux