From patchwork Tue Jan 28 13:59:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 232442 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=unavailable 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 7C02AC33CB2 for ; Tue, 28 Jan 2020 14:48:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 46A022173E for ; Tue, 28 Jan 2020 14:48:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580222896; bh=UYePmV8CUdNFim5tIHubVgaS5KfCFYt1aT7JaIs8DwA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Vxm5uDRw48mOMIjTkfNBeqqLz75YsUyGVr6XFiEcRf3VuVPbqqhoMiAIHNLUm9bcG 7bppSlRolx9tn2zNuvR7O49Wvaj5QFUdxChnbN/CVvAskXVpG6OpziMzKxafwUqFlr jTD9NwLV1ghfZzAXWsrVftjYfNceDe2RYhBIheBU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727721AbgA1OCr (ORCPT ); Tue, 28 Jan 2020 09:02:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:49144 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727706AbgA1OCp (ORCPT ); Tue, 28 Jan 2020 09:02:45 -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 DE18F2468D; Tue, 28 Jan 2020 14:02:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580220164; bh=UYePmV8CUdNFim5tIHubVgaS5KfCFYt1aT7JaIs8DwA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mJBlfvo0tlv+raspp27FnaRoZErjwJrrZPT52Ler72pPh+5IIkCDvSibD3J5555K5 dFMULclQquJl+ZHtXsHpOonhqFLCS3k5ty7k54ZC5vTAx8U2EWBzWqtTKHAdpEQbDT n0MxN8ct3tW9vQqUdYUGpaPnZmnUvjAow8ontWP0= 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 5.4 011/104] net_sched: fix datalen for ematch Date: Tue, 28 Jan 2020 14:59:32 +0100 Message-Id: <20200128135818.800068165@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200128135817.238524998@linuxfoundation.org> References: <20200128135817.238524998@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 @@ -263,12 +263,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;