Skip to contentSkip to conversation

PM / devfreq: Fix kernel oops on governor module load

PATCH In review Ezequiel Garcia 4 participants 5 messages Jun 21, 2019 – Jul 11, 2019 Device frequency (devfreq)

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 PM / devfreq: Fix kernel oops on governor module load

A bit unexpectedly (but still documented), request_module may return a positive value, in case of a modprobe error. This is currently causing issues in the devfreq framework.

When a request_module exits with a positive value, we currently return that via ERR_PTR. However, because the value is positive, it's not a ERR_VALUE proper, and is therefore treated as a valid struct devfreq_governor pointer, leading to a kernel oops.

Fix this by returning -EINVAL if request_module returns a positive value.

Fixes b53b0128052ff ("PM / devfreq: Fix static checker warning in try_then_request_governor")

---
Changes from v1:
* Rework the fix as suggested by Enric and Chanwoo, handling the return vaue.

---
 drivers/devfreq/devfreq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/devfreq/devfreq.c +1 -1
index 6b6991f0e873..258f70c1e48f 100644
@@ -257,7 +257,7 @@ static struct devfreq_governor *try_then_request_governor(const char *name)
 		/* Restore previous state before return */
 		mutex_lock(&devfreq_list_lock);
 		if (err)
-			return ERR_PTR(err);
+			return (err < 0) ? ERR_PTR(err) : ERR_PTR(-EINVAL);
 
 		governor = find_devfreq_governor(name);
 	}
Signature · 1 line
2.20.1
Reviewed-by on v2 1/1
#1 lore raw

Hi,

2019년 6월 22일 (토) 오전 6:42, Ezequiel Garcia <[email protected]>님이 작성:

Quoted 28 lines

A bit unexpectedly (but still documented), request_module may return a positive value, in case of a modprobe error. This is currently causing issues in the devfreq framework.

When a request_module exits with a positive value, we currently return that via ERR_PTR. However, because the value is positive, it's not a ERR_VALUE proper, and is therefore treated as a valid struct devfreq_governor pointer, leading to a kernel oops.

Fix this by returning -EINVAL if request_module returns a positive value.

Fixes b53b0128052ff ("PM / devfreq: Fix static checker warning in try_then_request_governor")

---
Changes from v1:
* Rework the fix as suggested by Enric and Chanwoo, handling the return vaue.

---
 drivers/devfreq/devfreq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/devfreq/devfreq.c +0 -0
index 6b6991f0e873..258f70c1e48f 100644

drivers/devfreq/devfreq.c static struct devfreq_governor *try_then_request_governor(const char *name) · line 263

Quoted 8 lines
drivers/devfreq/devfreq.c +1 -1
@@ -257,7 +257,7 @@ static struct devfreq_governor *try_then_request_governor(const char *name)
                /* Restore previous state before return */
                mutex_lock(&devfreq_list_lock);
                if (err)
-                       return ERR_PTR(err);
+                       return (err < 0) ? ERR_PTR(err) : ERR_PTR(-EINVAL);
 
                governor = find_devfreq_governor(name);
        }

Thanks you for fix-up.

But, you are missing the stable mailing list. In order to apply this fix-up patch,\
you have to send it to stable mailing list. Please send it.

Signature · 2 lines
Best Regards,
Chanwoo Choi
#2 lore raw

Hello Chanwoo,

Quoted 40 lines · Chanwoo Choi

Hi,

2019년 6월 22일 (토) 오전 6:42, Ezequiel Garcia <[email protected]>님이 작성:

Quoted 27 lines

A bit unexpectedly (but still documented), request_module may return a positive value, in case of a modprobe error. This is currently causing issues in the devfreq framework.

When a request_module exits with a positive value, we currently return that via ERR_PTR. However, because the value is positive, it's not a ERR_VALUE proper, and is therefore treated as a valid struct devfreq_governor pointer, leading to a kernel oops.

Fix this by returning -EINVAL if request_module returns a positive value.

Fixes b53b0128052ff ("PM / devfreq: Fix static checker warning in try_then_request_governor")

---
Changes from v1:
* Rework the fix as suggested by Enric and Chanwoo, handling the return vaue.

---
 drivers/devfreq/devfreq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/devfreq/devfreq.c +0 -0
index 6b6991f0e873..258f70c1e48f 100644

drivers/devfreq/devfreq.c static struct devfreq_governor *try_then_request_governor(const char *name) · line 263

