um: ubd: Fix crash from option parsing
PATCH 1/1 um: ubd: Fix crash from option parsing
Below patch will cause NULL ptr dereferences if the optional filenames are not present.
--- arch/um/drivers/ubd_kern.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/um/drivers/ubd_kern.c +3 -3
@@ -371,15 +371,15 @@ static int ubd_setup_common(char *str, int *index_out, char **error_out) break_loop: file =strsep (&str,",:" ); -if (*file =='\0' ) +if (file && *file =='\0' ) file =NULL ; backing_file =strsep (&str,",:" ); -if (*backing_file =='\0' ) +if (backing_file && *backing_file =='\0' ) backing_file =NULL ; serial =strsep (&str,",:" ); -if (*serial =='\0' ) +if (serial && *serial =='\0' ) serial =NULL ;if (backing_file && ubd_dev->no_cow) {
Signature · 7 lines
2.30.0.284.gd98b1dd5eaa7-goog _______________________________________________ linux-um mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-um
Quoted 5 lines · Paul Lawrence
Below patch will cause NULL ptr dereferences if the optional filenames are not present.
Fixes ef3ba87cb7c9 (um: ubd: Set device serial attribute from cmdline)Signed-off-by Paul Lawrence <[email protected]>
Looks good.
Totally unrelated, but it seems the original patch writes a "(null)" string to the sysfs attribute, if no serial is defined. I think we should have a default serial UBDX in case the user didn't provide any.
Thanks,
Quoted 27 lines
--- arch/um/drivers/ubd_kern.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)arch/um/drivers/ubd_kern.c +3
-3@@ -371,15 +371,15 @@ static int ubd_setup_common(char *str, int *index_out, char **error_out) break_loop: file =strsep (&str,",:" ); -if (*file =='\0' ) +if (file && *file =='\0' ) file =NULL ; backing_file =strsep (&str,",:" ); -if (*backing_file =='\0' ) +if (backing_file && *backing_file =='\0' ) backing_file =NULL ; serial =strsep (&str,",:" ); -if (*serial =='\0' ) +if (serial && *serial =='\0' ) serial =NULL ;if (backing_file && ubd_dev->no_cow) {
Signature · 6 lines
Gabriel Krisman Bertazi _______________________________________________ linux-um mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-um
Hello,
Quoted 6 lines · Paul Lawrence
Below patch will cause NULL ptr dereferences if the optional filenames are not present.
Fixes ef3ba87cb7c9 (um: ubd: Set device serial attribute from cmdline)Signed-off-by Paul Lawrence <[email protected]>
This was addressed/fixed by the below patch, though that one doesn't the first "file" variable check.
http://lists.infradead.org/pipermail/linux-um/2020-December/000983.html
There was another attempt to fix (with the same diff), btw.
http://lists.infradead.org/pipermail/linux-um/2021-January/000998.html
It seems that the patch is already queued but not upstreamed yet.
-- Hajime
_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
Quoted 2 lines
This was addressed/fixed by the below patch, though that one doesn't the first "file" variable check.
I don't believe the first file variable can in fact be NULL, so my check was unnecessary. Pleased to see this has been fixed, we can abandon my patch now.
Paul
_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um