* [PATCH v2] mtd: ubi: Added a check for ubi_num
@ 2024-12-02 9:36 Denis Arefev
2024-12-02 11:05 ` Zhihao Cheng
0 siblings, 1 reply; 4+ messages in thread
From: Denis Arefev @ 2024-12-02 9:36 UTC (permalink / raw)
To: Richard Weinberger
Cc: Zhihao Cheng, Miquel Raynal, Vignesh Raghavendra,
Artem Bityutskiy, linux-mtd, linux-kernel, lvc-project, stable
Added a check for ubi_num for negative numbers
If the variable ubi_num takes negative values then we get:
qemu-system-arm ... -append "ubi.mtd=0,0,0,-22222345" ...
[ 0.745065] ubi_attach_mtd_dev from ubi_init+0x178/0x218
[ 0.745230] ubi_init from do_one_initcall+0x70/0x1ac
[ 0.745344] do_one_initcall from kernel_init_freeable+0x198/0x224
[ 0.745474] kernel_init_freeable from kernel_init+0x18/0x134
[ 0.745600] kernel_init from ret_from_fork+0x14/0x28
[ 0.745727] Exception stack(0x90015fb0 to 0x90015ff8)
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 83ff59a06663 ("UBI: support ubi_num on mtd.ubi command line")
Cc: stable@vger.kernel.org
Signed-off-by: Denis Arefev <arefev@swemel.ru>
---
V1 -> V2: changed the tag Fixes and moved the check to ubi_mtd_param_parse()
drivers/mtd/ubi/build.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 30be4ed68fad..ef6a22f372f9 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -1537,7 +1537,7 @@ static int ubi_mtd_param_parse(const char *val, const struct kernel_param *kp)
if (token) {
int err = kstrtoint(token, 10, &p->ubi_num);
- if (err) {
+ if (err || p->ubi_num < UBI_DEV_NUM_AUTO) {
pr_err("UBI error: bad value for ubi_num parameter: %s\n",
token);
return -EINVAL;
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v2] mtd: ubi: Added a check for ubi_num
2024-12-02 9:36 [PATCH v2] mtd: ubi: Added a check for ubi_num Denis Arefev
@ 2024-12-02 11:05 ` Zhihao Cheng
0 siblings, 0 replies; 4+ messages in thread
From: Zhihao Cheng @ 2024-12-02 11:05 UTC (permalink / raw)
To: Denis Arefev, Richard Weinberger
Cc: Miquel Raynal, Vignesh Raghavendra, Artem Bityutskiy, linux-mtd,
linux-kernel, lvc-project, stable
在 2024/12/2 17:36, Denis Arefev 写道:
> Added a check for ubi_num for negative numbers
> If the variable ubi_num takes negative values then we get:
>
> qemu-system-arm ... -append "ubi.mtd=0,0,0,-22222345" ...
> [ 0.745065] ubi_attach_mtd_dev from ubi_init+0x178/0x218
> [ 0.745230] ubi_init from do_one_initcall+0x70/0x1ac
> [ 0.745344] do_one_initcall from kernel_init_freeable+0x198/0x224
> [ 0.745474] kernel_init_freeable from kernel_init+0x18/0x134
> [ 0.745600] kernel_init from ret_from_fork+0x14/0x28
> [ 0.745727] Exception stack(0x90015fb0 to 0x90015ff8)
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Fixes: 83ff59a06663 ("UBI: support ubi_num on mtd.ubi command line")
> Cc: stable@vger.kernel.org
> Signed-off-by: Denis Arefev <arefev@swemel.ru>
> ---
> V1 -> V2: changed the tag Fixes and moved the check to ubi_mtd_param_parse()
> drivers/mtd/ubi/build.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
>
> diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
> index 30be4ed68fad..ef6a22f372f9 100644
> --- a/drivers/mtd/ubi/build.c
> +++ b/drivers/mtd/ubi/build.c
> @@ -1537,7 +1537,7 @@ static int ubi_mtd_param_parse(const char *val, const struct kernel_param *kp)
> if (token) {
> int err = kstrtoint(token, 10, &p->ubi_num);
>
> - if (err) {
> + if (err || p->ubi_num < UBI_DEV_NUM_AUTO) {
> pr_err("UBI error: bad value for ubi_num parameter: %s\n",
> token);
> return -EINVAL;
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] mtd: ubi: Added a check for ubi_num
@ 2024-11-26 12:54 Denis Arefev
2024-11-26 14:04 ` Zhihao Cheng
0 siblings, 1 reply; 4+ messages in thread
From: Denis Arefev @ 2024-11-26 12:54 UTC (permalink / raw)
To: Richard Weinberger
Cc: Zhihao Cheng, Miquel Raynal, Vignesh Raghavendra,
Artem Bityutskiy, linux-mtd, linux-kernel, stable
Added a check for ubi_num for negative numbers
If the variable ubi_num takes negative values then we get:
qemu-system-arm ... -append "ubi.mtd=0,0,0,-22222345" ...
[ 0.745065] ubi_attach_mtd_dev from ubi_init+0x178/0x218
[ 0.745230] ubi_init from do_one_initcall+0x70/0x1ac
[ 0.745344] do_one_initcall from kernel_init_freeable+0x198/0x224
[ 0.745474] kernel_init_freeable from kernel_init+0x18/0x134
[ 0.745600] kernel_init from ret_from_fork+0x14/0x28
[ 0.745727] Exception stack(0x90015fb0 to 0x90015ff8)
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 83ff59a06663 ("UBI: support ubi_num on mtd.ubi command line")
Cc: stable@vger.kernel.org
Signed-off-by: Denis Arefev <arefev@swemel.ru>
---
V1 -> V2: changed the tag Fixes and moved the check to ubi_mtd_param_parse()
drivers/mtd/ubi/build.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 30be4ed68fad..ef6a22f372f9 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -1537,7 +1537,7 @@ static int ubi_mtd_param_parse(const char *val, const struct kernel_param *kp)
if (token) {
int err = kstrtoint(token, 10, &p->ubi_num);
- if (err) {
+ if (err || p->ubi_num < UBI_DEV_NUM_AUTO) {
pr_err("UBI error: bad value for ubi_num parameter: %s\n",
token);
return -EINVAL;
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v2] mtd: ubi: Added a check for ubi_num
2024-11-26 12:54 Denis Arefev
@ 2024-11-26 14:04 ` Zhihao Cheng
0 siblings, 0 replies; 4+ messages in thread
From: Zhihao Cheng @ 2024-11-26 14:04 UTC (permalink / raw)
To: Denis Arefev, Richard Weinberger
Cc: Miquel Raynal, Vignesh Raghavendra, Artem Bityutskiy, linux-mtd,
linux-kernel, stable
在 2024/11/26 20:54, Denis Arefev 写道:
> Added a check for ubi_num for negative numbers
> If the variable ubi_num takes negative values then we get:
>
> qemu-system-arm ... -append "ubi.mtd=0,0,0,-22222345" ...
> [ 0.745065] ubi_attach_mtd_dev from ubi_init+0x178/0x218
> [ 0.745230] ubi_init from do_one_initcall+0x70/0x1ac
> [ 0.745344] do_one_initcall from kernel_init_freeable+0x198/0x224
> [ 0.745474] kernel_init_freeable from kernel_init+0x18/0x134
> [ 0.745600] kernel_init from ret_from_fork+0x14/0x28
> [ 0.745727] Exception stack(0x90015fb0 to 0x90015ff8)
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Fixes: 83ff59a06663 ("UBI: support ubi_num on mtd.ubi command line")
> Cc: stable@vger.kernel.org
> Signed-off-by: Denis Arefev <arefev@swemel.ru>
> ---
> V1 -> V2: changed the tag Fixes and moved the check to ubi_mtd_param_parse()
> drivers/mtd/ubi/build.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
>
> diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
> index 30be4ed68fad..ef6a22f372f9 100644
> --- a/drivers/mtd/ubi/build.c
> +++ b/drivers/mtd/ubi/build.c
> @@ -1537,7 +1537,7 @@ static int ubi_mtd_param_parse(const char *val, const struct kernel_param *kp)
> if (token) {
> int err = kstrtoint(token, 10, &p->ubi_num);
>
> - if (err) {
> + if (err || p->ubi_num < UBI_DEV_NUM_AUTO) {
> pr_err("UBI error: bad value for ubi_num parameter: %s\n",
> token);
> return -EINVAL;
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-12-02 11:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-02 9:36 [PATCH v2] mtd: ubi: Added a check for ubi_num Denis Arefev
2024-12-02 11:05 ` Zhihao Cheng
-- strict thread matches above, loose matches on Subject: below --
2024-11-26 12:54 Denis Arefev
2024-11-26 14:04 ` Zhihao Cheng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox