From patchwork Thu Jan 10 11:31:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 210978 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id A76962C0326 for ; Thu, 10 Jan 2013 22:27:40 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753470Ab3AJL1U (ORCPT ); Thu, 10 Jan 2013 06:27:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40830 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753403Ab3AJL1T (ORCPT ); Thu, 10 Jan 2013 06:27:19 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r0ABRHAH019567 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 10 Jan 2013 06:27:17 -0500 Received: from redhat.com (vpn1-5-222.ams2.redhat.com [10.36.5.222]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id r0ABREem029648; Thu, 10 Jan 2013 06:27:15 -0500 Date: Thu, 10 Jan 2013 13:31:08 +0200 From: "Michael S. Tsirkin" To: Jason Wang Cc: Stefan Hajnoczi , "David S. Miller" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] tun: avoid owner checks on IFF_ATTACH_QUEUE Message-ID: <20130110113108.GF13451@redhat.com> MIME-Version: 1.0 Content-Disposition: inline X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org At the moment, we check owner when we enable queue in tun. This seems redundant and will break some valid uses where fd is passed around: I think TUNSETOWNER is there to prevent others from attaching to a persistent device not owned by them. Here the fd is already attached, enabling/disabling queue is more like read/write. Signed-off-by: Michael S. Tsirkin Reviewed-by: Stefan Hajnoczi --- Note: this is unrelated to Stefan's bugfix. diff --git a/drivers/net/tun.c b/drivers/net/tun.c index fbd106e..78e3225 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1789,10 +1792,8 @@ static int tun_set_queue(struct file *file, struct ifreq *ifr) tun = tfile->detached; if (!tun) ret = -EINVAL; - else if (tun_not_capable(tun)) - ret = -EPERM; else ret = tun_attach(tun, file); } else if (ifr->ifr_flags & IFF_DETACH_QUEUE) { tun = rcu_dereference_protected(tfile->tun, lockdep_rtnl_is_held());