Skip to contentSkip to conversation

UBI: Fix section mismatch

PATCH In review Andy Shevchenko 3 participants 10 messages Jan 10, 2017

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

PATCH v2 1/2 UBI: Fix section mismatch

WARNING: vmlinux.o(.text+0x1f2a80): Section mismatch in reference from the variable __param_ops_mtd to the function .init.text:ubi_mtd_param_parse() The function __param_ops_mtd() references
the function __init ubi_mtd_param_parse().
This is often because __param_ops_mtd lacks a __init
annotation or the annotation of ubi_mtd_param_parse is wrong.

Cc Richard Weinberger <[email protected]>
---
 drivers/mtd/ubi/build.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/mtd/ubi/build.c +4 -4
index 85d54f37e28f..54312431750b 100644
@@ -74,10 +74,10 @@ struct mtd_dev_param {
 };
 
 /* Numbers of elements set in the @mtd_dev_param array */
-static int __initdata mtd_devs;
+static int mtd_devs;
 
 /* MTD devices specification parameters */
-static struct mtd_dev_param __initdata mtd_dev_param[UBI_MAX_DEVICES];
+static struct mtd_dev_param mtd_dev_param[UBI_MAX_DEVICES];
 #ifdef CONFIG_MTD_UBI_FASTMAP
 /* UBI module parameter to enable fastmap automatically on non-fastmap images */
 static bool fm_autoconvert;
@@ -1351,7 +1351,7 @@ module_exit(ubi_exit);
  * This function returns positive resulting integer in case of success and a
  * negative error code in case of failure.
  */
-static int __init bytes_str_to_int(const char *str)
+static int bytes_str_to_int(const char *str)
 {
 	char *endp;
 	unsigned long result;
@@ -1389,7 +1389,7 @@ static int __init bytes_str_to_int(const char *str)
  * This function returns zero in case of success and a negative error code in
  * case of error.
  */
-static int __init ubi_mtd_param_parse(const char *val, struct kernel_param *kp)
+static int ubi_mtd_param_parse(const char *val, struct kernel_param *kp)
 {
 	int i, len;
 	struct mtd_dev_param *p;
Signature · 1 line
2.11.0
#1 lore raw

PATCH v2 2/2 UBI: Make mtd parameter readable

Fix permissions to allow read mtd parameter back (only for owner).

---
 drivers/mtd/ubi/build.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/ubi/build.c +1 -1
index 54312431750b..7bac790d4298 100644
@@ -1470,7 +1470,7 @@ static int ubi_mtd_param_parse(const char *val, struct kernel_param *kp)
 	return 0;
 }
 
-module_param_call(mtd, ubi_mtd_param_parse, NULL, NULL, 000);
+module_param_call(mtd, ubi_mtd_param_parse, NULL, NULL, 0400);
 MODULE_PARM_DESC(mtd, "MTD devices to attach. Parameter format: mtd=<name|num|path>[,<vid_hdr_offs>[,max_beb_per1024[,ubi_num]]].\n"
 		      "Multiple \"mtd\" parameters may be specified.\n"
 		      "MTD devices may be specified by their number, name, or path to the MTD character device node.\n"
Signature · 1 line
2.11.0
#2 lore raw

Re: [PATCH v2 2/2] UBI: Make mtd parameter readable

Andy,

Quoted 3 lines · Andy Shevchenko

Fix permissions to allow read mtd parameter back (only for owner).

Please CC all maintainers in future. Otherwise the chance is high that I'll miss a patch.

Quoted 9 lines
---
 drivers/mtd/ubi/build.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/ubi/build.c +0 -0
index 54312431750b..7bac790d4298 100644

drivers/mtd/ubi/build.c static int ubi_mtd_param_parse(const char *val, struct kernel_param *kp) · line 1476

Quoted 8 lines
drivers/mtd/ubi/build.c +1 -1
@@ -1470,7 +1470,7 @@ static int ubi_mtd_param_parse(const char *val, struct kernel_param *kp)
        return 0;
 }
 
-module_param_call(mtd, ubi_mtd_param_parse, NULL, NULL, 000);
+module_param_call(mtd, ubi_mtd_param_parse, NULL, NULL, 0400);
 MODULE_PARM_DESC(mtd, "MTD devices to attach. Parameter format: mtd=<name|num|path>[,<vid_hdr_offs>[,max_beb_per1024[,ubi_num]]].\n"
                      "Multiple \"mtd\" parameters may be specified.\n"
                      "MTD devices may be specified by their number, name, or path to the MTD character device node.\n"

What is the use case?
AFAIKT the permissions are 000 because a parser is involved and to "understand" the parameter,
a reader needs the ubi_mtd_param_parse() function.

Signature · 2 lines
Thanks,
//richard
#3 lore raw

Re: [PATCH v2 2/2] UBI: Make mtd parameter readable

Quoted 10 lines · Richard Weinberger

Andy,

Quoted 3 lines · Andy Shevchenko

Fix permissions to allow read mtd parameter back (only for owner).

Please CC all maintainers in future. Otherwise the chance is high that I'll miss a patch.

Noted.

Quoted 5 lines

drivers/mtd/ubi/build.c static int ubi_mtd_param_parse(const char *val, struct kernel_param *kp) · line 1473

Quoted 2 lines
drivers/mtd/ubi/build.c +1 -1
-module_param_call(mtd, ubi_mtd_param_parse, NULL, NULL, 000);
+module_param_call(mtd, ubi_mtd_param_parse, NULL, NULL, 0400);

What is the use case?
AFAIKT the permissions are 000

If it's not 0 in current case than you easily crash the kernel because parser will be gone at that time. This is fixed by patch 1.

Quoted 3 lines

because a parser is involved and to
"understand" the parameter,
a reader needs the ubi_mtd_param_parse() function.

Are you implying that writer is a bot and reader is human being? The use case is obvious (any security reasons are implied?) -- allow user to see what was written there in the first place.

Permissions 0000 are error prone.

Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
#4 lore raw

Re: [PATCH v2 2/2] UBI: Make mtd parameter readable

Am 10.01.2017 um 14:48 schrieb Andy Shevchenko:

Quoted 8 lines
Quoted 5 lines

drivers/mtd/ubi/build.c static int ubi_mtd_param_parse(const char *val, struct kernel_param *kp) · line 1473

Quoted 2 lines
drivers/mtd/ubi/build.c +1 -1
-module_param_call(mtd, ubi_mtd_param_parse, NULL, NULL, 000);
+module_param_call(mtd, ubi_mtd_param_parse, NULL, NULL, 0400);

What is the use case?
AFAIKT the permissions are 000

If it's not 0 in current case than you easily crash the kernel because parser will be gone at that time. This is fixed by patch 1.

Before your changes it was non-issue, right? ;)

Quoted 8 lines
Quoted 4 lines

because a parser is involved and to
"understand" the parameter,
a reader needs the ubi_mtd_param_parse() function.

Are you implying that writer is a bot and reader is human being? The use case is obvious (any security reasons are implied?) -- allow user to see what was written there in the first place.

I'm asking for the use case, why is exposing this parameter to user space a good thing? Who will use it?

Quoted 1 line

Permissions 0000 are error prone.

Why?

Thanks,
//richard

#5 lore raw

Re: [PATCH v2 2/2] UBI: Make mtd parameter readable

Quoted 11 lines · Richard Weinberger

Am 10.01.2017 um 14:48 schrieb Andy Shevchenko:

Quoted 8 lines
Quoted 4 lines

drivers/mtd/ubi/build.c static int ubi_mtd_param_parse(const char *val, struct kernel_param *kp) · line 1473

Quoted 2 lines
drivers/mtd/ubi/build.c +1 -1
-module_param_call(mtd, ubi_mtd_param_parse, NULL, NULL, 000);
+module_param_call(mtd, ubi_mtd_param_parse, NULL, NULL, 0400);

What is the use case?
AFAIKT the permissions are 000

If it's not 0 in current case than you easily crash the kernel because
parser will be gone at that time. This is fixed by patch 1.

Before your changes it was non-issue, right? ;)

