From: Jason Wang <jasowang@redhat.com>
To: Kirill Tkhai <ktkhai@virtuozzo.com>,
davem@davemloft.net, edumazet@google.com, mst@redhat.com,
brouer@redhat.com, peterpenkov96@gmail.com, sd@queasysnail.net,
netdev@vger.kernel.org
Subject: Re: [PATCH net-next] tun: Do SIOCGSKNS out of rtnl_lock()
Date: Wed, 9 May 2018 15:18:14 +0800 [thread overview]
Message-ID: <06a89506-2d3c-a0dd-3ac2-2c517683517e@redhat.com> (raw)
In-Reply-To: <152579647246.21100.10461408116587658568.stgit@localhost.localdomain>
On 2018年05月09日 00:21, Kirill Tkhai wrote:
> Since net ns of tun device is assigned on the device creation,
> and it never changes, we do not need to use any lock to get it
> from alive tun.
>
> Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
> ---
> drivers/net/tun.c | 18 +++++++-----------
> 1 file changed, 7 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index d3c04ab9752a..44d4f3d25350 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -2850,10 +2850,10 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
> unsigned long arg, int ifreq_len)
> {
> struct tun_file *tfile = file->private_data;
> + struct net *net = sock_net(&tfile->sk);
> struct tun_struct *tun;
> void __user* argp = (void __user*)arg;
> struct ifreq ifr;
> - struct net *net;
> kuid_t owner;
> kgid_t group;
> int sndbuf;
> @@ -2877,14 +2877,18 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
> */
> return put_user(IFF_TUN | IFF_TAP | TUN_FEATURES,
> (unsigned int __user*)argp);
> - } else if (cmd == TUNSETQUEUE)
> + } else if (cmd == TUNSETQUEUE) {
> return tun_set_queue(file, &ifr);
> + } else if (cmd == SIOCGSKNS) {
Not for this patch, reusing socket ioctl cmd is probably not good though
they were probably not intersected (see ioctl-number.txt). We probably
need to introduce TUN specific ioctls for SIOCGSKNS and SIOCGIFHWADDR
and warn for socket ones.
Thanks
> + if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
> + return -EPERM;
> + return open_related_ns(&net->ns, get_net_ns);
> + }
>
> ret = 0;
> rtnl_lock();
>
> tun = tun_get(tfile);
> - net = sock_net(&tfile->sk);
> if (cmd == TUNSETIFF) {
> ret = -EEXIST;
> if (tun)
> @@ -2914,14 +2918,6 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
> tfile->ifindex = ifindex;
> goto unlock;
> }
> - if (cmd == SIOCGSKNS) {
> - ret = -EPERM;
> - if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
> - goto unlock;
> -
> - ret = open_related_ns(&net->ns, get_net_ns);
> - goto unlock;
> - }
>
> ret = -EBADFD;
> if (!tun)
>
next prev parent reply other threads:[~2018-05-09 7:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-08 16:21 [PATCH net-next] tun: Do SIOCGSKNS out of rtnl_lock() Kirill Tkhai
2018-05-09 7:18 ` Jason Wang [this message]
2018-05-09 9:00 ` Kirill Tkhai
2018-05-09 13:19 ` Jason Wang
2018-05-10 19:17 ` David Miller
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=06a89506-2d3c-a0dd-3ac2-2c517683517e@redhat.com \
--to=jasowang@redhat.com \
--cc=brouer@redhat.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=ktkhai@virtuozzo.com \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=peterpenkov96@gmail.com \
--cc=sd@queasysnail.net \
/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).