Skip to contentSkip to conversation

kcsan: Use GFP_ATOMIC under spin lock

PATCH Applied Wei Yongjun 3 participants 3 messages Apr 17, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kcsan: Use GFP_ATOMIC under spin lock

A spin lock is taken here so we should use GFP_ATOMIC.

---
 kernel/kcsan/debugfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/kcsan/debugfs.c +2 -2
index 1a08664a7fab..023e49c58d55 100644
@@ -230,7 +230,7 @@ static ssize_t insert_report_filterlist(const char *func)
 		/* initial allocation */
 		report_filterlist.addrs =
 			kmalloc_array(report_filterlist.size,
-				      sizeof(unsigned long), GFP_KERNEL);
+				      sizeof(unsigned long), GFP_ATOMIC);
 		if (report_filterlist.addrs == NULL) {
 			ret = -ENOMEM;
 			goto out;
@@ -240,7 +240,7 @@ static ssize_t insert_report_filterlist(const char *func)
 		size_t new_size = report_filterlist.size * 2;
 		unsigned long *new_addrs =
 			krealloc(report_filterlist.addrs,
-				 new_size * sizeof(unsigned long), GFP_KERNEL);
+				 new_size * sizeof(unsigned long), GFP_ATOMIC);
 
 		if (new_addrs == NULL) {
 			/* leave filterlist itself untouched */
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Wei Yongjun

A spin lock is taken here so we should use GFP_ATOMIC.

Good catch, thank you!

Quoted 29 lines
---
 kernel/kcsan/debugfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/kcsan/debugfs.c +2 -2
index 1a08664a7fab..023e49c58d55 100644
@@ -230,7 +230,7 @@ static ssize_t insert_report_filterlist(const char *func)
                /* initial allocation */
                report_filterlist.addrs >                         kmalloc_array(report_filterlist.size,
-                                     sizeof(unsigned long), GFP_KERNEL);
+                                     sizeof(unsigned long), GFP_ATOMIC);
                if (report_filterlist.addrs = NULL) {
                        ret = -ENOMEM;
                        goto out;
@@ -240,7 +240,7 @@ static ssize_t insert_report_filterlist(const char *func)
                size_t new_size = report_filterlist.size * 2;
                unsigned long *new_addrs >                         krealloc(report_filterlist.addrs,
-                                new_size * sizeof(unsigned long), GFP_KERNEL);
+                                new_size * sizeof(unsigned long), GFP_ATOMIC);
 
                if (new_addrs = NULL) {
                        /* leave filterlist itself untouched */
 
#2 lore raw
Quoted 9 lines · Marco Elver
Quoted 4 lines · Wei Yongjun

A spin lock is taken here so we should use GFP_ATOMIC.

Good catch, thank you!

Queued and pushed, thank you both!

Thanx, Paul

Quoted 29 lines
Quoted 29 lines
---
 kernel/kcsan/debugfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/kcsan/debugfs.c +2 -2
index 1a08664a7fab..023e49c58d55 100644
@@ -230,7 +230,7 @@ static ssize_t insert_report_filterlist(const char *func)
                /* initial allocation */
                report_filterlist.addrs > >                         kmalloc_array(report_filterlist.size,
-                                     sizeof(unsigned long), GFP_KERNEL);
+                                     sizeof(unsigned long), GFP_ATOMIC);
                if (report_filterlist.addrs = NULL) {
                        ret = -ENOMEM;
                        goto out;
@@ -240,7 +240,7 @@ static ssize_t insert_report_filterlist(const char *func)
                size_t new_size = report_filterlist.size * 2;
                unsigned long *new_addrs > >                         krealloc(report_filterlist.addrs,
-                                new_size * sizeof(unsigned long), GFP_KERNEL);
+                                new_size * sizeof(unsigned long), GFP_ATOMIC);
 
                if (new_addrs = NULL) {
                        /* leave filterlist itself untouched */