If annoying section mismatch is not an issue, then yes, correct.

Quoted 11 lines
Quoted 7 lines
Quoted 3 lines

 because a parser is involved and to "understand" the parameter,
a reader needs the ubi_mtd_param_parse() function.

Are you implying that writer is a bot and reader is human being? The use case is obvious (any security reasons are implied?) -- allow user to see what was written there in the first place.

I'm asking for the use case, why is exposing this parameter to user space
a good thing? Who will use it?

Any user. I like the idea to have initial string to be stored somewhere and visible (imagine the case when it's module and history is gone). It might be useful for debugging (okay, this case perhaps not anymore, but in general).

Quoted 3 lines
Quoted 1 line

Permissions 0000 are error prone.

Why?

Because of a trick is being used here.

P.S. If you strongly against it I will give up, it doesn't cost my efforts anymore. That's why one of the possible "solution" is to put comment there for other brave guys.

Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
#6 lore raw

Re: [PATCH v2 2/2] UBI: Make mtd parameter readable

Am 10.01.2017 um 15:11 schrieb Andy Shevchenko:

Quoted 7 lines · Richard Weinberger
Quoted 6 lines

Am 10.01.2017 um 14:48 schrieb Andy Shevchenko:

Quoted 5 lines
Quoted 4 lines

drivers/mtd/ubi/build.c static int ubi_mtd_param_parse(const char *val, struct kernel_param *kp) · line 1473

Quoted 2 lines
drivers/mtd/ubi/build.c +1 -1
-module_param_call(mtd, ubi_mtd_param_parse, NULL, NULL, 000);
+module_param_call(mtd, ubi_mtd_param_parse, NULL, NULL, 0400);

What is the use case?
AFAIKT the permissions are 000

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

If it's not 0 in current case than you easily crash the kernel because
parser will be gone at that time. This is fixed by patch 1.

Before your changes it was non-issue, right? ;)

