Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp6024010ybc; Wed, 27 Nov 2019 13:35:33 -0800 (PST) X-Google-Smtp-Source: APXvYqxA9kG0ugHbIf/RsFodmYuUubyDjpd/IJRmxgDhikj28BWQchSRUdsbANHgjlJRABR7Znon X-Received: by 2002:a17:906:e0d5:: with SMTP id gl21mr49894414ejb.292.1574890533038; Wed, 27 Nov 2019 13:35:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574890533; cv=none; d=google.com; s=arc-20160816; b=JF+WUWuvhaiAGrkgGrT0hURz7IYLuPyIc7vI3uoQWX8Vrn36t7n3aYPWpxP8dVcuSC QaIaITejf8FKw+ZHHhtoBtQc735/Oq+CVYNDnpD4DJL9f+QVn1dHKZi2z8lKaqPAUhDH o6/4mYpPchonhPyUv5nB3KOjQzo0Qr6ShfIued8TnR4hBMU/9q4SPDaxJao8bFbM1ScV vwR6tCtqwUUNqNwEgPUJLTQZ8vrnymC3FAb4SOS0VR6ZbDNXHOJ/428oB02zo+JRGmdS QYy2VKJSSMT9BTuXbIpnnR24Nz3YBegVjUVpOafIS/x5QYJBbOHW6v0I0o5bnXMjC194 RRMQ== 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=KxAencTmhJ5Kzztg1QzCDM8c7KOL8O2qLa7ItbO4XV8=; b=HsW/4GB18Ft1cqHFJeWS6Cn4qTikk404Ib1D6wYeac2/aF3GTflsWj1btXWNwBuhGT sZE/tXud1OXkmuJUf3lX+FtO01UGTWarbIuQ8FjEIK9UmvXHOyCCbdixBtPjiP05/e2u ZXvh/ffaTDO7pF/mwXuhTchDQCv3XSc1+HCFBLPas6htl7Kxx7ezFGZ31aoeIlM1+ocX 6OP10FAduA+pyjhLyOMtQuf+Ultpw1dY3oj+10wJRrteJLTf9IOgvdGAUUaXYuky94iz bcFwdPChR71maOm6LZBBYl6c+XDBGug5fs/De4DgVa4TdFRZXn8o5OVqTM2OQe75wTv+ +Lzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YlVFcHnb; 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 x60si11303356ede.172.2019.11.27.13.35.09; Wed, 27 Nov 2019 13:35:33 -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=YlVFcHnb; 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 S1730258AbfK0Uz0 (ORCPT + 99 others); Wed, 27 Nov 2019 15:55:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:45872 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730146AbfK0UzZ (ORCPT ); Wed, 27 Nov 2019 15:55:25 -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 0F29A2070B; Wed, 27 Nov 2019 20:55:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888124; bh=lDXkVWJ9S5dgNw9Hr18od3skLLTtbWiy3U51b8sjXh4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YlVFcHnb/9tTsRJ0Ouk+/yuOxdHOvaSqFDqvv6FsQMpHyFVdfxF1SWpGhy8kLvO4w 3Ekg0CeYM1gpMXOEzeOP+qnW0litkyuYxc2jg+4U0J/zthMwrxYmQo/n4WQSMSaDqh gZaOeKIGAysi0ghTOmUe39BznecX9TTKLFJyyjr8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xin Long , Simon Horman , "David S. Miller" Subject: [PATCH 4.19 006/306] net: sched: ensure opts_len <= IP_TUNNEL_OPTS_MAX in act_tunnel_key Date: Wed, 27 Nov 2019 21:27:36 +0100 Message-Id: <20191127203115.209535927@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@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: Xin Long [ Upstream commit 4f0e97d070984d487df027f163e52bb72d1713d8 ] info->options_len is 'u8' type, and when opts_len with a value > IP_TUNNEL_OPTS_MAX, 'info->options_len = opts_len' will cast int to u8 and set a wrong value to info->options_len. Kernel crashed in my test when doing: # opts="0102:80:00800022" # for i in {1..99}; do opts="$opts,0102:80:00800022"; done # ip link add name geneve0 type geneve dstport 0 external # tc qdisc add dev eth0 ingress # tc filter add dev eth0 protocol ip parent ffff: \ flower indev eth0 ip_proto udp action tunnel_key \ set src_ip 10.0.99.192 dst_ip 10.0.99.193 \ dst_port 6081 id 11 geneve_opts $opts \ action mirred egress redirect dev geneve0 So we should do the similar check as cls_flower does, return error when opts_len > IP_TUNNEL_OPTS_MAX in tunnel_key_copy_opts(). Fixes: 0ed5269f9e41 ("net/sched: add tunnel option support to act_tunnel_key") Signed-off-by: Xin Long Reviewed-by: Simon Horman Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/sched/act_tunnel_key.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/net/sched/act_tunnel_key.c +++ b/net/sched/act_tunnel_key.c @@ -137,6 +137,10 @@ static int tunnel_key_copy_opts(const st if (opt_len < 0) return opt_len; opts_len += opt_len; + if (opts_len > IP_TUNNEL_OPTS_MAX) { + NL_SET_ERR_MSG(extack, "Tunnel options exceeds max size"); + return -EINVAL; + } if (dst) { dst_len -= opt_len; dst += opt_len;