All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][next] ovl: fix null pointer dereference on null stack pointer on error return
@ 2020-06-03 15:45 ` Colin King
  0 siblings, 0 replies; 14+ messages in thread
From: Colin King @ 2020-06-03 15:45 UTC (permalink / raw)
  To: Miklos Szeredi, linux-unionfs; +Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

There are two error return paths where the call to path_put is
dereferencing the null pointer 'stack'.  Fix this by avoiding the
error exit path via label 'out_err' that will lead to the path_put
calls and instead just return the error code directly.

Addresses-Coverity: ("Dereference after null check)"
Fixes: 4155c10a0309 ("ovl: clean up getting lower layers")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 fs/overlayfs/super.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 1094836f7e31..4be1b041b32c 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -1594,20 +1594,18 @@ static struct ovl_entry *ovl_get_lowerstack(struct super_block *sb,
 	unsigned int i;
 	struct ovl_entry *oe;
 
-	err = -EINVAL;
 	if (!ofs->config.upperdir && numlower == 1) {
 		pr_err("at least 2 lowerdir are needed while upperdir nonexistent\n");
-		goto out_err;
+		return ERR_PTR(-EINVAL);
 	} else if (!ofs->config.upperdir && ofs->config.nfs_export &&
 		   ofs->config.redirect_follow) {
 		pr_warn("NFS export requires \"redirect_dir=nofollow\" on non-upper mount, falling back to nfs_export=off.\n");
 		ofs->config.nfs_export = false;
 	}
 
-	err = -ENOMEM;
 	stack = kcalloc(numlower, sizeof(struct path), GFP_KERNEL);
 	if (!stack)
-		goto out_err;
+		return ERR_PTR(-ENOMEM);
 
 	err = -EINVAL;
 	for (i = 0; i < numlower; i++) {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH][next] ovl: fix null pointer dereference on null stack pointer on error return
@ 2020-06-03 15:45 ` Colin King
  0 siblings, 0 replies; 14+ messages in thread
From: Colin King @ 2020-06-03 15:45 UTC (permalink / raw)
  To: Miklos Szeredi, linux-unionfs; +Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

There are two error return paths where the call to path_put is
dereferencing the null pointer 'stack'.  Fix this by avoiding the
error exit path via label 'out_err' that will lead to the path_put
calls and instead just return the error code directly.

