From: Al Viro <viro@zeniv.linux.org.uk>
To: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Cc: Peng Zhang <zhangpeng362@huawei.com>,
kari.argillander@gmail.com, akpm@linux-foundation.org,
ntfs3@lists.linux.dev, linux-kernel@vger.kernel.org,
sunnanyong@huawei.com, wangkefeng.wang@huawei.com,
Dan Carpenter <error27@gmail.com>
Subject: Re: [PATCH -next] fs/ntfs3: Fix potential NULL/IS_ERR bug in ntfs_lookup()
Date: Mon, 16 Jan 2023 20:34:48 +0000 [thread overview]
Message-ID: <Y8W06C8137iclvdl@ZenIV> (raw)
In-Reply-To: <Y8Ww/48pwi8RbTIv@ZenIV>
On Mon, Jan 16, 2023 at 08:18:07PM +0000, Al Viro wrote:
> On Fri, Jan 13, 2023 at 02:05:56PM +0400, Konstantin Komarov wrote:
>
> > Hello.
> >
> > We have added a patch with this check just before the New Year. (here https://lore.kernel.org/lkml/ee705b24-865b-26ff-157d-4cb2a303a962@paragon-software.com/)
>
> See upthread for the reasons why that's wrong. Incidentally,
> mixing logical change with a pile of whitespace changes is
> bad idea - it's very easy for reviewers to miss...
>
> Other observation from the cursory look through your namei.c:
> ntfs_create_inode() has no reason to return inode; the reference
> it creates goes into dentry. Make it return int, the callers will
> be happier. While we are at it, use d_instantiate_new() instead
> of d_instantiate() + unlock_new_inode() there.
>
> Incidentally, control flow in there is harder to follow that it
> needs to be:
> * everything that reaches out{3,4,5,6,7} is guaranteed
> to have err != 0;
> * fallthrough into out2 is guaranteed to have err != 0;
> direct branch to it - err == 0.
> * direct branch to out1 is guaranteed to have err != 0.
>
> I would suggest something along the lines of the following (completely
> untested) delta; the callers are clearly better off that way and
> failure paths are separated from the success one - they didn't share
> anywhere near enough to have it worth bothering.
While we are at it - what's the point passing the symlink body length
to ntfs_create_inode()? We could calculate it there just as well -
it's used only for symlinks (unsurprisingly) and you've got uncomfortably
many arguments as it is...
prev parent reply other threads:[~2023-01-16 20:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-12 1:32 [PATCH -next] fs/ntfs3: Fix potential NULL/IS_ERR bug in ntfs_lookup() Peng Zhang
2023-01-12 3:43 ` Al Viro
2023-01-12 4:11 ` Al Viro
2023-01-13 10:05 ` Konstantin Komarov
2023-01-16 20:18 ` Al Viro
2023-01-16 20:34 ` Al Viro [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y8W06C8137iclvdl@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=akpm@linux-foundation.org \
--cc=almaz.alexandrovich@paragon-software.com \
--cc=error27@gmail.com \
--cc=kari.argillander@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ntfs3@lists.linux.dev \
--cc=sunnanyong@huawei.com \
--cc=wangkefeng.wang@huawei.com \
--cc=zhangpeng362@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox