From: Al Viro <viro@zeniv.linux.org.uk>
To: Kees Cook <keescook@chromium.org>
Cc: "Guilherme G. Piccoli" <gpiccoli@igalia.com>,
Christian Brauner <brauner@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
linux-fsdevel@vger.kernel.org, Tony Luck <tony.luck@intel.com>,
linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH 3/5] fs: Add DEFINE_FREE for struct inode
Date: Sat, 2 Dec 2023 21:42:12 +0000 [thread overview]
Message-ID: <20231202214212.GR38156@ZenIV> (raw)
In-Reply-To: <202312021331.D2DFBF153@keescook>
On Sat, Dec 02, 2023 at 01:34:32PM -0800, Kees Cook wrote:
> On Sat, Dec 02, 2023 at 09:28:46PM +0000, Al Viro wrote:
> > On Sat, Dec 02, 2023 at 01:22:13PM -0800, Kees Cook wrote:
> > > Allow __free(iput) markings for easier cleanup on inode allocations.
> >
> > NAK. That's a bloody awful idea for that particular data type, since
> > 1) ERR_PTR(...) is not uncommon and passing it to iput() is a bug.
>
> Ah, sounds like instead of "if (_T)", you'd rather see
> "if (!IS_ERR_OR_NULL(_T))" ?
No. I would rather *not* see IS_ERR_OR_NULL anywhere, but that's
a separate rant.
> > 2) the common pattern is to have reference-consuming primitives,
> > with failure exits normally *not* having to do iput() at all.
>
> This I'm not following. If I make a call to "new_inode(sb)" that I end
> up not using, I need to call "iput()" in it...
>
> How should this patch be written to avoid the iput() on failure?
> https://lore.kernel.org/all/20231202212217.243710-4-keescook@chromium.org/
I'll poke around and see what I can suggest; said that, one thing I have
spotted there on the quick look is that you are exposing hashed dentry associated
with your inode before you set its ->i_private. Have an open() hit just after
that d_add() and this
static int pstore_file_open(struct inode *inode, struct file *file)
{
struct pstore_private *ps = inode->i_private;
struct seq_file *sf;
int err;
const struct seq_operations *sops = NULL;
if (ps->record->type == PSTORE_TYPE_FTRACE)
... with happily oops on you.
next prev parent reply other threads:[~2023-12-02 21:42 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-02 21:22 [PATCH 0/5] pstore: Initial use of cleanup.h Kees Cook
2023-12-02 21:22 ` [PATCH 1/5] pstore: inode: Convert kfree() usage to __free(kfree) Kees Cook
2023-12-02 21:22 ` [PATCH 2/5] pstore: inode: Convert mutex usage to guard(mutex) Kees Cook
2023-12-05 7:01 ` Dave Chinner
2023-12-02 21:22 ` [PATCH 3/5] fs: Add DEFINE_FREE for struct inode Kees Cook
2023-12-02 21:28 ` Al Viro
2023-12-02 21:34 ` Kees Cook
2023-12-02 21:42 ` Al Viro [this message]
2023-12-02 21:45 ` Al Viro
2023-12-05 11:38 ` Christian Brauner
2023-12-02 21:22 ` [PATCH 4/5] pstore: inode: Use __free(iput) for inode allocations Kees Cook
2023-12-02 21:22 ` [PATCH 5/5] pstore: inode: Use cleanup.h for struct pstore_private Kees Cook
2023-12-02 22:27 ` Al Viro
2023-12-05 0:54 ` Kees Cook
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=20231202214212.GR38156@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=brauner@kernel.org \
--cc=gpiccoli@igalia.com \
--cc=keescook@chromium.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=tony.luck@intel.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;
as well as URLs for NNTP newsgroup(s).