2020-02-16 21:37:13

by Sjoerd Simons

[permalink] [raw]
Subject: [PATCH] um: vector: Avoid NULL ptr deference if transport is unset

When the transport option of a vec isn't set strncmp ends up being
called on a NULL pointer. Better not do that.

Signed-off-by: Sjoerd Simons <[email protected]>

---

arch/um/drivers/vector_kern.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
index 0ff86391f77d..ca90666c0b61 100644
--- a/arch/um/drivers/vector_kern.c
+++ b/arch/um/drivers/vector_kern.c
@@ -198,6 +198,9 @@ static int get_transport_options(struct arglist *def)
long parsed;
int result = 0;

+ if (transport == NULL)
+ return -EINVAL;
+
if (vector != NULL) {
if (kstrtoul(vector, 10, &parsed) == 0) {
if (parsed == 0) {
--
2.25.0


2020-02-17 07:55:54

by Anton Ivanov

[permalink] [raw]
Subject: Re: [PATCH] um: vector: Avoid NULL ptr deference if transport is unset

On 16/02/2020 21:36, Sjoerd Simons wrote:
> When the transport option of a vec isn't set strncmp ends up being
> called on a NULL pointer. Better not do that.
>
> Signed-off-by: Sjoerd Simons <[email protected]>
>
> ---
>
> arch/um/drivers/vector_kern.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
> index 0ff86391f77d..ca90666c0b61 100644
> --- a/arch/um/drivers/vector_kern.c
> +++ b/arch/um/drivers/vector_kern.c
> @@ -198,6 +198,9 @@ static int get_transport_options(struct arglist *def)
> long parsed;
> int result = 0;
>
> + if (transport == NULL)
> + return -EINVAL;
> +
> if (vector != NULL) {
> if (kstrtoul(vector, 10, &parsed) == 0) {
> if (parsed == 0) {
>
Acked-By: Anton Ivanov <[email protected]>

--
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/

2020-03-29 23:07:21

by Richard Weinberger

[permalink] [raw]
Subject: Re: [PATCH] um: vector: Avoid NULL ptr deference if transport is unset

On Mon, Feb 17, 2020 at 8:54 AM Anton Ivanov
<[email protected]> wrote:
>
> On 16/02/2020 21:36, Sjoerd Simons wrote:
> > When the transport option of a vec isn't set strncmp ends up being
> > called on a NULL pointer. Better not do that.
> >
> > Signed-off-by: Sjoerd Simons <[email protected]>
> >
> > ---
> >
> > arch/um/drivers/vector_kern.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
> > index 0ff86391f77d..ca90666c0b61 100644
> > --- a/arch/um/drivers/vector_kern.c
> > +++ b/arch/um/drivers/vector_kern.c
> > @@ -198,6 +198,9 @@ static int get_transport_options(struct arglist *def)
> > long parsed;
> > int result = 0;
> >
> > + if (transport == NULL)
> > + return -EINVAL;
> > +
> > if (vector != NULL) {
> > if (kstrtoul(vector, 10, &parsed) == 0) {
> > if (parsed == 0) {
> >
> Acked-By: Anton Ivanov <[email protected]>

Applied, thanks!

--
Thanks,
//richard