Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1974285pxb; Fri, 5 Mar 2021 04:32:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJxNFQXvOHyaOr6q9X9qe8zw0J1OktZVwKuXRKsRbLQBs26dS5jYezJidtymlfHfJqnid+Kb X-Received: by 2002:a17:906:600f:: with SMTP id o15mr2081026ejj.76.1614947537247; Fri, 05 Mar 2021 04:32:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614947537; cv=none; d=google.com; s=arc-20160816; b=M58gjFN7Lm1nlaOgoPJLMHOOLpUREi0jEkxk5nzQ68ynRjICZxMECR+Chk2hGQU3MS 3PRJRTJmC/AUO66fjqUlc/Ub3d694HIQwtRUChK/kMAbRYbSpa9SqbdJ6fHQ7gDljDms T9TiUqVqKDN4ENGBleGYunpi2zSlT2NMJ6ony6Z2Jh67AhAUx40JQJOuR+ABaRsdo6d5 aV76p78r+1cKQD5G8OTe74orlwx0quaT3qacc/coXZtxbsQow6pFeIAsQPUeGDIgrbhz gOU5gXSshKd6jRR9wH+SUBvsi+nFccTua+xO2ljqr2+VfYu3roXiHVXi8E3w0zFYSjU1 mjcw== 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=kz6RpoYouCFSu1CDRhqAnyuOl+bgSpuxGFrbudmX/Us=; b=tEYrfygH8LU6/O1MzO8rAKOrdXxs8tx+sIcQ6JMmrP/m6uVu6CuqHhq66rLPKZYB3D 9Ts2nxjbds+bcREjtJSnVZ4D/r26cdciuex5ThH9kuUC+/Ckj2qufdwwdcII+V31b0rR sxFuII5XoMeYVNq8VfahkuNat5EUq1QBic6RG+1+lSZJRj1At5mQ8fBEw/V0+vPGjbl9 p4foOmSR3dK+Gqm2AnUjORf0OLyUhqSr4oCD0O0/eLA2mQGh0AFhciz1kSLBOwdpphf2 re2VBQrRfLbf1znfwj0GMmG7g8/W+AQ6SEm+fcmCvLF9pSP2RCwzlq5zGFYTnkPlu0Ax HPIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nPrQtjxd; 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 o9si1176279eja.264.2021.03.05.04.31.53; Fri, 05 Mar 2021 04:32:17 -0800 (PST) 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=nPrQtjxd; 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 S232004AbhCEM3e (ORCPT + 99 others); Fri, 5 Mar 2021 07:29:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:37922 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231959AbhCEM3B (ORCPT ); Fri, 5 Mar 2021 07:29:01 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 69D4A6503C; Fri, 5 Mar 2021 12:29:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614947341; bh=mFSrD1wneVhbIU/DX/3UfO3ldbpjEGrofRg/SJrcfFA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nPrQtjxdnHJ7T1UO5qkAd8Y7oPbs3NXpVc3xcXfoyIuqJ1wVGgrvneLIpv+AqtiLn Y93J76J4LEA6jh6Vqo3Qm1a0jAToIuPJUoJyV2F6YwPP0Zs7uj4VX885nlz/apm+56 vsd3MbJGwpnW50G61OPmuW6VT87jD2jYtaBCfj+Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yotam Gigi , Ido Schimmel , Jiri Pirko , Chris Mi , Jakub Kicinski Subject: [PATCH 5.10 030/102] net: psample: Fix netlink skb length with tunnel info Date: Fri, 5 Mar 2021 13:20:49 +0100 Message-Id: <20210305120904.762036214@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210305120903.276489876@linuxfoundation.org> References: <20210305120903.276489876@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: Chris Mi commit a93dcaada2ddb58dbc72652b42548adedd646d7a upstream. Currently, the psample netlink skb is allocated with a size that does not account for the nested 'PSAMPLE_ATTR_TUNNEL' attribute and the padding required for the 64-bit attribute 'PSAMPLE_TUNNEL_KEY_ATTR_ID'. This can result in failure to add attributes to the netlink skb due to insufficient tail room. The following error message is printed to the kernel log: "Could not create psample log message". Fix this by adjusting the allocation size to take into account the nested attribute and the padding. Fixes: d8bed686ab96 ("net: psample: Add tunnel support") CC: Yotam Gigi Reviewed-by: Ido Schimmel Reviewed-by: Jiri Pirko Signed-off-by: Chris Mi Link: https://lore.kernel.org/r/20210225075145.184314-1-cmi@nvidia.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/psample/psample.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/net/psample/psample.c +++ b/net/psample/psample.c @@ -309,10 +309,10 @@ static int psample_tunnel_meta_len(struc unsigned short tun_proto = ip_tunnel_info_af(tun_info); const struct ip_tunnel_key *tun_key = &tun_info->key; int tun_opts_len = tun_info->options_len; - int sum = 0; + int sum = nla_total_size(0); /* PSAMPLE_ATTR_TUNNEL */ if (tun_key->tun_flags & TUNNEL_KEY) - sum += nla_total_size(sizeof(u64)); + sum += nla_total_size_64bit(sizeof(u64)); if (tun_info->mode & IP_TUNNEL_INFO_BRIDGE) sum += nla_total_size(0);