From patchwork Mon Aug 5 15:25:54 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: 264704 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 D2ECD2C0084 for ; Tue, 6 Aug 2013 01:25:07 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753451Ab3HEPYu (ORCPT ); Mon, 5 Aug 2013 11:24:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51327 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752312Ab3HEPYt (ORCPT ); Mon, 5 Aug 2013 11:24:49 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r75FOHWK023664 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 5 Aug 2013 11:24:17 -0400 Received: from redhat.com (vpn1-4-33.ams2.redhat.com [10.36.4.33]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id r75FOE2i008570; Mon, 5 Aug 2013 11:24:15 -0400 Date: Mon, 5 Aug 2013 18:25:54 +0300 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org Cc: "David S. Miller" , John Fastabend , Patrick McHardy , netdev@vger.kernel.org Subject: [PATCH v3] macvlan: validate flags Message-ID: <20130805152554.GA3592@redhat.com> MIME-Version: 1.0 Content-Disposition: inline X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org commit df8ef8f3aaa6692970a436204c4429210addb23a macvlan: add FDB bridge ops and macvlan flags added a flags field to macvlan, which can be controlled from userspace. The idea is to make the interface future-proof so we can add flags and not new fields. However, flags value isn't validated, as a result, userspace can't detect which flags are supported. Cc: "David S. Miller" Cc: John Fastabend Signed-off-by: Michael S. Tsirkin --- Changes from v2: drop chunk in macvlan_common_newlink - not necessary since macvlan_validate is always called first Changes from v1: tweaked commit message no code changes Please consider this patch for -stable. The idea is by the time we add more flags, everyone has updated to a kernel that detects errors, so userspace will be able to detect supported flags cleanly. drivers/net/macvlan.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index 18373b6..8445a94 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -736,6 +736,10 @@ static int macvlan_validate(struct nlattr *tb[], struct nlattr *data[]) return -EADDRNOTAVAIL; } + if (data && data[IFLA_MACVLAN_FLAGS] && + nla_get_u16(data[IFLA_MACVLAN_FLAGS]) & ~MACVLAN_FLAG_NOPROMISC) + return -EINVAL; + if (data && data[IFLA_MACVLAN_MODE]) { switch (nla_get_u32(data[IFLA_MACVLAN_MODE])) { case MACVLAN_MODE_PRIVATE: