From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 660C8C3F68F for ; Tue, 28 Jan 2020 14:34:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 34CFC207FD for ; Tue, 28 Jan 2020 14:34:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580222042; bh=g98h9zgHGfmJG7qp7shi05vz6GMzSl3GulPJVilvKv0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Vg7nEzHggC76k/mTREUgRZVHP7M+VN6JSQbZl7PXd7orEuySwC8frsyOe4+DPIJ5w raiY10L4zGJ2it8WVTcvrysll+6m6UFRwFP3NETK/gg8Lo3ev62i35lCYn5wUCNVfR YiHEMG79sOKlV6jI/KVrX3GJPiyoU2NFXk48UDCA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732601AbgA1OYf (ORCPT ); Tue, 28 Jan 2020 09:24:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:51286 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732572AbgA1OYd (ORCPT ); Tue, 28 Jan 2020 09:24: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 42AE12468A; Tue, 28 Jan 2020 14:24:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580221472; bh=g98h9zgHGfmJG7qp7shi05vz6GMzSl3GulPJVilvKv0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2OTe1qjwLxst8c287OfMfma93MvBqYw6+V30ii/hvrWuxeI/9MMP1LNILq/rbngc0 fu1+02X3uQOn47xQIHOAvLNvb6orrl8FxZsF21iSg0U3nWLDlGRrJnH0DnWwY+C/xT pxx5mLW9uz2+tjb92w7+b2jQ4Z97mpnlOn+drRTc= 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.9 239/271] net_sched: fix datalen for ematch Date: Tue, 28 Jan 2020 15:06:28 +0100 Message-Id: <20200128135910.335176711@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200128135852.449088278@linuxfoundation.org> References: <20200128135852.449088278@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;