lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 11 Jul 2018 08:43:31 +0300
From:   Amir Goldstein <amir73il@...il.com>
To:     Al Viro <viro@...iv.linux.org.uk>
Cc:     Linus Torvalds <torvalds@...ux-foundation.org>,
        linux-fsdevel <linux-fsdevel@...r.kernel.org>,
        linux-kernel <linux-kernel@...r.kernel.org>,
        Miklos Szeredi <mszeredi@...hat.com>
Subject: Re: [RFC][PATCH 15/42] lift fput() on late failures into path_openat()

On Wed, Jul 11, 2018 at 5:21 AM, Al Viro <viro@...iv.linux.org.uk> wrote:
[...]
> @@ -3407,8 +3407,6 @@ static int do_last(struct nameidata *nd,
>         if (!error && will_truncate)
>                 error = handle_truncate(file);
>  out:
> -       if (unlikely(error) && (*opened & FILE_OPENED))
> -               fput(file);
>         if (unlikely(error > 0)) {
>                 WARN_ON(1);

Another opportunity to squash WARN_ON(1) with condition.

>                 error = -EINVAL;
> @@ -3484,8 +3482,6 @@ static int do_tmpfile(struct nameidata *nd, unsigned flags,
>         if (error)
>                 goto out2;
>         error = open_check_o_direct(file);
> -       if (error)
> -               fput(file);
>  out2:
>         mnt_drop_write(path.mnt);
>  out:
> @@ -3547,20 +3543,20 @@ static struct file *path_openat(struct nameidata *nd,
>         }
>         terminate_walk(nd);
>  out2:
> -       if (!(opened & FILE_OPENED)) {
> -               BUG_ON(!error);
> -               fput(file);
> +       if (likely(!error)) {
> +               if (likely(opened & FILE_OPENED))
> +                       return file;
> +               WARN_ON(1);

This style may be open for debate but:

               if (!WARN_ON(!(opened & FILE_OPENED)))
                       return file;

Maybe we need WARN_UNLESS() or WARN_ASSERT()

Thanks,
Amir.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