From: Gabriel Krisman Bertazi <krisman@collabora.com>
To: Paul Lawrence <paullawrence@google.com>
Cc: Richard Weinberger <richard@nod.at>,
Jeff Dike <jdike@addtoit.com>,
linux-um@lists.infradead.org, linux-kernel@vger.kernel.org,
Christopher Obbard <chris.obbard@collabora.com>,
Anton Ivanov <anton.ivanov@cambridgegreys.com>
Subject: Re: [PATCH] um: ubd: Fix crash from option parsing
Date: Tue, 19 Jan 2021 15:35:35 -0300 [thread overview]
Message-ID: <871regg4g8.fsf@collabora.com> (raw)
In-Reply-To: <20210119181945.2071053-1-paullawrence@google.com> (Paul Lawrence's message of "Tue, 19 Jan 2021 18:19:45 +0000")
Paul Lawrence <paullawrence@google.com> writes:
> 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 <paullawrence@google.com>
Looks good.
Reviewed-by: Gabriel Krisman Bertazi <krisman@collabora.com>
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,
> ---
> arch/um/drivers/ubd_kern.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
> index 13b1fe694b90..704989088f28 100644
> --- a/arch/um/drivers/ubd_kern.c
> +++ b/arch/um/drivers/ubd_kern.c
> @@ -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) {
--
Gabriel Krisman Bertazi
_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um
WARNING: multiple messages have this Message-ID (diff)
From: Gabriel Krisman Bertazi <krisman@collabora.com>
To: Paul Lawrence <paullawrence@google.com>
Cc: Jeff Dike <jdike@addtoit.com>,
Richard Weinberger <richard@nod.at>,
Anton Ivanov <anton.ivanov@cambridgegreys.com>,
Christopher Obbard <chris.obbard@collabora.com>,
linux-um@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] um: ubd: Fix crash from option parsing
Date: Tue, 19 Jan 2021 15:35:35 -0300 [thread overview]
Message-ID: <871regg4g8.fsf@collabora.com> (raw)
In-Reply-To: <20210119181945.2071053-1-paullawrence@google.com> (Paul Lawrence's message of "Tue, 19 Jan 2021 18:19:45 +0000")
Paul Lawrence <paullawrence@google.com> writes:
> 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 <paullawrence@google.com>
Looks good.
Reviewed-by: Gabriel Krisman Bertazi <krisman@collabora.com>
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,
> ---
> arch/um/drivers/ubd_kern.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
> index 13b1fe694b90..704989088f28 100644
> --- a/arch/um/drivers/ubd_kern.c
> +++ b/arch/um/drivers/ubd_kern.c
> @@ -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) {
--
Gabriel Krisman Bertazi
next prev parent reply other threads:[~2021-01-19 18:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-19 18:19 [PATCH] um: ubd: Fix crash from option parsing Paul Lawrence
2021-01-19 18:19 ` Paul Lawrence
2021-01-19 18:35 ` Gabriel Krisman Bertazi [this message]
2021-01-19 18:35 ` Gabriel Krisman Bertazi
2021-01-22 0:41 ` Hajime Tazaki
2021-01-22 0:41 ` Hajime Tazaki
2021-01-22 14:44 ` Paul Lawrence
2021-01-22 14:44 ` Paul Lawrence
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871regg4g8.fsf@collabora.com \
--to=krisman@collabora.com \
--cc=anton.ivanov@cambridgegreys.com \
--cc=chris.obbard@collabora.com \
--cc=jdike@addtoit.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-um@lists.infradead.org \
--cc=paullawrence@google.com \
--cc=richard@nod.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.