mdadm: check posix name before setting name and devname
PATCH 1/1 mdadm: check posix name before setting name and devname
It's good to has limitation for name when creating an array. But the arrays which were created before patch e2eb503bd797 (mdadm: Follow POSIX Portable Character Set) can't be assembled. In this patch, it removes the posix check for assemble mode.
--- config.c | 8 ++------ mdadm.c | 11 +++++++++++ 2 files changed, 13 insertions(+), 6 deletions(-)
config.c +2 -6
@@ -208,11 +208,6 @@ static mdadm_status_t ident_check_name(const char *name, const char *prop_name,return MDADM_STATUS_ERROR ; } -if (!is_name_posix_compatible (name)) { -ident_log (prop_name, name,"Not POSIX compatible" , cmdline); -return MDADM_STATUS_ERROR ; - } -return MDADM_STATUS_SUCCESS ; }
@@ -512,7 +507,8 @@ void arrayline(char *line)for (w =dl_next (line); w != line; w =dl_next (w)) {if (w[0 ] =='/' ||strchr (w,'=' ) ==NULL ) { -_ident_set_devname (&mis, w, false); +if (is_name_posix_compatible (w)) +_ident_set_devname (&mis, w, false); }else if (strncasecmp (w,"uuid=" ,5 ) ==0 ) {if (mis.uuid_set) pr_err("only specify uuid once, %s ignored.\n",
mdadm.c +11 -0
@@ -732,6 +732,11 @@ int main(int argc, char *argv[])exit (2 ); } +if (mode !=ASSEMBLE && !is_name_posix_compatible (optarg)) { +pr_err ("%s Not POSIX compatible\n" , optarg); +exit (2 ); + } +if (ident_set_name (&ident, optarg) !=MDADM_STATUS_SUCCESS )exit (2 );
@@ -1289,6 +1294,12 @@ int main(int argc, char *argv[])pr_err ("an md device must be given in this mode\n" );exit (2 ); } + +if (mode !=ASSEMBLE && !is_name_posix_compatible (devlist->devname)) { +pr_err ("%s Not POSIX compatible\n" , devlist->devname); +exit (2 ); + } +if (ident_set_devname (&ident, devlist->devname) !=MDADM_STATUS_SUCCESS )exit (1 );
Signature · 1 line
2.32.0 (Apple Git-132)
Dear Xiao,
Thank you for the patch. Wasn’t a similar patch sent to the list already months ago?
For the commit message subject/title I suggest:
mdadm: Allow to assemble existing arrays with non-POSIX names
Am 18.03.25 um 06:46 schrieb Xiao Ni:
Quoted 1 line
It's good to has limitation for name when creating an array. But the arrays
… to have limitations …
Quoted 3 lines
which were created before patch
e2eb503bd797(mdadm: Follow POSIX Portable Character Set) can't be assembled. In this patch, it removes the posix check for assemble mode.
“In this patch” is redundant in the commit message. Maybe:
So, remove the POSIX check for assemble mode.
Maybe add how to reproduce this? Is there a way to create a non-POSIX name with current mdadm, or should such a file be provided for tests.
Quoted 62 lines
Fixes e2eb503bd797 (mdadm: Follow POSIX Portable Character Set)Signed-off-by Xiao Ni <[email protected]>--- config.c | 8 ++------ mdadm.c | 11 +++++++++++ 2 files changed, 13 insertions(+), 6 deletions(-)config.c +2
-6@@ -208,11 +208,6 @@ static mdadm_status_t ident_check_name(const char *name, const char *prop_name,return MDADM_STATUS_ERROR ; } -if (!is_name_posix_compatible (name)) { -ident_log (prop_name, name,"Not POSIX compatible" , cmdline); -return MDADM_STATUS_ERROR ; - } -return MDADM_STATUS_SUCCESS ; }@@ -512,7 +507,8 @@ void arrayline(char *line)for (w =dl_next (line); w != line; w =dl_next (w)) {if (w[0 ] =='/' ||strchr (w,'=' ) ==NULL ) { -_ident_set_devname (&mis, w, false); +if (is_name_posix_compatible (w)) +_ident_set_devname (&mis, w, false); }else if (strncasecmp (w,"uuid=" ,5 ) ==0 ) {if (mis.uuid_set) pr_err("only specify uuid once, %s ignored.\n",mdadm.c +11
-0@@ -732,6 +732,11 @@ int main(int argc, char *argv[])exit (2 ); } +if (mode !=ASSEMBLE && !is_name_posix_compatible (optarg)) { +pr_err ("%s Not POSIX compatible\n" , optarg); +exit (2 ); + } +if (ident_set_name (&ident, optarg) !=MDADM_STATUS_SUCCESS )exit (2 );@@ -1289,6 +1294,12 @@ int main(int argc, char *argv[])pr_err ("an md device must be given in this mode\n" );exit (2 ); } + +if (mode !=ASSEMBLE && !is_name_posix_compatible (devlist->devname)) { +pr_err ("%s Not POSIX compatible\n" , devlist->devname); +exit (2 ); + } +if (ident_set_devname (&ident, devlist->devname) !=MDADM_STATUS_SUCCESS )exit (1 );
Quoted 10 lines · Paul Menzel
Dear Xiao,
Thank you for the patch. Wasn’t a similar patch sent to the list already months ago?
For the commit message subject/title I suggest:
mdadm: Allow to assemble existing arrays with non-POSIX names
Hi Paul
Thanks for reminding me about this. I forgot about this patch. I can't find the patch. Do you still have the link for it?
Quoted 6 lines
Am 18.03.25 um 06:46 schrieb Xiao Ni:
Quoted 1 line
It's good to has limitation for name when creating an array. But the arrays
… to have limitations …
Quoted 7 lines
Quoted 3 lines
which were created before patch
e2eb503bd797(mdadm: Follow POSIX Portable Character Set) can't be assembled. In this patch, it removes the posix check for assemble mode.“In this patch” is redundant in the commit message. Maybe:
So, remove the POSIX check for assemble mode.
good to me.
Quoted 3 lines
Maybe add how to reproduce this? Is there a way to create a non-POSIX name with current mdadm, or should such a file be provided for tests.
For example:
* build mdadm without patch e2eb503bd797
* mdadm -CR /dev/md/tbz:pv1 -l0 -n2 /dev/loop0 /dev/loop1
* mdadm -Ss
* build with latest mdadm, and try to assemble it.
* mdadm -A /dev/md/tbz:pv1 --name tbz:pv1
mdadm: Value "tbz:pv1" cannot be set as name. Reason: Not POSIX compatible.
Regards
Xiao
Quoted 64 lines
Quoted 63 lines
Fixes e2eb503bd797 (mdadm: Follow POSIX Portable Character Set)Signed-off-by Xiao Ni <[email protected]>--- config.c | 8 ++------ mdadm.c | 11 +++++++++++ 2 files changed, 13 insertions(+), 6 deletions(-)config.c +2
-6@@ -208,11 +208,6 @@ static mdadm_status_t ident_check_name(const char *name, const char *prop_name,return MDADM_STATUS_ERROR ; } -if (!is_name_posix_compatible (name)) { -ident_log (prop_name, name,"Not POSIX compatible" , cmdline); -return MDADM_STATUS_ERROR ; - } -return MDADM_STATUS_SUCCESS ; }@@ -512,7 +507,8 @@ void arrayline(char *line)for (w =dl_next (line); w != line; w =dl_next (w)) {if (w[0 ] =='/' ||strchr (w,'=' ) ==NULL ) { -_ident_set_devname (&mis, w, false); +if (is_name_posix_compatible (w)) +_ident_set_devname (&mis, w, false); }else if (strncasecmp (w,"uuid=" ,5 ) ==0 ) {if (mis.uuid_set) pr_err("only specify uuid once, %s ignored.\n",mdadm.c +11
-0@@ -732,6 +732,11 @@ int main(int argc, char *argv[])exit (2 ); } +if (mode !=ASSEMBLE && !is_name_posix_compatible (optarg)) { +pr_err ("%s Not POSIX compatible\n" , optarg); +exit (2 ); + } +if (ident_set_name (&ident, optarg) !=MDADM_STATUS_SUCCESS )exit (2 );@@ -1289,6 +1294,12 @@ int main(int argc, char *argv[])pr_err ("an md device must be given in this mode\n" );exit (2 ); } + +if (mode !=ASSEMBLE && !is_name_posix_compatible (devlist->devname)) { +pr_err ("%s Not POSIX compatible\n" , devlist->devname); +exit (2 ); + } +if (ident_set_devname (&ident, devlist->devname) !=MDADM_STATUS_SUCCESS )exit (1 );
Dear Xiao,
Am 18.03.25 um 09:18 schrieb Xiao Ni:
Quoted 11 lines · Paul Menzel
Quoted 7 lines
Thank you for the patch. Wasn’t a similar patch sent to the list already months ago?
For the commit message subject/title I suggest:
mdadm: Allow to assemble existing arrays with non-POSIX names
Thanks for reminding me about this. I forgot about this patch. I can't find the patch. Do you still have the link for it?
I searched for *e2eb503bd797* in the linux-raid archive [1], I found the patch and discussion *[PATCH] Add the ":" to the allowed_symbols list to work with the latest POSIX changes* [2]. So, similar, and I think only the topic of already created arrays came up, your patch solves. Sorry for the confusion.
Quoted 18 lines
Quoted 5 lines
Am 18.03.25 um 06:46 schrieb Xiao Ni:
Quoted 1 line
It's good to has limitation for name when creating an array. But the arrays
… to have limitations …
Quoted 7 lines
Quoted 3 lines
which were created before patch
e2eb503bd797(mdadm: Follow POSIX Portable Character Set) can't be assembled. In this patch, it removes the posix check for assemble mode.“In this patch” is redundant in the commit message. Maybe:
So, remove the POSIX check for assemble mode.
good to me.
Quoted 2 lines
Maybe add how to reproduce this? Is there a way to create a non-POSIX name with current mdadm, or should such a file be provided for tests.
Quoted 8 lines
For example:
* build mdadm without patch
e2eb503bd797
* mdadm -CR /dev/md/tbz:pv1 -l0 -n2/dev/loop0/dev/loop1
* mdadm -Ss
* build with latest mdadm, and try to assemble it.
* mdadm -A /dev/md/tbz:pv1 --name tbz:pv1
mdadm: Value "tbz:pv1" cannot be set as name. Reason: Not POSIX compatible.
Thank you. For running tests, re-building mdadm might not be feasible. But having these instructions would be great to have in the commit message nevertheless.
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines
Fixes e2eb503bd797 (mdadm: Follow POSIX Portable Character Set)Signed-off-by Xiao Ni <[email protected]>--- config.c | 8 ++------ mdadm.c | 11 +++++++++++ 2 files changed, 13 insertions(+), 6 deletions(-)config.c +2
-6@@ -208,11 +208,6 @@ static mdadm_status_t ident_check_name(const char *name, const char *prop_name,return MDADM_STATUS_ERROR ; } -if (!is_name_posix_compatible (name)) { -ident_log (prop_name, name,"Not POSIX compatible" , cmdline); -return MDADM_STATUS_ERROR ; - } -return MDADM_STATUS_SUCCESS ; }@@ -512,7 +507,8 @@ void arrayline(char *line)for (w =dl_next (line); w != line; w =dl_next (w)) {if (w[0 ] =='/' ||strchr (w,'=' ) ==NULL ) { -_ident_set_devname (&mis, w, false); +if (is_name_posix_compatible (w)) +_ident_set_devname (&mis, w, false); }else if (strncasecmp (w,"uuid=" ,5 ) ==0 ) {if (mis.uuid_set) pr_err("only specify uuid once, %s ignored.\n",mdadm.c +5
-0@@ -732,6 +732,11 @@ int main(int argc, char *argv[])exit (2 ); } +if (mode !=ASSEMBLE && !is_name_posix_compatible (optarg)) { +pr_err ("%s Not POSIX compatible\n" , optarg); +exit (2 ); + } +if (ident_set_name (&ident, optarg) !=MDADM_STATUS_SUCCESS )exit (2 );
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
mdadm.c +0
-0@@ -1289,6 +1294,12 @@ int main(int argc, char *argv[])pr_err ("an md device must be given in this mode\n" );exit (2 ); }Quoted 8 lines
mdadm.c int main(int argc, char *argv[]) · line 1304
Quoted 8 lines
mdadm.c +6
-0+ +if (mode !=ASSEMBLE && !is_name_posix_compatible (devlist->devname)) { +pr_err ("%s Not POSIX compatible\n" , devlist->devname); +exit (2 ); + } +if (ident_set_devname (&ident, devlist->devname) !=MDADM_STATUS_SUCCESS )exit (1 );
Kind regards,
Paul
[1]: https://lore.kernel.org/linux-raid/?q=e2eb503bd797
[2]: https://lore.kernel.org/linux-raid/[email protected]/
Quoted 15 lines · Paul Menzel
Dear Xiao,
Am 18.03.25 um 09:18 schrieb Xiao Ni:
Quoted 8 lines · Paul Menzel
Quoted 7 lines
Thank you for the patch. Wasn’t a similar patch sent to the list already months ago?
For the commit message subject/title I suggest:
mdadm: Allow to assemble existing arrays with non-POSIX names
Quoted 8 lines
Quoted 2 lines
Thanks for reminding me about this. I forgot about this patch. I can't find the patch. Do you still have the link for it?
I searched for *e2eb503bd797* in the linux-raid archive [1], I found the patch and discussion *[PATCH] Add the ":" to the
allowed_symbolslist to work with the latest POSIX changes* [2]. So, similar, and I think only the topic of already created arrays came up, your patch solves. Sorry for the confusion.
Thanks for finding it. It doesn't resolve the problem. So this patch tries to resolve the problem.
Quoted 28 lines
Quoted 19 lines
Quoted 6 lines
Am 18.03.25 um 06:46 schrieb Xiao Ni:
Quoted 1 line
It's good to has limitation for name when creating an array. But the arrays
… to have limitations …
Quoted 7 lines
Quoted 3 lines
which were created before patch
e2eb503bd797(mdadm: Follow POSIX Portable Character Set) can't be assembled. In this patch, it removes the posix check for assemble mode.“In this patch” is redundant in the commit message. Maybe:
So, remove the POSIX check for assemble mode.
good to me.
Quoted 2 lines
Maybe add how to reproduce this? Is there a way to create a non-POSIX name with current mdadm, or should such a file be provided for tests.
Quoted 8 lines
For example:
* build mdadm without patch
e2eb503bd797
* mdadm -CR /dev/md/tbz:pv1 -l0 -n2/dev/loop0/dev/loop1
* mdadm -Ss
* build with latest mdadm, and try to assemble it.
* mdadm -A /dev/md/tbz:pv1 --name tbz:pv1
mdadm: Value "tbz:pv1" cannot be set as name. Reason: Not POSIX compatible.
Quoted 3 lines
Thank you. For running tests, re-building mdadm might not be feasible. But having these instructions would be great to have in the commit message nevertheless.
It's right. I'll add them into the commit message.
Regards
Xiao
Quoted 72 lines
Quoted 50 lines
Quoted 50 lines
Quoted 50 lines
Fixes e2eb503bd797 (mdadm: Follow POSIX Portable Character Set)Signed-off-by Xiao Ni <[email protected]>--- config.c | 8 ++------ mdadm.c | 11 +++++++++++ 2 files changed, 13 insertions(+), 6 deletions(-)config.c +2
-6@@ -208,11 +208,6 @@ static mdadm_status_t ident_check_name(const char *name, const char *prop_name,return MDADM_STATUS_ERROR ; } -if (!is_name_posix_compatible (name)) { -ident_log (prop_name, name,"Not POSIX compatible" , cmdline); -return MDADM_STATUS_ERROR ; - } -return MDADM_STATUS_SUCCESS ; }@@ -512,7 +507,8 @@ void arrayline(char *line)for (w =dl_next (line); w != line; w =dl_next (w)) {if (w[0 ] =='/' ||strchr (w,'=' ) ==NULL ) { -_ident_set_devname (&mis, w, false); +if (is_name_posix_compatible (w)) +_ident_set_devname (&mis, w, false); }else if (strncasecmp (w,"uuid=" ,5 ) ==0 ) {if (mis.uuid_set) pr_err("only specify uuid once, %s ignored.\n",mdadm.c +5
-0@@ -732,6 +732,11 @@ int main(int argc, char *argv[])exit (2 ); } +if (mode !=ASSEMBLE && !is_name_posix_compatible (optarg)) { +pr_err ("%s Not POSIX compatible\n" , optarg); +exit (2 ); + } +if (ident_set_name (&ident, optarg) !=MDADM_STATUS_SUCCESS )exit (2 );Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
mdadm.c +0
-0@@ -1289,6 +1294,12 @@ int main(int argc, char *argv[])pr_err ("an md device must be given in this mode\n" );exit (2 ); }Quoted 8 lines
mdadm.c int main(int argc, char *argv[]) · line 1304
Quoted 8 lines
mdadm.c +6
-0+ +if (mode !=ASSEMBLE && !is_name_posix_compatible (devlist->devname)) { +pr_err ("%s Not POSIX compatible\n" , devlist->devname); +exit (2 ); + } +if (ident_set_devname (&ident, devlist->devname) !=MDADM_STATUS_SUCCESS )exit (1 );Kind regards,
Paul
[1]: https://lore.kernel.org/linux-raid/?q=e2eb503bd797
[2]:
https://lore.kernel.org/linux-raid/[email protected]/