Addresses-Coverity: ("Dereference after null check)"
Fixes: 4155c10a0309 ("ovl: clean up getting lower layers")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 fs/overlayfs/super.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 1094836f7e31..4be1b041b32c 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -1594,20 +1594,18 @@ static struct ovl_entry *ovl_get_lowerstack(struct super_block *sb,
 	unsigned int i;
 	struct ovl_entry *oe;
 
-	err = -EINVAL;
 	if (!ofs->config.upperdir && numlower = 1) {
 		pr_err("at least 2 lowerdir are needed while upperdir nonexistent\n");
-		goto out_err;
+		return ERR_PTR(-EINVAL);
 	} else if (!ofs->config.upperdir && ofs->config.nfs_export &&
 		   ofs->config.redirect_follow) {
 		pr_warn("NFS export requires \"redirect_dir=nofollow\" on non-upper mount, falling back to nfs_export=off.\n");
 		ofs->config.nfs_export = false;
 	}
 
-	err = -ENOMEM;
 	stack = kcalloc(numlower, sizeof(struct path), GFP_KERNEL);
 	if (!stack)
-		goto out_err;
+		return ERR_PTR(-ENOMEM);
 
 	err = -EINVAL;
 	for (i = 0; i < numlower; i++) {
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH][next] ovl: fix null pointer dereference on null stack pointer on error return
  2020-06-03 15:45 ` Colin King
@ 2020-06-03 16:11   ` Amir Goldstein
  -1 siblings, 0 replies; 14+ messages in thread
From: Amir Goldstein @ 2020-06-03 16:11 UTC (permalink / raw)
  To: Colin King; +Cc: Miklos Szeredi, overlayfs, kernel-janitors, linux-kernel

On Wed, Jun 3, 2020 at 6:46 PM Colin King <colin.king@canonical.com> wrote:
>
> From: Colin Ian King <colin.king@canonical.com>
>
> There are two error return paths where the call to path_put is
> dereferencing the null pointer 'stack'.  Fix this by avoiding the
> error exit path via label 'out_err' that will lead to the path_put
> calls and instead just return the error code directly.
>
> Addresses-Coverity: ("Dereference after null check)"
> Fixes: 4155c10a0309 ("ovl: clean up getting lower layers")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>


Which branch is that based on?
Doesn't seem to apply to master nor next

> ---
>  fs/overlayfs/super.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
> index 1094836f7e31..4be1b041b32c 100644
> --- a/fs/overlayfs/super.c
> +++ b/fs/overlayfs/super.c
> @@ -1594,20 +1594,18 @@ static struct ovl_entry *ovl_get_lowerstack(struct super_block *sb,
>         unsigned int i;
>         struct ovl_entry *oe;
>
> -       err = -EINVAL;
>         if (!ofs->config.upperdir && numlower == 1) {
>                 pr_err("at least 2 lowerdir are needed while upperdir nonexistent\n");
> -               goto out_err;
> +               return ERR_PTR(-EINVAL);
>         } else if (!ofs->config.upperdir && ofs->config.nfs_export &&
>                    ofs->config.redirect_follow) {
>                 pr_warn("NFS export requires \"redirect_dir=nofollow\" on non-upper mount, falling back to nfs_export=off.\n");
>                 ofs->config.nfs_export = false;
>         }
>
> -       err = -ENOMEM;
>         stack = kcalloc(numlower, sizeof(struct path), GFP_KERNEL);
>         if (!stack)
> -               goto out_err;
> +               return ERR_PTR(-ENOMEM);
>
>         err = -EINVAL;
>         for (i = 0; i < numlower; i++) {
> --
> 2.25.1
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH][next] ovl: fix null pointer dereference on null stack pointer on error return
@ 2020-06-03 16:11   ` Amir Goldstein
  0 siblings, 0 replies; 14+ messages in thread
From: Amir Goldstein @ 2020-06-03 16:11 UTC (permalink / raw)
  To: Colin King; +Cc: Miklos Szeredi, overlayfs, kernel-janitors, linux-kernel

On Wed, Jun 3, 2020 at 6:46 PM Colin King <colin.king@canonical.com> wrote:
>
> From: Colin Ian King <colin.king@canonical.com>
>
> There are two error return paths where the call to path_put is
> dereferencing the null pointer 'stack'.  Fix this by avoiding the
> error exit path via label 'out_err' that will lead to the path_put
> calls and instead just return the error code directly.
>
> Addresses-Coverity: ("Dereference after null check)"
> Fixes: 4155c10a0309 ("ovl: clean up getting lower layers")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>


Which branch is that based on?
Doesn't seem to apply to master nor next

> ---
>  fs/overlayfs/super.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
> index 1094836f7e31..4be1b041b32c 100644
> --- a/fs/overlayfs/super.c
> +++ b/fs/overlayfs/super.c
> @@ -1594,20 +1594,18 @@ static struct ovl_entry *ovl_get_lowerstack(struct super_block *sb,
>         unsigned int i;
>         struct ovl_entry *oe;
>
> -       err = -EINVAL;
>         if (!ofs->config.upperdir && numlower = 1) {
>                 pr_err("at least 2 lowerdir are needed while upperdir nonexistent\n");
> -               goto out_err;
> +               return ERR_PTR(-EINVAL);
>         } else if (!ofs->config.upperdir && ofs->config.nfs_export &&
>                    ofs->config.redirect_follow) {
>                 pr_warn("NFS export requires \"redirect_dir=nofollow\" on non-upper mount, falling back to nfs_export=off.\n");
>                 ofs->config.nfs_export = false;
>         }
>
> -       err = -ENOMEM;
>         stack = kcalloc(numlower, sizeof(struct path), GFP_KERNEL);
>         if (!stack)
> -               goto out_err;
> +               return ERR_PTR(-ENOMEM);
>
>         err = -EINVAL;
>         for (i = 0; i < numlower; i++) {
> --
> 2.25.1
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH][next] ovl: fix null pointer dereference on null stack pointer on error return
  2020-06-03 16:11   ` Amir Goldstein
@ 2020-06-03 16:15     ` Colin Ian King
  -1 siblings, 0 replies; 14+ messages in thread
From: Colin Ian King @ 2020-06-03 16:15 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: Miklos Szeredi, overlayfs, kernel-janitors, linux-kernel

On 03/06/2020 17:11, Amir Goldstein wrote:
> On Wed, Jun 3, 2020 at 6:46 PM Colin King <colin.king@canonical.com> wrote:
>>
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> There are two error return paths where the call to path_put is
>> dereferencing the null pointer 'stack'.  Fix this by avoiding the
>> error exit path via label 'out_err' that will lead to the path_put
>> calls and instead just return the error code directly.
>>
>> Addresses-Coverity: ("Dereference after null check)"
>> Fixes: 4155c10a0309 ("ovl: clean up getting lower layers")
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> 
> 
> Which branch is that based on?
> Doesn't seem to apply to master nor next

It was based on today's linux-next

> 
>> ---
>>  fs/overlayfs/super.c | 6 ++----
>>  1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
>> index 1094836f7e31..4be1b041b32c 100644
>> --- a/fs/overlayfs/super.c
>> +++ b/fs/overlayfs/super.c
>> @@ -1594,20 +1594,18 @@ static struct ovl_entry *ovl_get_lowerstack(struct super_block *sb,
>>         unsigned int i;
>>         struct ovl_entry *oe;
>>
>> -       err = -EINVAL;
>>         if (!ofs->config.upperdir && numlower == 1) {
>>                 pr_err("at least 2 lowerdir are needed while upperdir nonexistent\n");
>> -               goto out_err;
>> +               return ERR_PTR(-EINVAL);
>>         } else if (!ofs->config.upperdir && ofs->config.nfs_export &&
>>                    ofs->config.redirect_follow) {
>>                 pr_warn("NFS export requires \"redirect_dir=nofollow\" on non-upper mount, falling back to nfs_export=off.\n");
>>                 ofs->config.nfs_export = false;
>>         }
>>
>> -       err = -ENOMEM;
>>         stack = kcalloc(numlower, sizeof(struct path), GFP_KERNEL);
>>         if (!stack)
>> -               goto out_err;
>> +               return ERR_PTR(-ENOMEM);
>>
>>         err = -EINVAL;
>>         for (i = 0; i < numlower; i++) {
>> --
>> 2.25.1
>>


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH][next] ovl: fix null pointer dereference on null stack pointer on error return
@ 2020-06-03 16:15     ` Colin Ian King
  0 siblings, 0 replies; 14+ messages in thread
From: Colin Ian King @ 2020-06-03 16:15 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: Miklos Szeredi, overlayfs, kernel-janitors, linux-kernel

On 03/06/2020 17:11, Amir Goldstein wrote:
> On Wed, Jun 3, 2020 at 6:46 PM Colin King <colin.king@canonical.com> wrote:
>>
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> There are two error return paths where the call to path_put is
>> dereferencing the null pointer 'stack'.  Fix this by avoiding the
>> error exit path via label 'out_err' that will lead to the path_put
>> calls and instead just return the error code directly.
>>
>> Addresses-Coverity: ("Dereference after null check)"
>> Fixes: 4155c10a0309 ("ovl: clean up getting lower layers")
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> 
> 
> Which branch is that based on?
> Doesn't seem to apply to master nor next

It was based on today's linux-next

> 
>> ---
>>  fs/overlayfs/super.c | 6 ++----
>>  1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
>> index 1094836f7e31..4be1b041b32c 100644
>> --- a/fs/overlayfs/super.c
>> +++ b/fs/overlayfs/super.c
>> @@ -1594,20 +1594,18 @@ static struct ovl_entry *ovl_get_lowerstack(struct super_block *sb,
>>         unsigned int i;
>>         struct ovl_entry *oe;
>>
>> -       err = -EINVAL;
>>         if (!ofs->config.upperdir && numlower = 1) {
>>                 pr_err("at least 2 lowerdir are needed while upperdir nonexistent\n");
>> -               goto out_err;
>> +               return ERR_PTR(-EINVAL);
>>         } else if (!ofs->config.upperdir && ofs->config.nfs_export &&
>>                    ofs->config.redirect_follow) {
>>                 pr_warn("NFS export requires \"redirect_dir=nofollow\" on non-upper mount, falling back to nfs_export=off.\n");
>>                 ofs->config.nfs_export = false;
>>         }
>>
>> -       err = -ENOMEM;
>>         stack = kcalloc(numlower, sizeof(struct path), GFP_KERNEL);
>>         if (!stack)
>> -               goto out_err;
>> +               return ERR_PTR(-ENOMEM);
>>
>>         err = -EINVAL;
>>         for (i = 0; i < numlower; i++) {
>> --
>> 2.25.1
>>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH][next] ovl: fix null pointer dereference on null stack pointer on error return
  2020-06-03 16:15     ` Colin Ian King
@ 2020-06-03 16:21       ` Amir Goldstein
  -1 siblings, 0 replies; 14+ messages in thread
From: Amir Goldstein @ 2020-06-03 16:21 UTC (permalink / raw)
  To: Colin Ian King; +Cc: Miklos Szeredi, overlayfs, kernel-janitors, linux-kernel

On Wed, Jun 3, 2020 at 7:15 PM Colin Ian King <colin.king@canonical.com> wrote:
>
> On 03/06/2020 17:11, Amir Goldstein wrote:
> > On Wed, Jun 3, 2020 at 6:46 PM Colin King <colin.king@canonical.com> wrote:
> >>
> >> From: Colin Ian King <colin.king@canonical.com>
> >>
> >> There are two error return paths where the call to path_put is
> >> dereferencing the null pointer 'stack'.  Fix this by avoiding the
> >> error exit path via label 'out_err' that will lead to the path_put
> >> calls and instead just return the error code directly.
> >>
> >> Addresses-Coverity: ("Dereference after null check)"
> >> Fixes: 4155c10a0309 ("ovl: clean up getting lower layers")
> >> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> >
> >
> > Which branch is that based on?
> > Doesn't seem to apply to master nor next
>
> It was based on today's linux-next

Oh, I'm behind.
Sorry for the noise.

Thanks,
Amir.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH][next] ovl: fix null pointer dereference on null stack pointer on error return
@ 2020-06-03 16:21       ` Amir Goldstein
  0 siblings, 0 replies; 14+ messages in thread
From: Amir Goldstein @ 2020-06-03 16:21 UTC (permalink / raw)
  To: Colin Ian King; +Cc: Miklos Szeredi, overlayfs, kernel-janitors, linux-kernel

On Wed, Jun 3, 2020 at 7:15 PM Colin Ian King <colin.king@canonical.com> wrote:
>
> On 03/06/2020 17:11, Amir Goldstein wrote:
> > On Wed, Jun 3, 2020 at 6:46 PM Colin King <colin.king@canonical.com> wrote:
> >>
> >> From: Colin Ian King <colin.king@canonical.com>
> >>
> >> There are two error return paths where the call to path_put is
> >> dereferencing the null pointer 'stack'.  Fix this by avoiding the
> >> error exit path via label 'out_err' that will lead to the path_put
> >> calls and instead just return the error code directly.
> >>
> >> Addresses-Coverity: ("Dereference after null check)"
> >> Fixes: 4155c10a0309 ("ovl: clean up getting lower layers")
> >> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> >
> >
> > Which branch is that based on?
> > Doesn't seem to apply to master nor next
>
> It was based on today's linux-next

Oh, I'm behind.
Sorry for the noise.

Thanks,
Amir.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH][next] ovl: fix null pointer dereference on null stack pointer on error return
  2020-06-03 16:15     ` Colin Ian King
@ 2020-06-04  7:25       ` Miklos Szeredi
  -1 siblings, 0 replies; 14+ messages in thread
From: Miklos Szeredi @ 2020-06-04  7:25 UTC (permalink / raw)
  To: Colin Ian King; +Cc: Amir Goldstein, overlayfs, kernel-janitors, linux-kernel

On Wed, Jun 3, 2020 at 6:15 PM Colin Ian King <colin.king@canonical.com> wrote:
>
> On 03/06/2020 17:11, Amir Goldstein wrote:
> > On Wed, Jun 3, 2020 at 6:46 PM Colin King <colin.king@canonical.com> wrote:
> >>
> >> From: Colin Ian King <colin.king@canonical.com>
> >>
> >> There are two error return paths where the call to path_put is
> >> dereferencing the null pointer 'stack'.  Fix this by avoiding the
> >> error exit path via label 'out_err' that will lead to the path_put
> >> calls and instead just return the error code directly.
> >>
> >> Addresses-Coverity: ("Dereference after null check)"
> >> Fixes: 4155c10a0309 ("ovl: clean up getting lower layers")
> >> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> >
> >
> > Which branch is that based on?
> > Doesn't seem to apply to master nor next
>
> It was based on today's linux-next

Yeah, it's actually

Fixes: 73819e26c0f0 ("ovl: get rid of redundant members in struct ovl_fs")

So I'll just fold your patch.  There's still a change in the loop
count for later errors, but that's okay, since
ovl_lower_dir()/ovl_mount_dir_noesc() use the path_put_init() variant.
Actually ovl_lower_dir() can get rid of that path_put_init()
completely, since now the only caller will take care of that...

Thanks for reporting!

Miklos

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH][next] ovl: fix null pointer dereference on null stack pointer on error return
@ 2020-06-04  7:25       ` Miklos Szeredi
  0 siblings, 0 replies; 14+ messages in thread
From: Miklos Szeredi @ 2020-06-04  7:25 UTC (permalink / raw)
  To: Colin Ian King; +Cc: Amir Goldstein, overlayfs, kernel-janitors, linux-kernel

On Wed, Jun 3, 2020 at 6:15 PM Colin Ian King <colin.king@canonical.com> wrote:
>
> On 03/06/2020 17:11, Amir Goldstein wrote:
> > On Wed, Jun 3, 2020 at 6:46 PM Colin King <colin.king@canonical.com> wrote:
> >>
> >> From: Colin Ian King <colin.king@canonical.com>
> >>
> >> There are two error return paths where the call to path_put is
> >> dereferencing the null pointer 'stack'.  Fix this by avoiding the
> >> error exit path via label 'out_err' that will lead to the path_put
> >> calls and instead just return the error code directly.
> >>
> >> Addresses-Coverity: ("Dereference after null check)"
> >> Fixes: 4155c10a0309 ("ovl: clean up getting lower layers")
> >> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> >
> >
> > Which branch is that based on?
> > Doesn't seem to apply to master nor next
>
> It was based on today's linux-next

Yeah, it's actually

Fixes: 73819e26c0f0 ("ovl: get rid of redundant members in struct ovl_fs")

So I'll just fold your patch.  There's still a change in the loop
count for later errors, but that's okay, since
ovl_lower_dir()/ovl_mount_dir_noesc() use the path_put_init() variant.
Actually ovl_lower_dir() can get rid of that path_put_init()
completely, since now the only caller will take care of that...

Thanks for reporting!

Miklos

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH][next] ovl: fix null pointer dereference on null stack pointer on error return
  2020-06-04  7:25       ` Miklos Szeredi
@ 2020-06-04  9:27         ` Colin Ian King
  -1 siblings, 0 replies; 14+ messages in thread
From: Colin Ian King @ 2020-06-04  9:27 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: Amir Goldstein, overlayfs, kernel-janitors, linux-kernel

On 04/06/2020 08:25, Miklos Szeredi wrote:
> On Wed, Jun 3, 2020 at 6:15 PM Colin Ian King <colin.king@canonical.com> wrote:
>>
>> On 03/06/2020 17:11, Amir Goldstein wrote:
>>> On Wed, Jun 3, 2020 at 6:46 PM Colin King <colin.king@canonical.com> wrote:
>>>>
>>>> From: Colin Ian King <colin.king@canonical.com>
>>>>
>>>> There are two error return paths where the call to path_put is
>>>> dereferencing the null pointer 'stack'.  Fix this by avoiding the
>>>> error exit path via label 'out_err' that will lead to the path_put
>>>> calls and instead just return the error code directly.
>>>>
>>>> Addresses-Coverity: ("Dereference after null check)"
>>>> Fixes: 4155c10a0309 ("ovl: clean up getting lower layers")
>>>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>>>
>>>
>>> Which branch is that based on?
>>> Doesn't seem to apply to master nor next
>>
>> It was based on today's linux-next
> 
> Yeah, it's actually
> 
> Fixes: 73819e26c0f0 ("ovl: get rid of redundant members in struct ovl_fs")
> 
> So I'll just fold your patch.  There's still a change in the loop
> count for later errors, but that's okay, since
> ovl_lower_dir()/ovl_mount_dir_noesc() use the path_put_init() variant.
> Actually ovl_lower_dir() can get rid of that path_put_init()
> completely, since now the only caller will take care of that...
> 
> Thanks for reporting!
> 
> Miklos
> 
Is there a reason for folding the fix and hence losing the Signed-off-by
tag?

Colin

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH][next] ovl: fix null pointer dereference on null stack pointer on error return
@ 2020-06-04  9:27         ` Colin Ian King
  0 siblings, 0 replies; 14+ messages in thread
From: Colin Ian King @ 2020-06-04  9:27 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: Amir Goldstein, overlayfs, kernel-janitors, linux-kernel

On 04/06/2020 08:25, Miklos Szeredi wrote:
> On Wed, Jun 3, 2020 at 6:15 PM Colin Ian King <colin.king@canonical.com> wrote:
>>
>> On 03/06/2020 17:11, Amir Goldstein wrote:
>>> On Wed, Jun 3, 2020 at 6:46 PM Colin King <colin.king@canonical.com> wrote:
>>>>
>>>> From: Colin Ian King <colin.king@canonical.com>
>>>>
>>>> There are two error return paths where the call to path_put is
>>>> dereferencing the null pointer 'stack'.  Fix this by avoiding the
>>>> error exit path via label 'out_err' that will lead to the path_put
>>>> calls and instead just return the error code directly.
>>>>
>>>> Addresses-Coverity: ("Dereference after null check)"
>>>> Fixes: 4155c10a0309 ("ovl: clean up getting lower layers")
>>>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>>>
>>>
>>> Which branch is that based on?
>>> Doesn't seem to apply to master nor next
>>
>> It was based on today's linux-next
> 
> Yeah, it's actually
> 
> Fixes: 73819e26c0f0 ("ovl: get rid of redundant members in struct ovl_fs")
> 
> So I'll just fold your patch.  There's still a change in the loop
> count for later errors, but that's okay, since
> ovl_lower_dir()/ovl_mount_dir_noesc() use the path_put_init() variant.
> Actually ovl_lower_dir() can get rid of that path_put_init()
> completely, since now the only caller will take care of that...
> 
> Thanks for reporting!
> 
> Miklos
> 
Is there a reason for folding the fix and hence losing the Signed-off-by
tag?

Colin

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH][next] ovl: fix null pointer dereference on null stack pointer on error return
  2020-06-04  9:27         ` Colin Ian King
@ 2020-06-04  9:39           ` Miklos Szeredi
  -1 siblings, 0 replies; 14+ messages in thread
From: Miklos Szeredi @ 2020-06-04  9:39 UTC (permalink / raw)
  To: Colin Ian King; +Cc: Amir Goldstein, overlayfs, kernel-janitors, linux-kernel

On Thu, Jun 4, 2020 at 11:27 AM Colin Ian King <colin.king@canonical.com> wrote:
>
> On 04/06/2020 08:25, Miklos Szeredi wrote:
> > On Wed, Jun 3, 2020 at 6:15 PM Colin Ian King <colin.king@canonical.com> wrote:
> >>
> >> On 03/06/2020 17:11, Amir Goldstein wrote:
> >>> On Wed, Jun 3, 2020 at 6:46 PM Colin King <colin.king@canonical.com> wrote:
> >>>>
> >>>> From: Colin Ian King <colin.king@canonical.com>
> >>>>
> >>>> There are two error return paths where the call to path_put is
> >>>> dereferencing the null pointer 'stack'.  Fix this by avoiding the
> >>>> error exit path via label 'out_err' that will lead to the path_put
> >>>> calls and instead just return the error code directly.
> >>>>
> >>>> Addresses-Coverity: ("Dereference after null check)"
> >>>> Fixes: 4155c10a0309 ("ovl: clean up getting lower layers")
> >>>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> >>>
> >>>
> >>> Which branch is that based on?
> >>> Doesn't seem to apply to master nor next
> >>
> >> It was based on today's linux-next
> >
> > Yeah, it's actually
> >
> > Fixes: 73819e26c0f0 ("ovl: get rid of redundant members in struct ovl_fs")
> >
> > So I'll just fold your patch.  There's still a change in the loop
> > count for later errors, but that's okay, since
> > ovl_lower_dir()/ovl_mount_dir_noesc() use the path_put_init() variant.
> > Actually ovl_lower_dir() can get rid of that path_put_init()
> > completely, since now the only caller will take care of that...
> >
> > Thanks for reporting!
> >
> > Miklos
> >
> Is there a reason for folding the fix and hence losing the Signed-off-by
> tag?

I generally prefer to fold small fixes for not yet merged patches.  In
this case it's more of a personal preference, but in other cases it
might have an effect on bisectability.

Thanks,
Miklos

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH][next] ovl: fix null pointer dereference on null stack pointer on error return
@ 2020-06-04  9:39           ` Miklos Szeredi
  0 siblings, 0 replies; 14+ messages in thread
From: Miklos Szeredi @ 2020-06-04  9:39 UTC (permalink / raw)
  To: Colin Ian King; +Cc: Amir Goldstein, overlayfs, kernel-janitors, linux-kernel

On Thu, Jun 4, 2020 at 11:27 AM Colin Ian King <colin.king@canonical.com> wrote:
>
> On 04/06/2020 08:25, Miklos Szeredi wrote:
> > On Wed, Jun 3, 2020 at 6:15 PM Colin Ian King <colin.king@canonical.com> wrote:
> >>
> >> On 03/06/2020 17:11, Amir Goldstein wrote:
> >>> On Wed, Jun 3, 2020 at 6:46 PM Colin King <colin.king@canonical.com> wrote:
> >>>>
> >>>> From: Colin Ian King <colin.king@canonical.com>
> >>>>
> >>>> There are two error return paths where the call to path_put is
> >>>> dereferencing the null pointer 'stack'.  Fix this by avoiding the
> >>>> error exit path via label 'out_err' that will lead to the path_put
> >>>> calls and instead just return the error code directly.
> >>>>
> >>>> Addresses-Coverity: ("Dereference after null check)"
> >>>> Fixes: 4155c10a0309 ("ovl: clean up getting lower layers")
> >>>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> >>>
> >>>
> >>> Which branch is that based on?
> >>> Doesn't seem to apply to master nor next
> >>
> >> It was based on today's linux-next
> >
> > Yeah, it's actually
> >
> > Fixes: 73819e26c0f0 ("ovl: get rid of redundant members in struct ovl_fs")
> >
> > So I'll just fold your patch.  There's still a change in the loop
> > count for later errors, but that's okay, since
> > ovl_lower_dir()/ovl_mount_dir_noesc() use the path_put_init() variant.
> > Actually ovl_lower_dir() can get rid of that path_put_init()
> > completely, since now the only caller will take care of that...
> >
> > Thanks for reporting!
> >
> > Miklos
> >
> Is there a reason for folding the fix and hence losing the Signed-off-by
> tag?

I generally prefer to fold small fixes for not yet merged patches.  In
this case it's more of a personal preference, but in other cases it
might have an effect on bisectability.

Thanks,
Miklos

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2020-06-04  9:39 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-03 15:45 [PATCH][next] ovl: fix null pointer dereference on null stack pointer on error return Colin King
2020-06-03 15:45 ` Colin King
2020-06-03 16:11 ` Amir Goldstein
2020-06-03 16:11   ` Amir Goldstein
2020-06-03 16:15   ` Colin Ian King
2020-06-03 16:15     ` Colin Ian King
2020-06-03 16:21     ` Amir Goldstein
2020-06-03 16:21       ` Amir Goldstein
2020-06-04  7:25     ` Miklos Szeredi
2020-06-04  7:25       ` Miklos Szeredi
2020-06-04  9:27       ` Colin Ian King
2020-06-04  9:27         ` Colin Ian King
2020-06-04  9:39         ` Miklos Szeredi
2020-06-04  9:39           ` Miklos Szeredi

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.