From: Al Viro <viro@zeniv.linux.org.uk>
To: Pavel Shilovsky <piastryyy@gmail.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
Steve French <stfrench@microsoft.com>,
Ronnie Sahlberg <lsahlber@redhat.com>,
linux-cifs <linux-cifs@vger.kernel.org>,
Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: build_path_from_dentry_optional_prefix() may schedule from invalid context
Date: Mon, 9 Dec 2019 00:34:13 +0000 [thread overview]
Message-ID: <20191209003413.GY4203@ZenIV.linux.org.uk> (raw)
In-Reply-To: <CAKywueSC=MoBB6t2OeUiyc6+GST2Jgg8FTO-kkXif-pn+1k-cw@mail.gmail.com>
On Mon, Sep 30, 2019 at 10:32:16AM -0700, Pavel Shilovsky wrote:
> сб, 21 сент. 2019 г. в 15:38, Al Viro <viro@zeniv.linux.org.uk>:
> > IOW, kindly lose that nonsense. More importantly, why bother
> > with that kmalloc()? Just __getname() in the very beginning
> > and __putname() on failure (and for freeing the result afterwards).
> >
> > What's more, you are open-coding dentry_path_raw(), badly.
> > The only differences are
> > * use of dirsep instead of '/' and
> > * a prefix slapped in the beginning.
> >
> > I'm fairly sure that
> > char *buf = __getname();
> > char *s;
> >
> > *to_free = NULL;
> > if (unlikely(!buf))
> > return NULL;
> >
> > s = dentry_path_raw(dentry, buf, PATH_MAX);
> > if (IS_ERR(s) || s < buf + prefix_len)
> > __putname(buf);
> > return NULL; // assuming that you don't care about details
> > }
> >
> > if (dirsep != '/') {
> > char *p = s;
> > while ((p = strchr(p, '/')) != NULL)
> > *p++ = dirsep;
> > }
> >
> > s -= prefix_len;
> > memcpy(s, prefix, prefix_len);
> >
> > *to_free = buf;
> > return s;
> >
> > would end up being faster, not to mention much easier to understand.
> > With the caller expected to pass &to_free among the arguments and
> > __putname() it once it's done.
> >
> > Or just do __getname() in the caller and pass it to the function -
> > in that case freeing (in all cases) would be up to the caller.
>
> Thanks for pointing this out. Someone should look at this closely and
> clean it up.
Could you take a look through vfs.git#misc.cifs?
next prev parent reply other threads:[~2019-12-09 0:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-29 5:02 build_path_from_dentry_optional_prefix() may schedule from invalid context Sergey Senozhatsky
2019-09-20 0:11 ` Pavel Shilovsky
2019-09-21 22:38 ` Al Viro
2019-09-30 17:32 ` Pavel Shilovsky
2019-12-09 0:34 ` Al Viro [this message]
2019-12-10 19:14 ` Pavel Shilovsky
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=20191209003413.GY4203@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lsahlber@redhat.com \
--cc=piastryyy@gmail.com \
--cc=sergey.senozhatsky.work@gmail.com \
--cc=stfrench@microsoft.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 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.