Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1615432pxb; Mon, 11 Oct 2021 09:32:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnDiI43FtAQWHU78TY9jOMv2bHiPkny83qzdZlpeR6nF5Hk7tHP+T9r+LgqP1K3ciSvaUq X-Received: by 2002:a50:e1cf:: with SMTP id m15mr42033162edl.181.1633969936722; Mon, 11 Oct 2021 09:32:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633969936; cv=none; d=google.com; s=arc-20160816; b=cVlMo2tiWol5usMbldyFYXOnXXZsKVFqTlaUhoZa30lZJ9Azxe7WFb7UuCIJqkohYW oJSVeLurSi72MDbX8kL458DwrdKzPM+SSASjiDJsQb9D5bcmnxVnqzWLu/hRzYBydWMY EwgcJr95pzgrAirhLWEEaSO6flPDlSkza0dXN03gQiQeKJiLnPdHS2qpEHhCdfh0C9TD Wz94Fvg5UbsnG4E21t+ZqN+dmk7q5KWEyTm/e1vPxqs8Wu0Wl++hoV/bCi4YmKQhjO7o 6hh3Ib5TuUj3/qACXmy85iu8H6O6qGZwaq0MVv9FHVX64yT+rzKCIn4ENeo5xTM9UeAq 3Hnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=O8AbLwwleH3fMYSV1DkmDQHFwXPQLSl8RDom5LvCdQw=; b=VjaKZnTjrAWiiGxp5ppE8TK5z9daM2uM7cuI/uW//oTRRAQxBh25h8KKP8Zj2W8yHO eLhq0mDILkp/p3JMhhE8rI7S6RJzxdCftiaOuUPBHT772sbrKHOnS2pmSSrLKirl8pDj oLWGmY5QRbUTwOaNqazbeeWwoIhzOQlcxUQpeTywTGSlZMy0FlkGFpmltnnj5BIIYAyS O5TfQO0j2ZdcFRbUxxIQj0LItYhf+uq4A41aKn3s2BPdzIW3GK3gNcV+1R3TbOC6Z5m5 P9Cgl9GaQXfW22MBUraYdCc8KZlQYFCbkcgMQfiwMcX7iY7PzorR2Vv9paK5vev28wtJ oOVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JgTeoBs1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y21si11532343eje.171.2021.10.11.09.31.52; Mon, 11 Oct 2021 09:32:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JgTeoBs1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236839AbhJKN7S (ORCPT + 99 others); Mon, 11 Oct 2021 09:59:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:41094 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237598AbhJKN5O (ORCPT ); Mon, 11 Oct 2021 09:57:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A61E260EB4; Mon, 11 Oct 2021 13:54:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633960443; bh=Qbe/ZKLQz/HG6cTuiQFpEiTqDCdF7dTxczwQvORkYQQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JgTeoBs1Zw7H36kSeM7Q3W4TKhHXy6ptLvoQoCoZ40Y6/+j69VZCJYsPKN2WX8ZI2 vrLHJ+e4eSZkrOEbqm9qyvDDH9oiCvoO7p2YJKoqBirAWwHjTiorqgg24ySPQGTdth vmDwg7F3jC73+lYPLig+WoHu1aEWgllD65y9FFZA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Roopa Prabhu , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 61/83] rtnetlink: fix if_nlmsg_stats_size() under estimation Date: Mon, 11 Oct 2021 15:46:21 +0200 Message-Id: <20211011134510.496602284@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211011134508.362906295@linuxfoundation.org> References: <20211011134508.362906295@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Dumazet [ Upstream commit d34367991933d28bd7331f67a759be9a8c474014 ] rtnl_fill_statsinfo() is filling skb with one mandatory if_stats_msg structure. nlmsg_put(skb, pid, seq, type, sizeof(struct if_stats_msg), flags); But if_nlmsg_stats_size() never considered the needed storage. This bug did not show up because alloc_skb(X) allocates skb with extra tailroom, because of added alignments. This could very well be changed in the future to have deterministic behavior. Fixes: 10c9ead9f3c6 ("rtnetlink: add new RTM_GETSTATS message to dump link stats") Signed-off-by: Eric Dumazet Cc: Roopa Prabhu Acked-by: Roopa Prabhu Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/core/rtnetlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 7266571d5c7e..27ffa83ffeb3 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -5257,7 +5257,7 @@ nla_put_failure: static size_t if_nlmsg_stats_size(const struct net_device *dev, u32 filter_mask) { - size_t size = 0; + size_t size = NLMSG_ALIGN(sizeof(struct if_stats_msg)); if (stats_attr_valid(filter_mask, IFLA_STATS_LINK_64, 0)) size += nla_total_size_64bit(sizeof(struct rtnl_link_stats64)); -- 2.33.0