From: ebiederm@xmission.com (Eric W. Biederman)
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Stefan Lippers-Hollmann <s.l-h@gmx.de>,
Christian Brauner <christian.brauner@canonical.com>,
Christian Brauner <christian.brauner@ubuntu.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
"Serge E. Hallyn" <serge@hallyn.com>,
Al Viro <viro@zeniv.linux.org.uk>,
Thorsten Leemhuis <regressions@leemhuis.info>
Subject: Re: [PATCH 0/1] devpts: use dynamic_dname() to generate proc name
Date: Thu, 24 Aug 2017 10:51:05 -0500 [thread overview]
Message-ID: <87efs1ezh2.fsf@xmission.com> (raw)
In-Reply-To: <CA+55aFxnDoH4RLHTvkGwg59LCDRh+r780b2MXCo3=Hb2pSfLww@mail.gmail.com> (Linus Torvalds's message of "Wed, 23 Aug 2017 20:24:35 -0700")
Linus Torvalds <torvalds@linux-foundation.org> writes:
> On Wed, Aug 23, 2017 at 8:11 PM, Eric W. Biederman
> <ebiederm@xmission.com> wrote:
>> -static int pty_get_peer(struct tty_struct *tty, int flags)
>> +int ptm_open_peer(struct file *master, struct tty_struct *tty, int flags)
>> {
>> int fd = -1;
>> struct file *filp = NULL;
>> int retval = -EINVAL;
>> + struct path path;
>> +
>> + if ((tty->driver->type != TTY_DRIVER_TYPE_PTY) ||
>> + (tty->driver->subtype != PTY_TYPE_MASTER))
>> + return -EIO;
>
> No. Afaik, that could be a legact PTY, which wouldn't be ok.
>
> I think you need to do
>
> if (tty->driver != ptm_driver)
> return -EIO;
>
> which should check both that it's the unix98 pty, and that it's the master.
>
> Maybe I'm missing something.
>
> That check used to be implicit, in that only the unix98 pty's could
> reach that pty_unix98_ioctl() function, so then testing just that it
> was a master was sufficient.
No. That seems correct. Change made. If nothing else it is cheaper
and clearer so even if the other version wasn't wrong it is a good idea.
>> - /* We need to cache a fake path for TIOCGPTPEER. */
>> - pts_path = kmalloc(sizeof(struct path), GFP_KERNEL);
>> - if (!pts_path)
>> - goto err_release;
>> - pts_path->mnt = filp->f_path.mnt;
>> - pts_path->dentry = dentry;
>> - path_get(pts_path);
>> - tty->link->driver_data = pts_path;
>> + tty->link->driver_data = dentry;
>
> We used to do "path_get()". Shouldn't we now use "dget()"?
>
> But maybe the slave dentry is guaranteed to be around and we don't
> need to do that. So your approach may be fine. You did remove all the
> path_put() calls too, so I guess it all matches up.
>
> So this looks like it could be fine, but I'd like to make sure.
That change is a revert to the old v4.12 code. So it is definitely
not regression inducing.
Further devpts_pty_new allocates a dentry keeps it in the devpts
filesystem. The dentry is good until devpts_pty_kill where the
dentry is unlinked and killed.
I figure not differences from v4.12 if the logic hasn't changed
seems a good good way to cut down on the search for bugs/regressions.
>> +struct vfsmount *devpts_mnt(struct file *filp)
>> +{
>> + struct path path;
>> + int err;
>> +
>> + path = filp->f_path;
>> + path_get(&path);
>> +
>> + err = devpts_ptmx_path(&path);
>> + if (err) {
>> + path_put(&path);
>> + path.mnt = ERR_PTR(err);
>> + }
>> + return path.mnt;
>> +}
>
> That can't be right. You're leaking the dentry that you're not returning, no?
Correct. That is buggy. Will fix before I resend.
> But yes, apart from those comments, this looks like what I envisioned.
>
> Needs testing, and needs more looking at those reference counts, but
> otherwise looks good.
>
> And while the patch is a bit bigger, I do like getting rid of that
> 'struct path' thing, and keeping just the dentry.
Eric
next prev parent reply other threads:[~2017-08-24 15:51 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-16 17:12 [PATCH 0/1] devpts: use dynamic_dname() to generate proc name Christian Brauner
2017-08-16 17:12 ` [PATCH 1/1] " Christian Brauner
2017-08-16 18:26 ` [PATCH 0/1] " Linus Torvalds
2017-08-16 18:48 ` Linus Torvalds
2017-08-16 19:48 ` Christian Brauner
2017-08-16 19:56 ` Linus Torvalds
2017-08-16 20:19 ` Linus Torvalds
2017-08-16 20:30 ` Linus Torvalds
2017-08-16 21:03 ` Linus Torvalds
2017-08-16 21:37 ` Christian Brauner
2017-08-16 21:45 ` Linus Torvalds
2017-08-16 21:55 ` Linus Torvalds
2017-08-16 22:05 ` Christian Brauner
2017-08-16 22:28 ` Christian Brauner
2017-08-23 15:31 ` Eric W. Biederman
2017-08-23 21:15 ` Christian Brauner
2017-08-16 22:46 ` Eric W. Biederman
2017-08-16 22:58 ` Linus Torvalds
2017-08-16 23:51 ` Eric W. Biederman
2017-08-17 0:08 ` Linus Torvalds
2017-08-17 1:24 ` Eric W. Biederman
2017-08-24 0:24 ` Stefan Lippers-Hollmann
2017-08-24 0:42 ` Linus Torvalds
2017-08-24 1:16 ` Linus Torvalds
2017-08-24 1:25 ` Eric W. Biederman
2017-08-24 1:32 ` Linus Torvalds
2017-08-24 1:49 ` Linus Torvalds
2017-08-24 2:01 ` Linus Torvalds
2017-08-24 3:11 ` Eric W. Biederman
2017-08-24 3:24 ` Linus Torvalds
2017-08-24 15:51 ` Eric W. Biederman [this message]
2017-08-24 4:24 ` Stefan Lippers-Hollmann
2017-08-24 15:54 ` Eric W. Biederman
2017-08-24 17:52 ` Linus Torvalds
2017-08-24 18:06 ` Linus Torvalds
2017-08-24 18:13 ` Linus Torvalds
2017-08-24 18:31 ` Linus Torvalds
2017-08-24 18:36 ` Linus Torvalds
2017-08-24 20:24 ` Stefan Lippers-Hollmann
2017-08-24 20:27 ` Linus Torvalds
2017-08-24 18:40 ` Eric W. Biederman
2017-08-24 18:51 ` Linus Torvalds
2017-08-24 19:23 ` Eric W. Biederman
2017-08-24 20:13 ` [PATCH v3] pty: Repair TIOCGPTPEER Eric W. Biederman
2017-08-24 21:01 ` Stefan Lippers-Hollmann
[not found] ` <CAPP7u0WHqDfxTW6hmc=DsmHuoALZcrWdU-Odu=FfoTX26SGHQg@mail.gmail.com>
2017-08-24 19:22 ` [PATCH 0/1] devpts: use dynamic_dname() to generate proc name Linus Torvalds
2017-08-24 19:25 ` Linus Torvalds
2017-08-24 20:43 ` Eric W. Biederman
2017-08-24 21:07 ` Linus Torvalds
2017-08-24 23:01 ` Eric W. Biederman
2017-08-24 23:27 ` Linus Torvalds
2017-08-24 23:37 ` Christian Brauner
2017-08-26 1:00 ` Linus Torvalds
2017-08-24 19:48 ` Eric W. Biederman
2017-08-17 1:37 ` Eric W. Biederman
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=87efs1ezh2.fsf@xmission.com \
--to=ebiederm@xmission.com \
--cc=christian.brauner@canonical.com \
--cc=christian.brauner@ubuntu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=regressions@leemhuis.info \
--cc=s.l-h@gmx.de \
--cc=serge@hallyn.com \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
/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