2021-05-26 14:34:54

by Yang Yingliang

[permalink] [raw]
Subject: [PATCH -next] cred: add missing return error code when set_cred_ucounts() failed

If set_cred_ucounts() failed, we need return the error code.

Fixes: 905ae01c4ae2 ("Add a reference to ucounts for each cred")
Reported-by: Hulk Robot <[email protected]>
Signed-off-by: Yang Yingliang <[email protected]>
---
kernel/cred.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/cred.c b/kernel/cred.c
index db7c46bf36e5..e6fd2b3fc31f 100644
--- a/kernel/cred.c
+++ b/kernel/cred.c
@@ -372,7 +372,8 @@ int copy_creds(struct task_struct *p, unsigned long clone_flags)
ret = create_user_ns(new);
if (ret < 0)
goto error_put;
- if (set_cred_ucounts(new) < 0)
+ ret = set_cred_ucounts(new);
+ if (ret < 0)
goto error_put;
}

--
2.25.1


2021-05-27 00:57:26

by Eric W. Biederman

[permalink] [raw]
Subject: Re: [PATCH -next] cred: add missing return error code when set_cred_ucounts() failed

Yang Yingliang <[email protected]> writes:

> If set_cred_ucounts() failed, we need return the error code.

Alex how does this look to you?

This is showing up now as I have finally dropped the code in linux-next
and other people are looking at it.

At a quick fix looks correct to me.

> Fixes: 905ae01c4ae2 ("Add a reference to ucounts for each cred")
> Reported-by: Hulk Robot <[email protected]>
> Signed-off-by: Yang Yingliang <[email protected]>
> ---
> kernel/cred.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/cred.c b/kernel/cred.c
> index db7c46bf36e5..e6fd2b3fc31f 100644
> --- a/kernel/cred.c
> +++ b/kernel/cred.c
> @@ -372,7 +372,8 @@ int copy_creds(struct task_struct *p, unsigned long clone_flags)
> ret = create_user_ns(new);
> if (ret < 0)
> goto error_put;
> - if (set_cred_ucounts(new) < 0)
> + ret = set_cred_ucounts(new);
> + if (ret < 0)
> goto error_put;
> }

2021-05-27 09:00:41

by Alexey Gladkov

[permalink] [raw]
Subject: Re: [PATCH -next] cred: add missing return error code when set_cred_ucounts() failed

On Wed, May 26, 2021 at 05:10:43PM -0500, Eric W. Biederman wrote:
> Yang Yingliang <[email protected]> writes:
>
> > If set_cred_ucounts() failed, we need return the error code.
>
> Alex how does this look to you?
>
> This is showing up now as I have finally dropped the code in linux-next
> and other people are looking at it.
>
> At a quick fix looks correct to me.

Yes, this is the right fix. I miss it.

> > Fixes: 905ae01c4ae2 ("Add a reference to ucounts for each cred")
> > Reported-by: Hulk Robot <[email protected]>
> > Signed-off-by: Yang Yingliang <[email protected]>
> > ---
> > kernel/cred.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/kernel/cred.c b/kernel/cred.c
> > index db7c46bf36e5..e6fd2b3fc31f 100644
> > --- a/kernel/cred.c
> > +++ b/kernel/cred.c
> > @@ -372,7 +372,8 @@ int copy_creds(struct task_struct *p, unsigned long clone_flags)
> > ret = create_user_ns(new);
> > if (ret < 0)
> > goto error_put;
> > - if (set_cred_ucounts(new) < 0)
> > + ret = set_cred_ucounts(new);
> > + if (ret < 0)
> > goto error_put;
> > }
>

--
Rgrds, legion

2021-05-27 18:13:35

by Eric W. Biederman

[permalink] [raw]
Subject: Re: [PATCH -next] cred: add missing return error code when set_cred_ucounts() failed

Alexey Gladkov <[email protected]> writes:

> On Wed, May 26, 2021 at 05:10:43PM -0500, Eric W. Biederman wrote:
>> Yang Yingliang <[email protected]> writes:
>>
>> > If set_cred_ucounts() failed, we need return the error code.
>>
>> Alex how does this look to you?
>>
>> This is showing up now as I have finally dropped the code in linux-next
>> and other people are looking at it.
>>
>> At a quick fix looks correct to me.
>
> Yes, this is the right fix. I miss it.


