Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp562887imm; Wed, 6 Jun 2018 02:11:45 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL+NuCuBxVswjY4TtpfLpwojKakwubh+nopy+C3zIk17VPZuxb0x+WJmmFcmnbPQHR6Lfqv X-Received: by 2002:a65:5b8b:: with SMTP id i11-v6mr1906879pgr.225.1528276304795; Wed, 06 Jun 2018 02:11:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528276304; cv=none; d=google.com; s=arc-20160816; b=QRBdCOGAnJpEtHSUBumyy3zMt7o9fL2wnqc9Sn71mZtu8Co4blg2GD13fsRS69XQ3t 15CMFHSYdEYw3ea6tqccFjgDqpxJlnPfJ5bV68mkpMnh3xo57RN6MJGPnnG7YX8evKeY K/jYd+y1Y+pQNNkpRmYFGMhK87CX7r0L8vljj7EW6jGIFNTa4qsxK0SQB/nJZ1d/W4uY FqmS2wF/lMTdTz6PJuqz4Db4Avu3aJmRRK4E6BxFLcr4yqXNZ8eG2MhyJAcrev5G9gsQ 9ukewX0oZXNPeUz+/pcLN2x3DlNMobnlCmj64NDWGHgf2QPM5UWHNeGKNlXP77N6SOsj HT0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:importance:content-transfer-encoding :mime-version:subject:references:in-reply-to:message-id:cc:to:from :date:arc-authentication-results; bh=ViIwGb3/YLon86gjrNkjPRt6hs0B5vlByC0+zCMiFFQ=; b=f+j2OdQP6JfMS8Tivjlyt7U40JyWtUQOq6BKLnem9YOg5M3BbG7wpOefnVCVET3R7L kTO8xUSaFegXbc4C7jb0KCQ+a7wC32dsITIF2ZuU786sYC4LvmKSbkVYz07RJ7MHOME7 hyuoLb0RNv/3AiHSRxQmJ3YsY+3fzpE2/FB0dz8qQRXq3qXV2bRSW+8fbSwW+xob9AJb LLQ6/T8kpaXR9znrmBGLvqwE+/qr7/ryXIi/v5rDKI6GHssnOC4Bzi+3vvhkuyox6N4k cwPJesfUx1Jaq5j97kp9paKhEgxjKvnq7Li7YP6t7vTJuVzXQHGSHHqbDDvPhHV864W7 AA1w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3-v6si49948581plm.428.2018.06.06.02.11.30; Wed, 06 Jun 2018 02:11:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932433AbeFFJKF (ORCPT + 99 others); Wed, 6 Jun 2018 05:10:05 -0400 Received: from mx01-sz.bfs.de ([194.94.69.67]:28319 "EHLO mx01-sz.bfs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932260AbeFFJKB (ORCPT ); Wed, 6 Jun 2018 05:10:01 -0400 X-Greylist: delayed 493 seconds by postgrey-1.27 at vger.kernel.org; Wed, 06 Jun 2018 05:10:00 EDT Received: from localhost (localhost [127.0.0.1]) by mx01-sz.bfs.de (Postfix) with ESMTP id 8F5CC600FC; Wed, 6 Jun 2018 11:01:46 +0200 (CEST) X-Virus-Scanned: amavisd-new at bfs.de Received: from mx01-sz.bfs.de ([127.0.0.1]) by localhost (mx01-sz.bfs.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rJk6eL-7V4UN; Wed, 6 Jun 2018 11:01:46 +0200 (CEST) Received: from mail-sz.bfs.de (mail-sz.bfs.de [10.129.18.200]) by mx01-sz.bfs.de (Postfix) with ESMTPS; Wed, 6 Jun 2018 11:01:46 +0200 (CEST) Received: from null (ox-groupware01-sz.bfs.de [10.129.18.42]) by mail-sz.bfs.de (Postfix) with ESMTPS id ECB997F483; Wed, 6 Jun 2018 11:01:45 +0200 (CEST) Date: Wed, 6 Jun 2018 11:01:44 +0200 (CEST) From: Walter Harms To: linux-ppp@vger.kernel.org, Eric Biggers , Paul Mackerras Cc: syzkaller-bugs@googlegroups.com, Guillaume Nault , Eric Biggers , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Message-ID: <909200487.17769.1528275705881@ox-groupware.bfs.de> In-Reply-To: <20180523213738.146911-1-ebiggers3@gmail.com> References: <20180523035952.25768-1-ebiggers3@gmail.com> <20180523213738.146911-1-ebiggers3@gmail.com> Subject: Re: [PATCH v2] ppp: remove the PPPIOCDETACH ioctl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Medium X-Mailer: Open-Xchange Mailer v7.8.4-Rev31 X-Originating-Client: com.openexchange.ox.gui.dhtml Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > Eric Biggers hat am 23. Mai 2018 um 23:37 geschrieben: > > > From: Eric Biggers > > The PPPIOCDETACH ioctl effectively tries to "close" the given ppp file > before f_count has reached 0, which is fundamentally a bad idea. It > does check 'f_count < 2', which excludes concurrent operations on the > file since they would only be possible with a shared fd table, in which > case each fdget() would take a file reference. However, it fails to > account for the fact that even with 'f_count == 1' the file can still be > linked into epoll instances. As reported by syzbot, this can trivially > be used to cause a use-after-free. > > Yet, the only known user of PPPIOCDETACH is pppd versions older than > ppp-2.4.2, which was released almost 15 years ago (November 2003). > Also, PPPIOCDETACH apparently stopped working reliably at around the > same time, when the f_count check was added to the kernel, e.g. see > https://lkml.org/lkml/2002/12/31/83. Also, the current 'f_count < 2' > check makes PPPIOCDETACH only work in single-threaded applications; it > always fails if called from a multithreaded application. > > All pppd versions released in the last 15 years just close() the file > descriptor instead. > > Therefore, instead of hacking around this bug by exporting epoll > internals to modules, and probably missing other related bugs, just > remove the PPPIOCDETACH ioctl and see if anyone actually notices. Leave > a stub in place that prints a one-time warning and returns EINVAL. > > Reported-by: syzbot+16363c99d4134717c05b@syzkaller.appspotmail.com > Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") > Cc: stable@vger.kernel.org > Signed-off-by: Eric Biggers > --- > > v2: leave a stub in place, rather than removing the ioctl completely. > > Documentation/networking/ppp_generic.txt | 6 ------ > drivers/net/ppp/ppp_generic.c | 27 +++++------------------- > include/uapi/linux/ppp-ioctl.h | 2 +- > 3 files changed, 6 insertions(+), 29 deletions(-) > > diff --git a/Documentation/networking/ppp_generic.txt > b/Documentation/networking/ppp_generic.txt > index 091d20273dcb..61daf4b39600 100644 > --- a/Documentation/networking/ppp_generic.txt > +++ b/Documentation/networking/ppp_generic.txt > @@ -300,12 +300,6 @@ unattached instance are: > The ioctl calls available on an instance of /dev/ppp attached to a > channel are: > > -* PPPIOCDETACH detaches the instance from the channel. This ioctl is > - deprecated since the same effect can be achieved by closing the > - instance. In order to prevent possible races this ioctl will fail > - with an EINVAL error if more than one file descriptor refers to this > - instance (i.e. as a result of dup(), dup2() or fork()). > - > * PPPIOCCONNECT connects this channel to a PPP interface. The > argument should point to an int containing the interface unit > number. It will return an EINVAL error if the channel is already > diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c > index dc7c7ec43202..02ad03a2fab7 100644 > --- a/drivers/net/ppp/ppp_generic.c > +++ b/drivers/net/ppp/ppp_generic.c > @@ -605,30 +605,13 @@ static long ppp_ioctl(struct file *file, unsigned int > cmd, unsigned long arg) > > if (cmd == PPPIOCDETACH) { > /* > - * We have to be careful here... if the file descriptor > - * has been dup'd, we could have another process in the > - * middle of a poll using the same file *, so we had > - * better not free the interface data structures - > - * instead we fail the ioctl. Even in this case, we > - * shut down the interface if we are the owner of it. > - * Actually, we should get rid of PPPIOCDETACH, userland > - * (i.e. pppd) could achieve the same effect by closing > - * this fd and reopening /dev/ppp. > + * PPPIOCDETACH is no longer supported as it was heavily broken, > + * and is only known to have been used by pppd older than > + * ppp-2.4.2 (released November 2003). > */ > + pr_warn_once("%s (%d) used obsolete PPPIOCDETACH ioctl\n", > + current->comm, current->pid); > err = -EINVAL; > - if (pf->kind == INTERFACE) { > - ppp = PF_TO_PPP(pf); > - rtnl_lock(); > - if (file == ppp->owner) > - unregister_netdevice(ppp->dev); > - rtnl_unlock(); > - } > - if (atomic_long_read(&file->f_count) < 2) { > - ppp_release(NULL, file); > - err = 0; > - } else > - pr_warn("PPPIOCDETACH file->f_count=%ld\n", > - atomic_long_read(&file->f_count)); > goto out; > } > > diff --git a/include/uapi/linux/ppp-ioctl.h b/include/uapi/linux/ppp-ioctl.h > index b19a9c249b15..784c2e3e572e 100644 > --- a/include/uapi/linux/ppp-ioctl.h > +++ b/include/uapi/linux/ppp-ioctl.h > @@ -106,7 +106,7 @@ struct pppol2tp_ioc_stats { > #define PPPIOCGIDLE _IOR('t', 63, struct ppp_idle) /* get idle time */ > #define PPPIOCNEWUNIT _IOWR('t', 62, int) /* create new ppp unit */ > #define PPPIOCATTACH _IOW('t', 61, int) /* attach to ppp unit */ > -#define PPPIOCDETACH _IOW('t', 60, int) /* detach from ppp unit/chan */ > +#define PPPIOCDETACH _IOW('t', 60, int) /* obsolete, do not use */ It's a bit late but ... i would suggest a stronger wording here. like /* removed 2003 */ for me "obsolete" sounds like "maybe it will be removed in a distant future" just my 2 cents, re, wh > #define PPPIOCSMRRU _IOW('t', 59, int) /* set multilink MRU */ > #define PPPIOCCONNECT _IOW('t', 58, int) /* connect channel to unit */ > #define PPPIOCDISCONN _IO('t', 57) /* disconnect channel */ > -- > 2.17.0.441.gb46fe60e1d-goog > > -- > To unsubscribe from this list: send the line "unsubscribe linux-ppp" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html