Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp17934450ybl; Thu, 2 Jan 2020 15:06:40 -0800 (PST) X-Google-Smtp-Source: APXvYqyrpo7zLeWB1KnQ5MYfbwl9d0+wWUywT/ctDE0SFY4LpT6JDtb4Iokr1ewHsfqO2KBn5d+c X-Received: by 2002:a05:6830:10c6:: with SMTP id z6mr100247299oto.203.1578006400442; Thu, 02 Jan 2020 15:06:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578006400; cv=none; d=google.com; s=arc-20160816; b=HrsIj/pLbkJyhaPCst9KXS8EipY/4h0j2AZygejoni8Yl3g/zJ9NptzxUSNFAsbUXs 1zkrizqgzBicIs8JbLtnpN6T0RCeFiffqXoL7LI6umrbxul48GSbysDF97koiYN4sdOm CkOjUEwca5iX1XtqXGVVtuadsz5VL6tMRz2zaPEO2WfRaEgH7gBQHxj0e32xkueUXM7a bsy4PGSQS2/Eb8yxPA6CQwxDkYgQIk2HLYZXbs2zqAyibaoMF6J0tqMhAeuRD8tlvYEl d+GNi5SB7Ym2qnytYyIYZzenW0KFmPX1BdJX8gRajQ71MsXMUOrgj/EU3TTLBNqLUmxq NjGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=EvWMSfi9hvHPTwEDbQguerek5jkHB4459j75O2ZAYpM=; b=ktxlG3pxfr6z5Ep2lUtv+zgUJRvORuYv38fuPo+cm6dTeJKtki/gvPirzLA+/5LcZh 7e0HWgbIhJ9XrPfPLEzsjm8TRu8SuAl4eUZIejUDLarQU2ghG/1i/o4v9Y6uzemuQG1D CTFOiLlTYqFJkoC+0I65octILTF26fn9OSov5jc4SdOxKYQW/saWgPUSTyTd0GLLA+EM yPZanfAm5AjfMIb+LcziWlbMEqnFvrzYqrlyJ16gNaAwSZQxTsQQr/NdyegDtOXUB2EU kfn+soEcO52s2V+HRacnj1Jf52DBzJlUttJABNAiPn2NHpVa78izSOKDPv4hALZXp/LU uzSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PymgbRLd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b25si27560911otp.212.2020.01.02.15.06.28; Thu, 02 Jan 2020 15:06:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PymgbRLd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728441AbgABWS0 (ORCPT + 99 others); Thu, 2 Jan 2020 17:18:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:33416 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728295AbgABWSS (ORCPT ); Thu, 2 Jan 2020 17:18:18 -0500 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 60E3221582; Thu, 2 Jan 2020 22:18:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578003497; bh=GbbVOGT3ssLiWOJrq9q3+/pq8O/Q6xx45RyYpvxGwGQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PymgbRLdSLJvobd3cjZAVd9HX+Pyxwnn3r31+QiT5zETNEXDzJTa2vLx/fNwGWPk2 hoJjYHP0OeJPehkSCaeBb4tAlWVVY8fzeGCkkSvAh+9migX7rpd14e5/5+CfCNuI96 LloP5CKXBbmLVFC3aGdTa0vu/QFdF4Tn7jxB3G3A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jianlin Shi , Hangbin Liu , David Ahern , Jakub Kicinski Subject: [PATCH 5.4 186/191] ipv6/addrconf: only check invalid header values when NETLINK_F_STRICT_CHK is set Date: Thu, 2 Jan 2020 23:07:48 +0100 Message-Id: <20200102215849.500783837@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102215829.911231638@linuxfoundation.org> References: <20200102215829.911231638@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hangbin Liu [ Upstream commit 2beb6d2901a3f73106485d560c49981144aeacb1 ] In commit 4b1373de73a3 ("net: ipv6: addr: perform strict checks also for doit handlers") we add strict check for inet6_rtm_getaddr(). But we did the invalid header values check before checking if NETLINK_F_STRICT_CHK is set. This may break backwards compatibility if user already set the ifm->ifa_prefixlen, ifm->ifa_flags, ifm->ifa_scope in their netlink code. I didn't move the nlmsg_len check because I thought it's a valid check. Reported-by: Jianlin Shi Fixes: 4b1373de73a3 ("net: ipv6: addr: perform strict checks also for doit handlers") Signed-off-by: Hangbin Liu Reviewed-by: David Ahern Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/ipv6/addrconf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -5231,16 +5231,16 @@ static int inet6_rtm_valid_getaddr_req(s return -EINVAL; } + if (!netlink_strict_get_check(skb)) + return nlmsg_parse_deprecated(nlh, sizeof(*ifm), tb, IFA_MAX, + ifa_ipv6_policy, extack); + ifm = nlmsg_data(nlh); if (ifm->ifa_prefixlen || ifm->ifa_flags || ifm->ifa_scope) { NL_SET_ERR_MSG_MOD(extack, "Invalid values in header for get address request"); return -EINVAL; } - if (!netlink_strict_get_check(skb)) - return nlmsg_parse_deprecated(nlh, sizeof(*ifm), tb, IFA_MAX, - ifa_ipv6_policy, extack); - err = nlmsg_parse_deprecated_strict(nlh, sizeof(*ifm), tb, IFA_MAX, ifa_ipv6_policy, extack); if (err)