* [PATCH v2 0/2] fs: bug fixes
@ 2025-04-11 15:31 Zijun Hu
2025-04-11 15:31 ` [PATCH v2 1/2] fs/fs_parse: Delete macro fsparam_u32hex() Zijun Hu
2025-04-11 15:31 ` [PATCH v2 2/2] fs/fs_parse: Fix 3 issues for validate_constant_table() Zijun Hu
0 siblings, 2 replies; 7+ messages in thread
From: Zijun Hu @ 2025-04-11 15:31 UTC (permalink / raw)
To: Alexander Viro, Christian Brauner, Jan Kara, David Howells,
Jonathan Corbet
Cc: Zijun Hu, linux-fsdevel, linux-kernel, linux-doc, Zijun Hu
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
Changes in v2:
- Drop applied patches and remove fixes tag for remaining patches
- Remove fsparam_u32hex() instead of fixing it
- Add more comment for the NULL pointer dereference issue
- Link to v1: https://lore.kernel.org/r/20250410-fix_fs-v1-0-7c14ccc8ebaa@quicinc.com
---
Zijun Hu (2):
fs/fs_parse: Delete macro fsparam_u32hex()
fs/fs_parse: Fix 3 issues for validate_constant_table()
Documentation/filesystems/mount_api.rst | 1 -
fs/fs_parser.c | 7 +++++--
include/linux/fs_parser.h | 2 --
3 files changed, 5 insertions(+), 5 deletions(-)
---
base-commit: 0af2f6be1b4281385b618cb86ad946eded089ac8
change-id: 20250410-fix_fs-6e0a97c4e59f
Best regards,
--
Zijun Hu <quic_zijuhu@quicinc.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/2] fs/fs_parse: Delete macro fsparam_u32hex()
2025-04-11 15:31 [PATCH v2 0/2] fs: bug fixes Zijun Hu
@ 2025-04-11 15:31 ` Zijun Hu
2025-04-14 13:17 ` Jan Kara
2025-04-14 13:35 ` (subset) " Christian Brauner
2025-04-11 15:31 ` [PATCH v2 2/2] fs/fs_parse: Fix 3 issues for validate_constant_table() Zijun Hu
1 sibling, 2 replies; 7+ messages in thread
From: Zijun Hu @ 2025-04-11 15:31 UTC (permalink / raw)
To: Alexander Viro, Christian Brauner, Jan Kara, David Howells,
Jonathan Corbet
Cc: Zijun Hu, linux-fsdevel, linux-kernel, linux-doc, Zijun Hu
From: Zijun Hu <quic_zijuhu@quicinc.com>
Delete macro fsparam_u32hex() since:
- it has no caller.
- it uses as type @fs_param_is_u32_hex which is never defined, so will
cause compile error when caller uses it.
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
Documentation/filesystems/mount_api.rst | 1 -
include/linux/fs_parser.h | 2 --
2 files changed, 3 deletions(-)
diff --git a/Documentation/filesystems/mount_api.rst b/Documentation/filesystems/mount_api.rst
index d92c276f1575af11370dcd4a5d5d0ac97c4d7f4c..47dafbb7427e6a829989a815e4d034e48fdbe7a2 100644
--- a/Documentation/filesystems/mount_api.rst
+++ b/Documentation/filesystems/mount_api.rst
@@ -671,7 +671,6 @@ The members are as follows:
fsparam_bool() fs_param_is_bool
fsparam_u32() fs_param_is_u32
fsparam_u32oct() fs_param_is_u32_octal
- fsparam_u32hex() fs_param_is_u32_hex
fsparam_s32() fs_param_is_s32
fsparam_u64() fs_param_is_u64
fsparam_enum() fs_param_is_enum
diff --git a/include/linux/fs_parser.h b/include/linux/fs_parser.h
index 53e566efd5fd133d19e313e494b975612a227b77..5057faf4f09182fa6e7ddd03fb17b066efd7e58b 100644
--- a/include/linux/fs_parser.h
+++ b/include/linux/fs_parser.h
@@ -125,8 +125,6 @@ static inline bool fs_validate_description(const char *name,
#define fsparam_u32(NAME, OPT) __fsparam(fs_param_is_u32, NAME, OPT, 0, NULL)
#define fsparam_u32oct(NAME, OPT) \
__fsparam(fs_param_is_u32, NAME, OPT, 0, (void *)8)
-#define fsparam_u32hex(NAME, OPT) \
- __fsparam(fs_param_is_u32_hex, NAME, OPT, 0, (void *)16)
#define fsparam_s32(NAME, OPT) __fsparam(fs_param_is_s32, NAME, OPT, 0, NULL)
#define fsparam_u64(NAME, OPT) __fsparam(fs_param_is_u64, NAME, OPT, 0, NULL)
#define fsparam_enum(NAME, OPT, array) __fsparam(fs_param_is_enum, NAME, OPT, 0, array)
--
2.34.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 2/2] fs/fs_parse: Fix 3 issues for validate_constant_table()
2025-04-11 15:31 [PATCH v2 0/2] fs: bug fixes Zijun Hu
2025-04-11 15:31 ` [PATCH v2 1/2] fs/fs_parse: Delete macro fsparam_u32hex() Zijun Hu
@ 2025-04-11 15:31 ` Zijun Hu
2025-04-14 13:17 ` Jan Kara
1 sibling, 1 reply; 7+ messages in thread
From: Zijun Hu @ 2025-04-11 15:31 UTC (permalink / raw)
To: Alexander Viro, Christian Brauner, Jan Kara, David Howells,
Jonathan Corbet
Cc: Zijun Hu, linux-fsdevel, linux-kernel, linux-doc, Zijun Hu
From: Zijun Hu <quic_zijuhu@quicinc.com>
Constant table array array[] which must end with a empty entry and fix
below issues for validate_constant_table(array, ARRAY_SIZE(array), ...):
- Always return wrong value for good constant table array which ends
with a empty entry.
- Imprecise error message for missorted case.
- Potential NULL pointer dereference since the last pr_err() may use
'tbl[i].name' NULL pointer to print the last constant entry's name.
Fortunately, the function has no caller currently.
Fix these issues mentioned above.
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
fs/fs_parser.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/fs/fs_parser.c b/fs/fs_parser.c
index e635a81e17d965df78ffef27f6885cd70996c6dd..ef7876340a917876bc40df9cdde9232204125a75 100644
--- a/fs/fs_parser.c
+++ b/fs/fs_parser.c
@@ -399,6 +399,9 @@ bool validate_constant_table(const struct constant_table *tbl, size_t tbl_size,
}
for (i = 0; i < tbl_size; i++) {
+ if (!tbl[i].name && (i + 1 == tbl_size))
+ break;
+
if (!tbl[i].name) {
pr_err("VALIDATE C-TBL[%zu]: Null\n", i);
good = false;
@@ -411,13 +414,13 @@ bool validate_constant_table(const struct constant_table *tbl, size_t tbl_size,
good = false;
}
if (c > 0) {
- pr_err("VALIDATE C-TBL[%zu]: Missorted %s>=%s\n",
+ pr_err("VALIDATE C-TBL[%zu]: Missorted %s>%s\n",
i, tbl[i-1].name, tbl[i].name);
good = false;
}
}
- if (tbl[i].value != special &&
+ if (tbl[i].name && tbl[i].value != special &&
(tbl[i].value < low || tbl[i].value > high)) {
pr_err("VALIDATE C-TBL[%zu]: %s->%d const out of range (%d-%d)\n",
i, tbl[i].name, tbl[i].value, low, high);
--
2.34.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] fs/fs_parse: Delete macro fsparam_u32hex()
2025-04-11 15:31 ` [PATCH v2 1/2] fs/fs_parse: Delete macro fsparam_u32hex() Zijun Hu
@ 2025-04-14 13:17 ` Jan Kara
2025-04-14 13:35 ` (subset) " Christian Brauner
1 sibling, 0 replies; 7+ messages in thread
From: Jan Kara @ 2025-04-14 13:17 UTC (permalink / raw)
To: Zijun Hu
Cc: Alexander Viro, Christian Brauner, Jan Kara, David Howells,
Jonathan Corbet, linux-fsdevel, linux-kernel, linux-doc,
Zijun Hu
On Fri 11-04-25 23:31:40, Zijun Hu wrote:
> From: Zijun Hu <quic_zijuhu@quicinc.com>
>
> Delete macro fsparam_u32hex() since:
>
> - it has no caller.
>
> - it uses as type @fs_param_is_u32_hex which is never defined, so will
> cause compile error when caller uses it.
>
> Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> Documentation/filesystems/mount_api.rst | 1 -
> include/linux/fs_parser.h | 2 --
> 2 files changed, 3 deletions(-)
>
> diff --git a/Documentation/filesystems/mount_api.rst b/Documentation/filesystems/mount_api.rst
> index d92c276f1575af11370dcd4a5d5d0ac97c4d7f4c..47dafbb7427e6a829989a815e4d034e48fdbe7a2 100644
> --- a/Documentation/filesystems/mount_api.rst
> +++ b/Documentation/filesystems/mount_api.rst
> @@ -671,7 +671,6 @@ The members are as follows:
> fsparam_bool() fs_param_is_bool
> fsparam_u32() fs_param_is_u32
> fsparam_u32oct() fs_param_is_u32_octal
> - fsparam_u32hex() fs_param_is_u32_hex
> fsparam_s32() fs_param_is_s32
> fsparam_u64() fs_param_is_u64
> fsparam_enum() fs_param_is_enum
> diff --git a/include/linux/fs_parser.h b/include/linux/fs_parser.h
> index 53e566efd5fd133d19e313e494b975612a227b77..5057faf4f09182fa6e7ddd03fb17b066efd7e58b 100644
> --- a/include/linux/fs_parser.h
> +++ b/include/linux/fs_parser.h
> @@ -125,8 +125,6 @@ static inline bool fs_validate_description(const char *name,
> #define fsparam_u32(NAME, OPT) __fsparam(fs_param_is_u32, NAME, OPT, 0, NULL)
> #define fsparam_u32oct(NAME, OPT) \
> __fsparam(fs_param_is_u32, NAME, OPT, 0, (void *)8)
> -#define fsparam_u32hex(NAME, OPT) \
> - __fsparam(fs_param_is_u32_hex, NAME, OPT, 0, (void *)16)
> #define fsparam_s32(NAME, OPT) __fsparam(fs_param_is_s32, NAME, OPT, 0, NULL)
> #define fsparam_u64(NAME, OPT) __fsparam(fs_param_is_u64, NAME, OPT, 0, NULL)
> #define fsparam_enum(NAME, OPT, array) __fsparam(fs_param_is_enum, NAME, OPT, 0, array)
>
> --
> 2.34.1
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/2] fs/fs_parse: Fix 3 issues for validate_constant_table()
2025-04-11 15:31 ` [PATCH v2 2/2] fs/fs_parse: Fix 3 issues for validate_constant_table() Zijun Hu
@ 2025-04-14 13:17 ` Jan Kara
2025-04-14 13:24 ` Zijun Hu
0 siblings, 1 reply; 7+ messages in thread
From: Jan Kara @ 2025-04-14 13:17 UTC (permalink / raw)
To: Zijun Hu
Cc: Alexander Viro, Christian Brauner, Jan Kara, David Howells,
Jonathan Corbet, linux-fsdevel, linux-kernel, linux-doc,
Zijun Hu
On Fri 11-04-25 23:31:41, Zijun Hu wrote:
> From: Zijun Hu <quic_zijuhu@quicinc.com>
>
> Constant table array array[] which must end with a empty entry and fix
> below issues for validate_constant_table(array, ARRAY_SIZE(array), ...):
>
> - Always return wrong value for good constant table array which ends
> with a empty entry.
>
> - Imprecise error message for missorted case.
>
> - Potential NULL pointer dereference since the last pr_err() may use
> 'tbl[i].name' NULL pointer to print the last constant entry's name.
>
> Fortunately, the function has no caller currently.
> Fix these issues mentioned above.
>
> Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
As discussed, I'd rather drop this function since it is unused as well.
Honza
> ---
> fs/fs_parser.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/fs/fs_parser.c b/fs/fs_parser.c
> index e635a81e17d965df78ffef27f6885cd70996c6dd..ef7876340a917876bc40df9cdde9232204125a75 100644
> --- a/fs/fs_parser.c
> +++ b/fs/fs_parser.c
> @@ -399,6 +399,9 @@ bool validate_constant_table(const struct constant_table *tbl, size_t tbl_size,
> }
>
> for (i = 0; i < tbl_size; i++) {
> + if (!tbl[i].name && (i + 1 == tbl_size))
> + break;
> +
> if (!tbl[i].name) {
> pr_err("VALIDATE C-TBL[%zu]: Null\n", i);
> good = false;
> @@ -411,13 +414,13 @@ bool validate_constant_table(const struct constant_table *tbl, size_t tbl_size,
> good = false;
> }
> if (c > 0) {
> - pr_err("VALIDATE C-TBL[%zu]: Missorted %s>=%s\n",
> + pr_err("VALIDATE C-TBL[%zu]: Missorted %s>%s\n",
> i, tbl[i-1].name, tbl[i].name);
> good = false;
> }
> }
>
> - if (tbl[i].value != special &&
> + if (tbl[i].name && tbl[i].value != special &&
> (tbl[i].value < low || tbl[i].value > high)) {
> pr_err("VALIDATE C-TBL[%zu]: %s->%d const out of range (%d-%d)\n",
> i, tbl[i].name, tbl[i].value, low, high);
>
> --
> 2.34.1
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/2] fs/fs_parse: Fix 3 issues for validate_constant_table()
2025-04-14 13:17 ` Jan Kara
@ 2025-04-14 13:24 ` Zijun Hu
0 siblings, 0 replies; 7+ messages in thread
From: Zijun Hu @ 2025-04-14 13:24 UTC (permalink / raw)
To: Jan Kara
Cc: Alexander Viro, Christian Brauner, David Howells,
Jonathan Corbet, linux-fsdevel, linux-kernel, linux-doc,
Zijun Hu
On 2025/4/14 21:17, Jan Kara wrote:
>> Fortunately, the function has no caller currently.
>> Fix these issues mentioned above.
>>
>> Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
> As discussed, I'd rather drop this function since it is unused as well.
thank you Jan for comments.
will drop it in next revision (^^).
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: (subset) [PATCH v2 1/2] fs/fs_parse: Delete macro fsparam_u32hex()
2025-04-11 15:31 ` [PATCH v2 1/2] fs/fs_parse: Delete macro fsparam_u32hex() Zijun Hu
2025-04-14 13:17 ` Jan Kara
@ 2025-04-14 13:35 ` Christian Brauner
1 sibling, 0 replies; 7+ messages in thread
From: Christian Brauner @ 2025-04-14 13:35 UTC (permalink / raw)
To: Zijun Hu
Cc: Christian Brauner, linux-fsdevel, linux-kernel, linux-doc,
Zijun Hu, Alexander Viro, Jan Kara, David Howells,
Jonathan Corbet
On Fri, 11 Apr 2025 23:31:40 +0800, Zijun Hu wrote:
> Delete macro fsparam_u32hex() since:
>
> - it has no caller.
>
> - it uses as type @fs_param_is_u32_hex which is never defined, so will
> cause compile error when caller uses it.
>
> [...]
Applied to the vfs-6.16.misc branch of the vfs/vfs.git tree.
Patches in the vfs-6.16.misc branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs-6.16.misc
[1/2] fs/fs_parse: Delete macro fsparam_u32hex()
https://git.kernel.org/vfs/vfs/c/8cc42084abd9
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-04-14 13:36 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-11 15:31 [PATCH v2 0/2] fs: bug fixes Zijun Hu
2025-04-11 15:31 ` [PATCH v2 1/2] fs/fs_parse: Delete macro fsparam_u32hex() Zijun Hu
2025-04-14 13:17 ` Jan Kara
2025-04-14 13:35 ` (subset) " Christian Brauner
2025-04-11 15:31 ` [PATCH v2 2/2] fs/fs_parse: Fix 3 issues for validate_constant_table() Zijun Hu
2025-04-14 13:17 ` Jan Kara
2025-04-14 13:24 ` Zijun Hu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®