Linux Overlay Filesystem development
 help / color / mirror / Atom feed
* [bug report] ovl: detect overlapping layers
@ 2019-05-29 10:31 Dan Carpenter
  2019-05-29 10:42 ` Amir Goldstein
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2019-05-29 10:31 UTC (permalink / raw)
  To: amir73il; +Cc: linux-unionfs

Hello Amir Goldstein,

The patch 0e7f2cccb42a: "ovl: detect overlapping layers" from Apr 18,
2019, leads to the following static checker warning:

	fs/overlayfs/super.c:998 ovl_setup_trap()
	warn: passing a valid pointer to 'PTR_ERR'

fs/overlayfs/super.c
   991  static int ovl_setup_trap(struct super_block *sb, struct dentry *dir,
   992                            struct inode **ptrap, const char *name)
   993  {
   994          struct inode *trap;
   995          int err;
   996  
   997          trap = ovl_get_trap_inode(sb, dir);
   998          err = PTR_ERR(trap);
   999          if (IS_ERR(trap) && err == -ELOOP) {
  1000                  pr_err("overlayfs: conflicting %s path\n", name);
  1001                  return err;
  1002          }
  1003  
  1004          *ptrap = trap;
  1005          return 0;
  1006  }

The warning message is wrong but the code is also wrong.  The
ovl_get_trap_inode() can return ERR_PTR(-ENOMEM) and that would lead to
and Oops when we try to call iput() on it.

regards,
dan carpenter

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

* Re: [bug report] ovl: detect overlapping layers
  2019-05-29 10:31 [bug report] ovl: detect overlapping layers Dan Carpenter
@ 2019-05-29 10:42 ` Amir Goldstein
  0 siblings, 0 replies; 2+ messages in thread
From: Amir Goldstein @ 2019-05-29 10:42 UTC (permalink / raw)
  To: Dan Carpenter, Miklos Szeredi; +Cc: overlayfs

On Wed, May 29, 2019 at 1:31 PM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> Hello Amir Goldstein,
>
> The patch 0e7f2cccb42a: "ovl: detect overlapping layers" from Apr 18,
> 2019, leads to the following static checker warning:
>
>         fs/overlayfs/super.c:998 ovl_setup_trap()
>         warn: passing a valid pointer to 'PTR_ERR'
>
> fs/overlayfs/super.c
>    991  static int ovl_setup_trap(struct super_block *sb, struct dentry *dir,
>    992                            struct inode **ptrap, const char *name)
>    993  {
>    994          struct inode *trap;
>    995          int err;
>    996
>    997          trap = ovl_get_trap_inode(sb, dir);
>    998          err = PTR_ERR(trap);
>    999          if (IS_ERR(trap) && err == -ELOOP) {
>   1000                  pr_err("overlayfs: conflicting %s path\n", name);
>   1001                  return err;
>   1002          }
>   1003
>   1004          *ptrap = trap;
>   1005          return 0;
>   1006  }
>
> The warning message is wrong but the code is also wrong.  The
> ovl_get_trap_inode() can return ERR_PTR(-ENOMEM) and that would lead to
> and Oops when we try to call iput() on it.
>

Right, thank you for spotting this!

Miklos,

Can you fold in this fix:

Thanks,
Amir.

--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -996,8 +996,9 @@ static int ovl_setup_trap(struct super_block *sb,
struct dentry *dir,

        trap = ovl_get_trap_inode(sb, dir);
        err = PTR_ERR(trap);
-       if (IS_ERR(trap) && err == -ELOOP) {
-               pr_err("overlayfs: conflicting %s path\n", name);
+       if (IS_ERR(trap)) {
+               if (err == -ELOOP)
+                       pr_err("overlayfs: conflicting %s path\n", name);
                return err;
        }

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

end of thread, other threads:[~2019-05-29 10:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-29 10:31 [bug report] ovl: detect overlapping layers Dan Carpenter
2019-05-29 10:42 ` Amir Goldstein

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox