Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp495141ybl; Tue, 28 Jan 2020 06:51:15 -0800 (PST) X-Google-Smtp-Source: APXvYqyMB1jsu0Njafeu7eJnkyZfurAkg7dJCCxuJgEO1q3duC1zlKOCsYNu8GGT4hU850qaZxNq X-Received: by 2002:aca:bac3:: with SMTP id k186mr3173359oif.19.1580223075664; Tue, 28 Jan 2020 06:51:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580223075; cv=none; d=google.com; s=arc-20160816; b=n4uM+BA5a/6T48ZEKPUdoADmSZiENoXVMFiKuev8BQy2IIYmzKt9uf8YNeB5XqiShp Yrxt6Xa5POnO+vWYZjNOiTdfkib4YYRcsKlx4N+dDd7aN00W+SnLt3pX0vAXmvvtIUzn w4dH8sPdB5CJj7XFR/oU0bxIL4XFVHAQ4JIs8uFtyp6RHNZhFnAOkk+ikmPyZWsEdBx0 u+UoGzf+gfrJlXLTDm0VXC68AEoFjnstPyEldQ2vxmCyFY/tHoexyuSZcSp2qDYCgsA6 63I+eQQMQBzTg69j8Bn04rMardjHG3z8sOYiJZTp2kXiG0c0Cg7iegp1H57bGM7wYvS9 6Rkg== 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=bNL7wk5I+A6h8/x8XOJHihxR+VYkvbHOE0Hpl4xwEmKpZzUMTIQukyxQedIePOrLe4 K8gTXQ0QGmV8FFdsH49KEeUCZvA9Pc3M0I7/xxMAHKAdZgpC1oUEnq2sBp+ILMFmUKHB aXTa0mOR7I8LE1AUXMTh7GNU/w53MgyuNhR5aEWPQtEtFaZw+KyyamhgqQAdctasV6+W EwtVYT6X7mtbnliUYd6e9msoOsuBoxnYfJ3UaARWwE/6UpA5zC4s7p5QBtWqPakMbi+v bsDg8vd69Ig6Mvhw9zJp69n7AfW5HayJGnkuM8BvCcZVatqqV1IaEQWu408gqbIIoSmU 8xdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=U69Onotk; 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 l6si8314131otk.134.2020.01.28.06.51.03; Tue, 28 Jan 2020 06:51:15 -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=U69Onotk; 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 S1727063AbgA1OuM (ORCPT + 99 others); Tue, 28 Jan 2020 09:50:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:44970 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726477AbgA1N7d (ORCPT ); Tue, 28 Jan 2020 08:59:33 -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 2B3132173E; Tue, 28 Jan 2020 13:59:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580219972; bh=g98h9zgHGfmJG7qp7shi05vz6GMzSl3GulPJVilvKv0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U69OnotkKaUaRp8rjRvDEU4Mk8MpQrxZXKcdfrD3hb0poUoGjXVrpbhcPL1TtvHKG I9O60+LhanuSDh1NVgbvAs6p8812Xez5naKrzbyI1WZxQffp8i+C7nqyJl/dvu0Pat MrX0IoYfV/8rTL5+JSQnkttMhIwiivnsGF7spOLU= 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.14 08/46] net_sched: fix datalen for ematch Date: Tue, 28 Jan 2020 14:57:42 +0100 Message-Id: <20200128135751.237908634@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200128135749.822297911@linuxfoundation.org> References: <20200128135749.822297911@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;