From patchwork Mon May 28 11:58:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10432059 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7D5BA602CC for ; Mon, 28 May 2018 11:59:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C88628C6E for ; Mon, 28 May 2018 11:59:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 60684285A6; Mon, 28 May 2018 11:59:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, MAILING_LIST_MULTI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 62C92285A6 for ; Mon, 28 May 2018 11:59:07 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40vb482mFSzDrpY for ; Mon, 28 May 2018 21:59:04 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=mellanox.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=Mellanox.com header.i=@Mellanox.com header.b="r0yHmB0y"; dkim-atps=neutral X-Original-To: linux-mlxsw@lists.ozlabs.org Delivered-To: linux-mlxsw@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=mellanox.com (client-ip=40.107.3.88; helo=eur03-am5-obe.outbound.protection.outlook.com; envelope-from=petrm@mellanox.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=mellanox.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=Mellanox.com header.i=@Mellanox.com header.b="r0yHmB0y"; dkim-atps=neutral Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30088.outbound.protection.outlook.com [40.107.3.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40vb414LX9zDrWR for ; Mon, 28 May 2018 21:58:56 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dB5eThODiW/NY4Ks1q/PalxoQA3Rh0S3prag30rBZX0=; b=r0yHmB0y0UkDJ/r7A75AWvLH0jo0n3HO5DC6vTq8y+/fHUoU9FxPFIksv77UkeK8DyLtuMwlDUwChE9VQMdVlhHGCR6A7rHF41yLRZt3zBXjfnGVo06EJprlvjQhOqiE/w7oq9TQLMsUFpt9Mb15I1kBicIEpspD3MN55rz35kg= Received: from t540p (78.45.160.211) by AM0PR05MB4177.eurprd05.prod.outlook.com (2603:10a6:208:57::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.797.11; Mon, 28 May 2018 11:58:50 +0000 From: Petr Machata To: Subject: [PATCH net mlxsw v2] mlxsw: spectrum: Forbid creation of VLAN 1 over port/LAG Message-Id: Date: Mon, 28 May 2018 13:58:44 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 X-Originating-IP: [78.45.160.211] X-ClientProxiedBy: CWLP265CA0237.GBRP265.PROD.OUTLOOK.COM (2603:10a6:401:4f::33) To AM0PR05MB4177.eurprd05.prod.outlook.com (2603:10a6:208:57::26) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:AM0PR05MB4177; X-Microsoft-Exchange-Diagnostics: 1; AM0PR05MB4177; 3:EE1WiDY1T03QbMQvsan2tnAJW1ZzLjodgt4NIavYpsTYd0V5YBqcVbgBxtGhl9P8jNEXPAZlsfZeBz3PJ/Rc609k9iIHRUHVoVP5O5953xwsyodZgORy/ndJs7ES40A7JwqjbzKZDkkrYMdRSf2PKvBgDYNbRrZ/9sqDSREd715X6TpiJbcLZJO9KuagMtlIT93bFOnndwZoS4vScmbXAlJVR841J9HCXyx81SXXYmW9EQdatdGZBXvWj1rUOp30; 25:E14PAVlZfcfg0n3cEMzTnueIlcrr5CMCsxuCHj8lGMQ1W5Qt1PEcaraO5E5BF4aR/HS4222BAV+rXONdziYs0xhzjYzpWPruUg08JVnnEvxvehr4XnBBV96O6Ed6dOgvvmsh5uBmK8Z3wvh97CePH4iwST/9xvV9hKO1NVu4EuYJ8tBBfek6DMQKz3W7owMzveS6BZ2AxQJvv766SROFb+UXvOZ/04roWnCv+LqLOeE7o3576x6SbGZ4iE8z1atpB0wIIE0VjgdJ8GhMv/ELBIQxE5vXo87cSwcnmSjnouqFot6xN3m3BilYepDCiFaBF4lI7ICLyxfJCor5nQhQ0w==; 31:nnUI3BgcEu6UmCzuL3VbwVwrYn0E/eMbbmehp6+mnYYluxxYvem4WOYKyovcIuO43YyqEPGSxgN7svO7FsMEELJ2g/Upw1WvBBy+WI4ZofA7QxUKH6/WSYijYwx2pK6q+2+j5EexN5cePGrlBbL7tsTW0JhvUzgO5n579UUcRG1jcI6xNwu7e6V3gLRgYsGF2axdxBtqLy7MsDka3wYrMecpri+b9Ocm7LBdls3Iu0M= X-MS-TrafficTypeDiagnostic: AM0PR05MB4177: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; X-Microsoft-Exchange-Diagnostics: 1; AM0PR05MB4177; 20:5+1yCUhsZzGgBsdXo6KS3dbS/GFPFm6q8WMFmr6Xl4ERCtVW+eQoOYzOBaF6rMroySb4yGH1bJnMEoUmyuTJ/9ZIBcheIRkBhNWlXCLO/tEqPUGjAde5fohTvzQKyaN62ZH1OuZCT0FfrBQXdPL2gLvJei/YgE+o8ueFLUaqtjuc4KeIXlgxRC1+qyfEAOgBrJGxNy+29JFuRpRVq99xssZbBGLaDGduUGbHa2otxtMjWhQsEsom5ymAQ/xo/7o2myfrACJAs5gVdRfdw86eLB8fVIc8gKikTWhYJE8AJXUcZV00CI4he4ws6FIsb4MozkqTBFDH9kAAxJC/YNfKe5j7fSZlMr0s3Od5zMeMNpmkEvsF63Xc1Xrw948lRy6HKnWSWJOqCnk0VfHUU6CZX82UcQCqwYNvdOLtKH/5V78n89pr3qW5E90TQYJdQZCvGb1ivAb9FXV5/8m9VUyHuhx3hE/Hx0GSKfCJEO+C0P85DR4I0h28m89sSpNG6Y+1; 4:P65/4U48UL7EZbhbCY9C9/FjBsE3exWir0kdohXXTfXUOFfj/6LO0RArEBYNtPXONqP6gK45ZKuCHZxG8+qLVYOlcrowCXBxbtjvLy2Nb0yYHIL9FpqioexDq3GrxsG6h52BvR5OFNZTOiVlIz8L9ODTLc24QRYWDM1KGaJV6UOhMxMzthlBaRcmg2qhs6naI3Q6acSAYe0tB/k73GQXpLLsKSFJzn+9yYUS+r2ikX6DJZqff5vyzoanuDhbIxEiRWv/VurnPTAw6VUogkFZSA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(10201501046)(3231254)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123562045)(20161123560045)(6072148)(201708071742011)(7699016); SRVR:AM0PR05MB4177; BCL:0; PCL:0; RULEID:; SRVR:AM0PR05MB4177; X-Forefront-PRVS: 06860EDC7B X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(396003)(376002)(39860400002)(346002)(39380400002)(199004)(189003)(66066001)(6636002)(6666003)(97736004)(2351001)(105586002)(51416003)(36756003)(50466002)(3846002)(6116002)(8936002)(37006003)(478600001)(106356001)(58126008)(7736002)(26005)(5660300001)(16526019)(186003)(305945005)(52116002)(118296001)(8676002)(25786009)(16586007)(81156014)(81166006)(6486002)(486006)(956004)(2616005)(476003)(68736007)(316002)(48376002)(6496006)(86362001)(53936002)(2906002)(6862004)(59450400001)(47776003)(386003); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR05MB4177; H:t540p; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM0PR05MB4177; 23:wTHw9JuCpj8SrXg/b+ad/sjlrF5G1U6UVn7ZFew/4?= =?us-ascii?Q?qFrESNjE4n6jXdzhkSP5oOf0J0ET22Aoz1vUx+3ml24cX6oWhhORBFi5LI/j?= =?us-ascii?Q?g34FrIyjn0MqAE6BYqCiZdz39KuS5q2rwGFxMdDAA0boAF6HiwCSmprej8rh?= =?us-ascii?Q?aMLp4kue3M7sastwUJlUM/M74oycETjEyANwh85ByPnk0BhwbUHtpOMv/TWc?= =?us-ascii?Q?1g3DTn/29ANerowEQ+MKHPDC2KhnzDAzPUnW94uqCvZSjnx5E4d1GWuOapnE?= =?us-ascii?Q?SaG6DppNcmTuRaw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1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM0PR05MB4177; 7:N1x5KAcV68cjH6Mm85Z4FtbrndlLUHytCbq/LYkD5DLjtyVnqiGYOqqpNNKu8byK72vCVildcH7Dvg/LlT3R7BPhMm5IDLUysJ59H2lK69irta1D152n2wHOHwruJfCKHOOaGmJgb238MLpdeCCfFUj1GP7dIHYWUFGRYkLEQT1lk5OlRkkIhWCvPBTg2n7s4ODlihWsxDFZE58jk0RXquC6BFc0r7uO10J72Q4MQzfavkSVhpqiMTk3+5dfCIJB X-MS-Office365-Filtering-Correlation-Id: b8109762-0b06-49ae-a783-08d5c49260b4 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 May 2018 11:58:50.5771 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b8109762-0b06-49ae-a783-08d5c49260b4 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB4177 X-BeenThere: linux-mlxsw@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: mlxsw driver development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-mlxsw-bounces+patchwork-linux-mlxsw=patchwork.kernel.org@lists.ozlabs.org X-Virus-Scanned: ClamAV using ClamSMTP VLAN 1 is internally used for untagged traffic. Prevent creation of explicit netdevice for that VLAN, because that currently isn't supported and leads to the NULL pointer dereference cited below. Fix by preventing creation of VLAN devices with VID of 1 over mlxsw devices or LAG devices that involve mlxsw devices. [ 327.175816] ================================================================================ [ 327.184544] UBSAN: Undefined behaviour in drivers/net/ethernet/mellanox/mlxsw/spectrum_fid.c:200:12 [ 327.193667] member access within null pointer of type 'const struct mlxsw_sp_fid' [ 327.201226] CPU: 0 PID: 8983 Comm: ip Not tainted 4.17.0-rc4-petrm_net_ip6gre_headroom-custom-140 #11 [ 327.210496] Hardware name: Mellanox Technologies Ltd. "MSN2410-CB2F"/"SA000874", BIOS 4.6.5 03/08/2016 [ 327.219872] Call Trace: [ 327.222384] dump_stack+0xc3/0x12b [ 327.234007] ubsan_epilogue+0x9/0x49 [ 327.237638] ubsan_type_mismatch_common+0x1f9/0x2d0 [ 327.255769] __ubsan_handle_type_mismatch+0x90/0xa7 [ 327.264716] mlxsw_sp_fid_type+0x35/0x50 [mlxsw_spectrum] [ 327.270255] mlxsw_sp_port_vlan_router_leave+0x46/0xc0 [mlxsw_spectrum] [ 327.277019] mlxsw_sp_inetaddr_port_vlan_event+0xe1/0x340 [mlxsw_spectrum] [ 327.315031] mlxsw_sp_netdevice_vrf_event+0xa8/0x100 [mlxsw_spectrum] [ 327.321626] mlxsw_sp_netdevice_event+0x276/0x430 [mlxsw_spectrum] [ 327.367863] notifier_call_chain+0x4c/0x150 [ 327.372128] __netdev_upper_dev_link+0x1b3/0x260 [ 327.399450] vrf_add_slave+0xce/0x170 [vrf] [ 327.403703] do_setlink+0x658/0x1d70 [ 327.508998] rtnl_newlink+0x908/0xf20 [ 327.559128] rtnetlink_rcv_msg+0x50c/0x720 [ 327.571720] netlink_rcv_skb+0x16a/0x1f0 [ 327.583450] netlink_unicast+0x2ca/0x3e0 [ 327.599305] netlink_sendmsg+0x3e2/0x7f0 [ 327.616655] sock_sendmsg+0x76/0xc0 [ 327.620207] ___sys_sendmsg+0x494/0x5d0 [ 327.666117] __sys_sendmsg+0xc2/0x130 [ 327.690953] do_syscall_64+0x66/0x370 [ 327.694677] entry_SYSCALL_64_after_hwframe+0x49/0xbe [ 327.699782] RIP: 0033:0x7f4c2f3f8037 [ 327.703393] RSP: 002b:00007ffe8c389708 EFLAGS: 00000246 ORIG_RAX: 000000000000002e [ 327.711035] RAX: ffffffffffffffda RBX: 000000005b03f53e RCX: 00007f4c2f3f8037 [ 327.718229] RDX: 0000000000000000 RSI: 00007ffe8c389760 RDI: 0000000000000003 [ 327.725431] RBP: 00007ffe8c389760 R08: 0000000000000000 R09: 00007f4c2f443630 [ 327.732632] R10: 00000000000005eb R11: 0000000000000246 R12: 0000000000000000 [ 327.739833] R13: 00000000006774e0 R14: 00007ffe8c3897e8 R15: 0000000000000000 [ 327.747096] ================================================================================ Fixes: 9589a7b5d7d9 ("mlxsw: spectrum: Handle VLAN devices linking / unlinking") Suggested-by: Ido Schimmel Signed-off-by: Petr Machata --- Notes: Changes from v1 to v2: - Change the rejection error code from -EINVAL to -EOPNOTSUPP. drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c index ca38a30..dbb729a 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -4433,6 +4433,11 @@ static int mlxsw_sp_netdevice_port_upper_event(struct net_device *lower_dev, NL_SET_ERR_MSG_MOD(extack, "Can not put a VLAN on an OVS port"); return -EINVAL; } + if (is_vlan_dev(upper_dev) && + vlan_dev_vlan_id(upper_dev) == 1) { + NL_SET_ERR_MSG_MOD(extack, "Creating a VLAN device with VID 1 is unsupported: VLAN 1 carries untagged traffic"); + return -EOPNOTSUPP; + } break; case NETDEV_CHANGEUPPER: upper_dev = info->upper_dev;