Quoted 8 lines
drivers/devfreq/devfreq.c +1 -1
@@ -257,7 +257,7 @@ static struct devfreq_governor *try_then_request_governor(const char *name)
                /* Restore previous state before return */
                mutex_lock(&devfreq_list_lock);
                if (err)
-                       return ERR_PTR(err);
+                       return (err < 0) ? ERR_PTR(err) : ERR_PTR(-EINVAL);
 
                governor = find_devfreq_governor(name);
        }

Thanks you for fix-up.

Quoted 7 lines

But, you are missing the stable mailing list. In order to apply this fix-up patch,\
you have to send it to stable mailing list. Please send it.

If I understand correctly, you or any of the devfreq maintainer can simply add a Cc: [email protected] tag.

This is documented as Option 1 in stable-kernel-rules.rst.

The Acked-by and Reviewed-by tags need to be collected anyway :-)

Thanks!
Eze

maintainer
#3 lore raw

Hi,

Quoted 45 lines · Ezequiel Garcia

Hello Chanwoo,

Quoted 42 lines · Chanwoo Choi

Hi,

2019년 6월 22일 (토) 오전 6:42, Ezequiel Garcia <[email protected]>님이 작성:

Quoted 27 lines

A bit unexpectedly (but still documented), request_module may return a positive value, in case of a modprobe error. This is currently causing issues in the devfreq framework.

When a request_module exits with a positive value, we currently return that via ERR_PTR. However, because the value is positive, it's not a ERR_VALUE proper, and is therefore treated as a valid struct devfreq_governor pointer, leading to a kernel oops.

Fix this by returning -EINVAL if request_module returns a positive value.

Fixes b53b0128052ff ("PM / devfreq: Fix static checker warning in try_then_request_governor")

---
Changes from v1:
* Rework the fix as suggested by Enric and Chanwoo, handling the return vaue.

---
 drivers/devfreq/devfreq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/devfreq/devfreq.c +0 -0
index 6b6991f0e873..258f70c1e48f 100644

drivers/devfreq/devfreq.c static struct devfreq_governor *try_then_request_governor(const char *name) · line 263

Quoted 8 lines
drivers/devfreq/devfreq.c +1 -1
@@ -257,7 +257,7 @@ static struct devfreq_governor *try_then_request_governor(const char *name)
                /* Restore previous state before return */
                mutex_lock(&devfreq_list_lock);
                if (err)
-                       return ERR_PTR(err);
+                       return (err < 0) ? ERR_PTR(err) : ERR_PTR(-EINVAL);
 
                governor = find_devfreq_governor(name);
        }

Thanks you for fix-up.

Quoted 8 lines
Quoted 5 lines

But, you are missing the stable mailing list. In order to apply this fix-up patch,\
you have to send it to stable mailing list. Please send it.

If I understand correctly, you or any of the devfreq maintainer can simply add a Cc: [email protected] tag.

Originally, the author have to send the stable mailing list with the required style. You can do it.

Quoted 4 lines

This is documented as Option 1 in stable-kernel-rules.rst.

The Acked-by and Reviewed-by tags need to be collected anyway :-)

This patch[1] was picked to devfreq.git.
[1] https://git.kernel.org/pub/scm/linux/kernel/git/mzx/devfreq.git/commit/?h=for-next&id=4f065f69ebc2bdf1fbe224816a3c471babd370dd

Quoted 6 lines

Thanks!
Eze

Signature · 3 lines
Best Regards,
Chanwoo Choi
Samsung Electronics
maintainer Acked-by on v2 1/1
#4 lore raw
In reply to Ezequiel Garcia
Quoted 14 lines

A bit unexpectedly (but still documented), request_module may return a positive value, in case of a modprobe error. This is currently causing issues in the devfreq framework.

When a request_module exits with a positive value, we currently return that via ERR_PTR. However, because the value is positive, it's not a ERR_VALUE proper, and is therefore treated as a valid struct devfreq_governor pointer, leading to a kernel oops.

Fix this by returning -EINVAL if request_module returns a positive value.

Fixes b53b0128052ff ("PM / devfreq: Fix static checker warning in try_then_request_governor")
Quoted 7 lines

---
Changes from v1:
* Rework the fix as suggested by Enric and Chanwoo, handling the return vaue.

---
 drivers/devfreq/devfreq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)