Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp487312ybl; Tue, 28 Jan 2020 06:43:40 -0800 (PST) X-Google-Smtp-Source: APXvYqzXij1XULyrmgSi6g67LFZ3eYtmoZMeyOKrWSsWey7ITg8n/ZGD+qVAMQ9lTM4yb/wCEx6v X-Received: by 2002:a05:6808:a9c:: with SMTP id q28mr3042704oij.176.1580222619937; Tue, 28 Jan 2020 06:43:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580222619; cv=none; d=google.com; s=arc-20160816; b=SzZVq/2b/95l1SBfNMt8NfQ3UKLcVty9H7a2PVMUKYtrrFWuwPZf4BolW0LTyHWs9P 3fTYJD7gYswIft5thlB7E8s321zFt+Xv+GguJ1EprK88KRrM6Lj1KMnY2lB5l6cJr6Do PB0sD1Nb2VleUvSffrvAp0nh/KAe8Z7kGV9a/8hJ6YYPcFfyT+Z6K4i1jEKcTM1T8jTm rhtEx4HTTwLIiN0WILtZNX9hzsnkDH2ODvHfOc+mJnSSxmwCH09F7rFOcxJgoWX011n0 Yc7qABppaQ3Re3PwqlHomtY4foteMqUyWImCAMfdDFRZXkgSP8G8Bhqnpbh7NKv8IME3 +Gkw== 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=sZoBvJw2bPOiT3nxLDevzfPB3VSLtizonjNUCLIIkuM=; b=JDT7VlhFRppeYnBAhsonlLOah11imD2tcKEKkf8QjBSkh+H9xm6JWR2bqSOSS0IFdc /J5xbz1YGV8/At6KA7fc6ATuCCYpWS5kOvCkpY93svWRd0C05StpspSezZInbDDjEmTX b+PIIXHglDfKexSgzvkcKTcBFWxkemkX7PVsH8D1NkUZ0u5cREKtNQ3fFWSArK8uywQQ GhTbLMmPKM84Bw4c3nfqKFRZCfbWxh/Nd1WME0TLG3YZ7/cZU5Y0gmZHkMidLqPlbUd0 F92HOLOx6UGBWYoyKNV5O1Gp6jRTORvW5cP7K9FM4tR/ENOKESjLKsO0wiqotpafaO5J 2WXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=D++hEZaq; 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 l26si8390198oti.152.2020.01.28.06.43.28; Tue, 28 Jan 2020 06:43:39 -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=D++hEZaq; 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 S1729728AbgA1ONw (ORCPT + 99 others); Tue, 28 Jan 2020 09:13:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:35628 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729546AbgA1ONs (ORCPT ); Tue, 28 Jan 2020 09:13:48 -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 F26C724688; Tue, 28 Jan 2020 14:13:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580220828; bh=g98h9zgHGfmJG7qp7shi05vz6GMzSl3GulPJVilvKv0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D++hEZaq6UtD/ZDvw+fxE/Ylp3H07nCrmZMT3s+ayM4eK5IU7WfLTm05mNOoqVCZa aeoMuoYFcBrUJIGjGkIk2hglgNketZ2QMSe2rE4GMbSisc50ExqEbX1pk4sz/fI1q9 8ZRAfVDOn0gUVbruxq5ZBSLdF+KDzGi+vWpHdcc0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+2f07903a5b05e7f36410@syzkaller.appspotmail.com, Eric Dumazet , Cong Wang , Eric Dumazet , "David S. Miller" , syzbot+5af9a90dad568aa9f611@syzkaller.appspotmail.com Subject: [PATCH 4.4 164/183] net_sched: fix datalen for ematch Date: Tue, 28 Jan 2020 15:06:23 +0100 Message-Id: <20200128135846.069120311@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200128135829.486060649@linuxfoundation.org> References: <20200128135829.486060649@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: Cong Wang [ Upstream commit 61678d28d4a45ef376f5d02a839cc37509ae9281 ] syzbot reported an out-of-bound access in em_nbyte. As initially analyzed by Eric, this is because em_nbyte sets its own em->datalen in em_nbyte_change() other than the one specified by user, but this value gets overwritten later by its caller tcf_em_validate(). We should leave em->datalen untouched to respect their choices. I audit all the in-tree ematch users, all of those implement ->change() set em->datalen, so we can just avoid setting it twice in this case. Reported-and-tested-by: syzbot+5af9a90dad568aa9f611@syzkaller.appspotmail.com Reported-by: syzbot+2f07903a5b05e7f36410@syzkaller.appspotmail.com Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: Eric Dumazet Signed-off-by: Cong Wang Reviewed-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/sched/ematch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/sched/ematch.c +++ b/net/sched/ematch.c @@ -267,12 +267,12 @@ static int tcf_em_validate(struct tcf_pr } em->data = (unsigned long) v; } + em->datalen = data_len; } } em->matchid = em_hdr->matchid; em->flags = em_hdr->flags; - em->datalen = data_len; em->net = net; err = 0;