Can I have your Acked-by or Reviewed-by.
Thank you.

>> > Fixes: 905ae01c4ae2 ("Add a reference to ucounts for each cred")
>> > Reported-by: Hulk Robot <[email protected]>
>> > Signed-off-by: Yang Yingliang <[email protected]>
>> > ---
>> > kernel/cred.c | 3 ++-
>> > 1 file changed, 2 insertions(+), 1 deletion(-)
>> >
>> > diff --git a/kernel/cred.c b/kernel/cred.c
>> > index db7c46bf36e5..e6fd2b3fc31f 100644
>> > --- a/kernel/cred.c
>> > +++ b/kernel/cred.c
>> > @@ -372,7 +372,8 @@ int copy_creds(struct task_struct *p, unsigned long clone_flags)
>> > ret = create_user_ns(new);
>> > if (ret < 0)
>> > goto error_put;
>> > - if (set_cred_ucounts(new) < 0)
>> > + ret = set_cred_ucounts(new);
>> > + if (ret < 0)
>> > goto error_put;
>> > }
>>

Eric

2021-05-28 12:35:55

by Alexey Gladkov

[permalink] [raw]
Subject: Re: [PATCH -next] cred: add missing return error code when set_cred_ucounts() failed

On Thu, May 27, 2021 at 11:10:27AM -0500, Eric W. Biederman wrote:
> Alexey Gladkov <[email protected]> writes:
>
> > On Wed, May 26, 2021 at 05:10:43PM -0500, Eric W. Biederman wrote:
> >> Yang Yingliang <[email protected]> writes:
> >>
> >> > If set_cred_ucounts() failed, we need return the error code.
> >>
> >> Alex how does this look to you?
> >>
> >> This is showing up now as I have finally dropped the code in linux-next
> >> and other people are looking at it.
> >>
> >> At a quick fix looks correct to me.
> >
> > Yes, this is the right fix. I miss it.
>
>
> Can I have your Acked-by or Reviewed-by.
> Thank you.

Yes.

Reviewed-by: Alexey Gladkov <[email protected]>
Acked-by: Alexey Gladkov <[email protected]>

> >> > Fixes: 905ae01c4ae2 ("Add a reference to ucounts for each cred")
> >> > Reported-by: Hulk Robot <[email protected]>
> >> > Signed-off-by: Yang Yingliang <[email protected]>
> >> > ---
> >> > kernel/cred.c | 3 ++-
> >> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >> >
> >> > diff --git a/kernel/cred.c b/kernel/cred.c
> >> > index db7c46bf36e5..e6fd2b3fc31f 100644
> >> > --- a/kernel/cred.c
> >> > +++ b/kernel/cred.c
> >> > @@ -372,7 +372,8 @@ int copy_creds(struct task_struct *p, unsigned long clone_flags)
> >> > ret = create_user_ns(new);
> >> > if (ret < 0)
> >> > goto error_put;
> >> > - if (set_cred_ucounts(new) < 0)
> >> > + ret = set_cred_ucounts(new);
> >> > + if (ret < 0)
> >> > goto error_put;
> >> > }
> >>
>
> Eric
>

--
Rgrds, legion

2021-05-28 21:23:23

by Eric W. Biederman

[permalink] [raw]
Subject: Re: [PATCH -next] cred: add missing return error code when set_cred_ucounts() failed

Yang Yingliang <[email protected]> writes:

> If set_cred_ucounts() failed, we need return the error code.
>
> Fixes: 905ae01c4ae2 ("Add a reference to ucounts for each cred")
> Reported-by: Hulk Robot <[email protected]>
> Signed-off-by: Yang Yingliang <[email protected]>

Applied thanks.
> ---
> kernel/cred.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/cred.c b/kernel/cred.c
> index db7c46bf36e5..e6fd2b3fc31f 100644
> --- a/kernel/cred.c
> +++ b/kernel/cred.c
> @@ -372,7 +372,8 @@ int copy_creds(struct task_struct *p, unsigned long clone_flags)
> ret = create_user_ns(new);
> if (ret < 0)
> goto error_put;
> - if (set_cred_ucounts(new) < 0)
> + ret = set_cred_ucounts(new);
> + if (ret < 0)
> goto error_put;
> }