From patchwork Mon Apr 20 12:39:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 227435 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA155C3A5A0 for ; Mon, 20 Apr 2020 12:51:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AF214206D4 for ; Mon, 20 Apr 2020 12:51:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587387090; bh=qaL4iYj7C80HTLE18s9gZmgPRTetzxaDAONH7zHUwiM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Xy8FkkBE8b0+fO0+TNkwlO9mEOP21z9ZJOdxnhUgqHwjCpa5Dy86yRqG4vGEOOczG Y0M2aSG0d/mYoCNJUOcXVcpYhzaBIIEG0IIO7VGI3IHDpuwmbvDIC1NYRJ8Y49NorY T/FvX/2dzMSGU0j3b3JOa/swONfKYsOs/EWJlIQg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729468AbgDTMva (ORCPT ); Mon, 20 Apr 2020 08:51:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:44864 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729226AbgDTMsR (ORCPT ); Mon, 20 Apr 2020 08:48:17 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 666552078E; Mon, 20 Apr 2020 12:48:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587386896; bh=qaL4iYj7C80HTLE18s9gZmgPRTetzxaDAONH7zHUwiM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N5Tf/tYOA8DviEEEtu+RosTIN4hrGnCJx4DzZrOOMGyU4Undj5Oq18YgkNyGz4Xea gaQoUoKCz4JAA49fbrQds3QyLvSn13zDQC/bLswyEFER0bt8exbwEhn0gxHYaEvvB7 ZPa3hOhQ3oIYJAssASXDtmkGjVOeM+nPrtrCljfc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Taehee Yoo , "David S. Miller" Subject: [PATCH 4.19 02/40] hsr: check protocol version in hsr_newlink() Date: Mon, 20 Apr 2020 14:39:12 +0200 Message-Id: <20200420121449.830617851@linuxfoundation.org> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200420121444.178150063@linuxfoundation.org> References: <20200420121444.178150063@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Taehee Yoo [ Upstream commit 4faab8c446def7667adf1f722456c2f4c304069c ] In the current hsr code, only 0 and 1 protocol versions are valid. But current hsr code doesn't check the version, which is received by userspace. Test commands: ip link add dummy0 type dummy ip link add dummy1 type dummy ip link add hsr0 type hsr slave1 dummy0 slave2 dummy1 version 4 In the test commands, version 4 is invalid. So, the command should be failed. After this patch, following error will occur. "Error: hsr: Only versions 0..1 are supported." Fixes: ee1c27977284 ("net/hsr: Added support for HSR v1") Signed-off-by: Taehee Yoo Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/hsr/hsr_netlink.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) --- a/net/hsr/hsr_netlink.c +++ b/net/hsr/hsr_netlink.c @@ -64,10 +64,16 @@ static int hsr_newlink(struct net *src_n else multicast_spec = nla_get_u8(data[IFLA_HSR_MULTICAST_SPEC]); - if (!data[IFLA_HSR_VERSION]) + if (!data[IFLA_HSR_VERSION]) { hsr_version = 0; - else + } else { hsr_version = nla_get_u8(data[IFLA_HSR_VERSION]); + if (hsr_version > 1) { + NL_SET_ERR_MSG_MOD(extack, + "Only versions 0..1 are supported"); + return -EINVAL; + } + } return hsr_dev_finalize(dev, link, multicast_spec, hsr_version); }