If annoying section mismatch is not an issue, then yes, correct.

Fixing the section mismatch is a good thing.

Quoted 17 lines
Quoted 11 lines
Quoted 7 lines
Quoted 3 lines

because a parser is involved and to
"understand" the parameter,
a reader needs the ubi_mtd_param_parse() function.

Are you implying that writer is a bot and reader is human being? The use case is obvious (any security reasons are implied?) -- allow user to see what was written there in the first place.

I'm asking for the use case, why is exposing this parameter to user space
a good thing? Who will use it?

Any user. I like the idea to have initial string to be stored somewhere and visible (imagine the case when it's module and history is gone). It might be useful for debugging (okay, this case perhaps not anymore, but in general).

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Permissions 0000 are error prone.

Why?

Because of a trick is being used here.

You are not really the answering questions kind of guy? ;-)

Quoted 3 lines

P.S. If you strongly against it I will give up, it doesn't cost my efforts anymore. That's why one of the possible "solution" is to put comment there for other brave guys.

I'm not at all against it, all I want to know why your patch improves the current situation what it fixes.

Did you check? Do other drivers in the kernel that have a parser behind a non-trivial module parameter also expose it to user space?

Thanks,
//richard

#7 lore raw

Re: [PATCH v2 2/2] UBI: Make mtd parameter readable

Quoted 11 lines · Richard Weinberger

Am 10.01.2017 um 15:11 schrieb Andy Shevchenko:

Quoted 8 lines · Richard Weinberger
Quoted 5 lines

Am 10.01.2017 um 14:48 schrieb Andy Shevchenko:

Quoted 1 line

Permissions 0000 are error prone.

Why?

Because of a trick is being used here.

You are not really the answering questions kind of guy? ;-)

You see, you have to keep in mind that you are not allowed to use anything except 0 because parser is gone, variable is gone. I'm talking about module_param_cb(..., 0) cases only.

Quoted 7 lines
Quoted 3 lines

P.S. If you strongly against it I will give up, it doesn't cost my efforts anymore. That's why one of the possible "solution" is to put comment there for other brave guys.

Did you check? Do other drivers in the kernel that have a parser behind a non-trivial
module parameter also expose it to user space?

Just checked. The only one which is not, this one.

Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
#8 lore raw

Re: [PATCH v2 2/2] UBI: Make mtd parameter readable

Andy,

Am 10.01.2017 um 15:35 schrieb Andy Shevchenko:

Quoted 6 lines
Quoted 3 lines

Did you check? Do other drivers in the kernel that have a parser behind a non-trivial
module parameter also expose it to user space?

Just checked. The only one which is not, this one.

That's an excellent reason. :-)
But I see also:
mtd/devices/phram.c:module_param_call(phram, phram_param_call, NULL, NULL, 000);

If these two are the only users of 000, let's rip them out to be consistent with the rest of the kernel.

Thanks,
//richard

#9 lore raw

Re: [PATCH v2 2/2] UBI: Make mtd parameter readable

Quoted 10 lines · Richard Weinberger

Andy,

Am 10.01.2017 um 15:35 schrieb Andy Shevchenko:

Quoted 6 lines
Quoted 3 lines

Did you check? Do other drivers in the kernel that have a parser behind a non-trivial
module parameter also expose it to user space?

Just checked. The only one which is not, this one.

Quoted 8 lines

That's an excellent reason. :-)
But I see also:
mtd/devices/phram.c:module_param_call(phram, phram_param_call, NULL, NULL, 000);

If these two are the only users of 000, let's rip them out to be consistent
with the rest of the kernel.

Okay, this is full(?) list of those. 3 drivers.

$ git grep -n 'module_param_call(.*, 0\+)' drivers/
drivers/ide/ide.c:277:module_param_call(chs, ide_set_disk_chs, NULL,
NULL, 0);
drivers/ide/ide.c:351:module_param_call(ignore_cable,
ide_set_ignore_cable, NULL, NULL, 0);
drivers/mtd/devices/phram.c:301:module_param_call(phram,
phram_param_call, NULL, NULL, 000);
drivers/platform/x86/thinkpad_acpi.c:9666:      module_param_call(featur
e, set_ibm_param, NULL, NULL, 0); \
$ git grep -n 'module_param_cb(.*, 0\+)' drivers/
drivers/mtd/ubi/block.c:168:module_param_cb(block, &ubiblock_param_ops,
NULL, 0);

I doubt about worth to fix IDE (last time I sent clean up maintainer told me not to do).

For thinkpad I will look at.

For MTD let's do it now.

So, would you like me to resend with / send separate fix to the other one?

Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy