PM / devfreq: Fix kernel oops on governor module load
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.
---
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
@@ -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
Hi,
2019년 6월 22일 (토) 오전 6:42, Ezequiel Garcia <[email protected]>님이 작성:
Quoted 28 lines
A bit unexpectedly (but still documented),
request_modulemay return a positive value, in case of a modprobe error. This is currently causing issues in the devfreq framework.When a
request_moduleexits with a positive value, we currently return that viaERR_PTR. However, because the value is positive, it's not aERR_VALUEproper, and is therefore treated as a valid structdevfreq_governorpointer, leading to a kernel oops.Fix this by returning
-EINVALifrequest_modulereturns a positive value.Fixes b53b0128052ff ("PM / devfreq: Fix static checker warning in try_then_request_governor")Signed-off-by Ezequiel Garcia <[email protected]>---
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
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
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_modulemay return a positive value, in case of a modprobe error. This is currently causing issues in the devfreq framework.When a
request_moduleexits with a positive value, we currently return that viaERR_PTR. However, because the value is positive, it's not aERR_VALUEproper, and is therefore treated as a valid structdevfreq_governorpointer, leading to a kernel oops.Fix this by returning
-EINVALifrequest_modulereturns a positive value.Fixes b53b0128052ff ("PM / devfreq: Fix static checker warning in try_then_request_governor")Signed-off-by Ezequiel Garcia <[email protected]>---
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
-0drivers/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
Reviewed-by Chanwoo Choi <[email protected]>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
Chanwoo Choi
maintainerHi,
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_modulemay return a positive value, in case of a modprobe error. This is currently causing issues in the devfreq framework.When a
request_moduleexits with a positive value, we currently return that viaERR_PTR. However, because the value is positive, it's not aERR_VALUEproper, and is therefore treated as a valid structdevfreq_governorpointer, leading to a kernel oops.Fix this by returning
-EINVALifrequest_modulereturns a positive value.Fixes b53b0128052ff ("PM / devfreq: Fix static checker warning in try_then_request_governor")Signed-off-by Ezequiel Garcia <[email protected]>---
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
-0drivers/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.
Reviewed-by Chanwoo Choi <[email protected]>
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
Quoted 14 lines
A bit unexpectedly (but still documented),
request_modulemay return a positive value, in case of a modprobe error. This is currently causing issues in the devfreq framework.When a
request_moduleexits with a positive value, we currently return that viaERR_PTR. However, because the value is positive, it's not aERR_VALUEproper, and is therefore treated as a valid structdevfreq_governorpointer, leading to a kernel oops.Fix this by returning
-EINVALifrequest_modulereturns a positive value.Fixes b53b0128052ff ("PM / devfreq: Fix static checker warning in try_then_request_governor")Signed-off-by Ezequiel Garcia <[email protected]>
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(-)