Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2096395ybl; Thu, 30 Jan 2020 11:17:29 -0800 (PST) X-Google-Smtp-Source: APXvYqxVTxvEJiAEjK/bUUPJJNnknw2u4M5vu2LVtBoKkQwr5hLhIaHtAxJ3mgBfwzTjPVrgIQJD X-Received: by 2002:aca:5295:: with SMTP id g143mr3839061oib.25.1580411849055; Thu, 30 Jan 2020 11:17:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580411849; cv=none; d=google.com; s=arc-20160816; b=tifgmauyidP+YvfeRtqj5Y0OBTzmyBMKlMtY6mUSEHJBVXbhju2p3GPMEEx9PBd1ui Y2C+RBNc6ppadfIEfqxCTnHAnhAlr/2kkSIgG1mSSYD+sfMNkXvMy1Xnc8DBbCDuNVqr YHona5UxRzLPGmdt6E5XX0Jb2VhTWtsEE/U63ePZgpW+qSl1lQn1RCxAsMrYrPtS59sR gYX+O0s9pTyt7GMxd2OpjoviEafibXK0ldbpvMEHUE79RWlkPIoxSEzdi2GFv4FZsDqT c5h7VLoglvl1dfmSszuDJCfOr9qgOSs1vOkLoCqBjKMHrIZLwMNNV0D48x/MIQ2IGscx Skqw== 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=ShhR9cqaTXjELwmQ2mpk0lYW6I6u3on97rTuC5IDo0o=; b=oVOqkvR0Q7+v8m6bOu+o2NosTvgruRXS+ny9f/mUXx4lxd/6hERE/f2iCIq5RaCJGD swIqeqduCjjvswY1DjhO876x3/vBT7vbpNCbYWGYGIH5TwXbK6Q0vsZXTuARVeEvrrYm dOP/ZimReCq46cg9EXJbOm2vnH1FOR0Bv6opLu2b8F7XJF6j1NqgqejVQUkv7es2AtzE GvXizRHdl/vjdpTKLBrF0xZrbgRblBjwebfrIPi5q1QscnyT/jloOsuEiB+rFWhwMfZ8 G1fv1UiABIebgf1VU0J0rTIiFnAAVsOcG8/v6kQ8jX2D+7e0TpVQ+8xWjih1vXt/Pf7/ 3e/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=eFo8evll; 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 t1si3519426otq.148.2020.01.30.11.17.17; Thu, 30 Jan 2020 11:17:29 -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=eFo8evll; 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 S1730651AbgA3Sni (ORCPT + 99 others); Thu, 30 Jan 2020 13:43:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:52326 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728062AbgA3Snf (ORCPT ); Thu, 30 Jan 2020 13:43:35 -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 19EFD20CC7; Thu, 30 Jan 2020 18:43:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580409814; bh=W24dS0pfWAmHHYBQWMMyxi9u/NC671FoXCiRWllbgOg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eFo8evlljVrWW4nTnM74r6NlBO1zQtWGReRhQD3npvAPoPL3m0vUa+R/fYz6gcp5p i/CEvY5GJ8iFHQMtFmfcviK9OG6pmrk7yaKLuGX+/oqFvkJ8T0eealZWRuUejCk2oJ tygpSMxPGC+zVEkUgjYrfaWQBXjPY79xf/UdlcsQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stephen Worley , David Ahern , "David S. Miller" Subject: [PATCH 5.4 042/110] net: include struct nhmsg size in nh nlmsg size Date: Thu, 30 Jan 2020 19:38:18 +0100 Message-Id: <20200130183620.308307146@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200130183613.810054545@linuxfoundation.org> References: <20200130183613.810054545@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: Stephen Worley [ Upstream commit f9e95555757915fc194288862d2978e370fe316b ] Include the size of struct nhmsg size when calculating how much of a payload to allocate in a new netlink nexthop notification message. Without this, we will fail to fill the skbuff at certain nexthop group sizes. You can reproduce the failure with the following iproute2 commands: ip link add dummy1 type dummy ip link add dummy2 type dummy ip link add dummy3 type dummy ip link add dummy4 type dummy ip link add dummy5 type dummy ip link add dummy6 type dummy ip link add dummy7 type dummy ip link add dummy8 type dummy ip link add dummy9 type dummy ip link add dummy10 type dummy ip link add dummy11 type dummy ip link add dummy12 type dummy ip link add dummy13 type dummy ip link add dummy14 type dummy ip link add dummy15 type dummy ip link add dummy16 type dummy ip link add dummy17 type dummy ip link add dummy18 type dummy ip link add dummy19 type dummy ip ro add 1.1.1.1/32 dev dummy1 ip ro add 1.1.1.2/32 dev dummy2 ip ro add 1.1.1.3/32 dev dummy3 ip ro add 1.1.1.4/32 dev dummy4 ip ro add 1.1.1.5/32 dev dummy5 ip ro add 1.1.1.6/32 dev dummy6 ip ro add 1.1.1.7/32 dev dummy7 ip ro add 1.1.1.8/32 dev dummy8 ip ro add 1.1.1.9/32 dev dummy9 ip ro add 1.1.1.10/32 dev dummy10 ip ro add 1.1.1.11/32 dev dummy11 ip ro add 1.1.1.12/32 dev dummy12 ip ro add 1.1.1.13/32 dev dummy13 ip ro add 1.1.1.14/32 dev dummy14 ip ro add 1.1.1.15/32 dev dummy15 ip ro add 1.1.1.16/32 dev dummy16 ip ro add 1.1.1.17/32 dev dummy17 ip ro add 1.1.1.18/32 dev dummy18 ip ro add 1.1.1.19/32 dev dummy19 ip next add id 1 via 1.1.1.1 dev dummy1 ip next add id 2 via 1.1.1.2 dev dummy2 ip next add id 3 via 1.1.1.3 dev dummy3 ip next add id 4 via 1.1.1.4 dev dummy4 ip next add id 5 via 1.1.1.5 dev dummy5 ip next add id 6 via 1.1.1.6 dev dummy6 ip next add id 7 via 1.1.1.7 dev dummy7 ip next add id 8 via 1.1.1.8 dev dummy8 ip next add id 9 via 1.1.1.9 dev dummy9 ip next add id 10 via 1.1.1.10 dev dummy10 ip next add id 11 via 1.1.1.11 dev dummy11 ip next add id 12 via 1.1.1.12 dev dummy12 ip next add id 13 via 1.1.1.13 dev dummy13 ip next add id 14 via 1.1.1.14 dev dummy14 ip next add id 15 via 1.1.1.15 dev dummy15 ip next add id 16 via 1.1.1.16 dev dummy16 ip next add id 17 via 1.1.1.17 dev dummy17 ip next add id 18 via 1.1.1.18 dev dummy18 ip next add id 19 via 1.1.1.19 dev dummy19 ip next add id 1111 group 1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/17/18/19 ip next del id 1111 Fixes: 430a049190de ("nexthop: Add support for nexthop groups") Signed-off-by: Stephen Worley Reviewed-by: David Ahern Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/nexthop.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/net/ipv4/nexthop.c +++ b/net/ipv4/nexthop.c @@ -322,7 +322,9 @@ static size_t nh_nlmsg_size_single(struc static size_t nh_nlmsg_size(struct nexthop *nh) { - size_t sz = nla_total_size(4); /* NHA_ID */ + size_t sz = NLMSG_ALIGN(sizeof(struct nhmsg)); + + sz += nla_total_size(4); /* NHA_ID */ if (nh->is_group) sz += nh_nlmsg_size_grp(nh);