netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Jason Wang <jasowang@redhat.com>
Cc: "Maciej Żenczykowski" <maze@google.com>,
	"Patrick Rohr" <prohr@google.com>,
	"David S . Miller" <davem@davemloft.net>,
	"Linux Network Development Mailing List" <netdev@vger.kernel.org>,
	"Lorenzo Colitti" <lorenzo@google.com>
Subject: Re: [PATCH] tun: support not enabling carrier in TUNSETIFF
Date: Tue, 20 Sep 2022 08:36:21 -0700	[thread overview]
Message-ID: <20220920083621.18219c3d@hermes.local> (raw)
In-Reply-To: <CACGkMEu6zBeduw9F==NWhz01FphYjkhT0Qmp+06vq6=kCx+bvA@mail.gmail.com>

On Tue, 20 Sep 2022 09:44:45 +0800
Jason Wang <jasowang@redhat.com> wrote:

> On Tue, Sep 20, 2022 at 8:01 AM Maciej Żenczykowski <maze@google.com> wrote:
> >
> > On Mon, Sep 19, 2022 at 10:18 AM Stephen Hemminger
> > <stephen@networkplumber.org> wrote:  
> > > On Fri, 16 Sep 2022 16:45:52 -0700
> > > Patrick Rohr <prohr@google.com> wrote:  
> > > >  #define IFF_DETACH_QUEUE 0x0400
> > > > +/* Used in TUNSETIFF to bring up tun/tap without carrier */
> > > > +#define IFF_NO_CARRIER IFF_DETACH_QUEUE  
> > >
> > > Overloading a flag in existing user API is likely to break
> > > some application somewhere...  
> >
> > We could of course burn a bit (0x0040 and 0x0080 are both currently
> > utterly unused)... but that just seemed wasteful...
> > Do you think that would be better?
> >
> > I find it exceedingly unlikely that any application is specifying this
> > flag to TUNSETIFF currently.
> >
> > This flag has barely any hits in the code base, indeed ignoring the
> > Documentation, tests, and #define's we have:
> >
> > $ git grep IFF_DETACH_QUEUE
> > drivers/net/tap.c:928:  else if (flags & IFF_DETACH_QUEUE)
> > drivers/net/tun.c:2954: } else if (ifr->ifr_flags & IFF_DETACH_QUEUE) {
> > drivers/net/tun.c:3115:                 ifr.ifr_flags |= IFF_DETACH_QUEUE;
> >
> > The first two implement ioctl(TUNSETQUEUE) -- that's the only spot
> > where IFF_DETACH_QUEUE is currently supposed to be used.
> >
> > The third one is the most interesting, see drivers/net/tun.c:3111
> >
> >  case TUNGETIFF:
> >          tun_get_iff(tun, &ifr);
> >          if (tfile->detached)
> >                  ifr.ifr_flags |= IFF_DETACH_QUEUE;
> >          if (!tfile->socket.sk->sk_filter)
> >                  ifr.ifr_flags |= IFF_NOFILTER;
> >
> > This means TUNGETIFF can return this flag for a detached queue.  However:
> >
> > (a) multiqueue tun/tap is pretty niche, and detached queues are even more niche.
> >
> > (b) the TUNGETIFF returned ifr_flags field already cannot be safely
> > used as input to TUNSETIFF,  
> 
> Yes, but it could be used by userspace to recover the multiqueue state
> via TUNSETQUEUE for a feature like checkpoint.
> 
> > because IFF_NOFILTER == IFF_NO_PI ==
> > 0x1000
> >
> > (this overlap of IFF_NO_PI and IFF_NOFILTER is why we thought it'd be
> > ok to overlap here as well)
> >
> > (c) if this actually turns out to be a problem it shouldn't be that
> > hard to fix the 1 or 2 userspace programs to mask out the flag
> > and not pass in garbage... Do we really want / need to maintain
> > compatibility with extremely badly written userspace?  
> 
> Not sure, but instead of trying to answer this hard question, having a
> new flag seems to be easier.
> 
> > It's really hard to even imagine how such code would come into existence...
> >
> > Arguably the TUNSETIFF api should have always returned an error for
> > invalid flags... should we make that change now?  
> 
> Probably too late to do that.

There have been several other cases where Linus has said
ABI compatability includes not breaking buggy userspace applications.
Look at the history around new syscalls that add a flag argument
and forget to check that it is zero in the first version.

  reply	other threads:[~2022-09-20 15:36 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-16 23:45 [PATCH] tun: support not enabling carrier in TUNSETIFF Patrick Rohr
2022-09-16 23:54 ` Maciej Żenczykowski
2022-09-19  6:52 ` Jason Wang
2022-09-19 17:18 ` Stephen Hemminger
2022-09-20  0:01   ` Maciej Żenczykowski
2022-09-20  1:44     ` Jason Wang
2022-09-20 15:36       ` Stephen Hemminger [this message]
2022-09-20 19:48         ` [PATCH v2] " Patrick Rohr
2022-09-20 21:47           ` Maciej Żenczykowski
2022-09-21  2:53           ` Jason Wang
2022-09-21  6:35           ` Nicolas Dichtel
2022-09-23 11:10           ` patchwork-bot+netdevbpf
2022-09-20  7:35 ` [PATCH] " Nicolas Dichtel
2022-09-21  7:08 ` [tun] a4d8f18ebc: ltp.ioctl03.fail kernel test robot
2022-09-21  7:48   ` [LTP] " Cyril Hrubis

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=20220920083621.18219c3d@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=davem@davemloft.net \
    --cc=jasowang@redhat.com \
    --cc=lorenzo@google.com \
    --cc=maze@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=prohr@google.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).