Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3285193ybb; Tue, 31 Mar 2020 02:05:58 -0700 (PDT) X-Google-Smtp-Source: ADFU+vt9rVLwXhUla/XRTNUE1foJ4cjtOKZc3qKCB9+gnhuRosD/uyWAYcrdduEJZtkDK/AK+qg5 X-Received: by 2002:a05:6830:1bc9:: with SMTP id v9mr11592726ota.169.1585645558279; Tue, 31 Mar 2020 02:05:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585645558; cv=none; d=google.com; s=arc-20160816; b=xPINHmjMFKpxKY2QLKApspDKyy09coMqEQc4gkUaFqPNN/XQ+xCRQgoFAK2MTuIVbR LArZfWUgfToGGa1Vha5CGmTp7OVhqvRogerq5sMrkMT1yx3HK5GXQZfvMYuTgEiY8KmX 0iLR4cuGzWq0ifuO/b7ikKfoObuFAJCmvGW+IeQvMneUZ9DqOGE0ueWIkizKnACVg3UL MjsMkaOXMjzCI3cH835VdE6iqt18CzApTcGAWyP17mxE4fxcCiidA8eDVm/Cp8FcBeuG qTCt76E6is5Ily8/igaJhnqJtYq3Y6dGB8W+m48TTB5LvWRNx6CUTW71+CtWijIfpdlv +zbQ== 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=+ARRKnUe+6IxYwpGE3SOl4Z3knt4V+MsZ0E1uIT9BLc=; b=xjJ3HbLjU9PU8/izh1XJYMQAU2pYZ+9a5Dd2sw6MIaQt0vl7RFF/wr3TiYpSLTudag AA6ac4BzC1OycNF4gPO3AGu5mn/vPgLKHDJ1g97wRczg0KSdZ98bnPbc2KS2bZhfH5lr 08NSCCkmIMPeL1ziLI1GxZqSfCBmsp4mWSa+rt9VxZMZJxrVjgDPuk6ycpO8gEeNguP5 5skLlmWdY0ADf9LgrmlcmBwzRSytdTUDFLbzAVvW+jO8G2mXl+FkYJhLquo2pG23wbVt Hz4KpbqwtqYKPUTtlWvl6kARLTKQZiQQNCazqy7EUVQLw1F0LBiA3Mf4xDBcVgTKfWPA O6dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Mf/DuTML"; 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 s15si6768912oie.175.2020.03.31.02.05.45; Tue, 31 Mar 2020 02:05:58 -0700 (PDT) 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="Mf/DuTML"; 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 S1730416AbgCaJEz (ORCPT + 99 others); Tue, 31 Mar 2020 05:04:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:45646 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730648AbgCaJEx (ORCPT ); Tue, 31 Mar 2020 05:04:53 -0400 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 2EFFD20787; Tue, 31 Mar 2020 09:04:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585645492; bh=0H0yxTCH0FS9s8xJIWY4odP8O/qWQfnbC5X7miz54Mc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mf/DuTMLf/APqh2iwbMuUtqAOIPBJzy37Gr3lRDbSRijeUWwn3ZK1qMTedmf2qQhi 2EA/ZSS0ZQezJkUSS7fxjZl5pkySlAOaKZ010g4o6nSaNsJHZczKe7AjDLJVyDRLN6 RZoLZFcbKyFZRq83waDX8a9drhWefL6tMVFFJ6V4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jamal Hadi Salim , Jiri Pirko , Cong Wang , "David S. Miller" , syzbot+dcc34d54d68ef7d2d53d@syzkaller.appspotmail.com, syzbot+c72da7b9ed57cde6fca2@syzkaller.appspotmail.com Subject: [PATCH 5.5 031/170] net_sched: keep alloc_hash updated after hash allocation Date: Tue, 31 Mar 2020 10:57:25 +0200 Message-Id: <20200331085427.367126817@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200331085423.990189598@linuxfoundation.org> References: <20200331085423.990189598@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 0d1c3530e1bd38382edef72591b78e877e0edcd3 ] In commit 599be01ee567 ("net_sched: fix an OOB access in cls_tcindex") I moved cp->hash calculation before the first tcindex_alloc_perfect_hash(), but cp->alloc_hash is left untouched. This difference could lead to another out of bound access. cp->alloc_hash should always be the size allocated, we should update it after this tcindex_alloc_perfect_hash(). Reported-and-tested-by: syzbot+dcc34d54d68ef7d2d53d@syzkaller.appspotmail.com Reported-and-tested-by: syzbot+c72da7b9ed57cde6fca2@syzkaller.appspotmail.com Fixes: 599be01ee567 ("net_sched: fix an OOB access in cls_tcindex") Cc: Jamal Hadi Salim Cc: Jiri Pirko Signed-off-by: Cong Wang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/sched/cls_tcindex.c | 1 + 1 file changed, 1 insertion(+) --- a/net/sched/cls_tcindex.c +++ b/net/sched/cls_tcindex.c @@ -359,6 +359,7 @@ tcindex_set_parms(struct net *net, struc if (tcindex_alloc_perfect_hash(net, cp) < 0) goto errout; + cp->alloc_hash = cp->hash; for (i = 0; i < min(cp->hash, p->hash); i++) cp->perfect[i].res = p->perfect[i].res; balloc = 1;