Received: by 2002:a17:90a:1609:0:0:0:0 with SMTP id n9csp846122pja; Wed, 1 Apr 2020 09:45:04 -0700 (PDT) X-Google-Smtp-Source: APiQypLfRVSrUP5RHczowcMRhd5d3nGbxHzTcMlB8jVzhvPbnuwT/51dSHPLp6954bui5GQr4vr1 X-Received: by 2002:aca:ed4b:: with SMTP id l72mr3244573oih.95.1585759503817; Wed, 01 Apr 2020 09:45:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585759503; cv=none; d=google.com; s=arc-20160816; b=dw/YIk38BT+/roC5jAcBV4UgH/4e6ooBoOi0OAVEbvuCxlPAYh7RsFAlFcJ985lgdE so4Gi6SJEXfGncSxU16QUGs6/H3URV+kEbzn3hefkgJTlhKhweztzxjb7mjglrEJFE++ Lt6u44cFlH2fshhyGyFaChZJTQmnevaov2EO0GzesAygyCq5xvA0Q+nmF9d7mXJIUQdJ z1/IXvE6JWi+uL2um1lYZOiBToLY8doQQKuNav+BWmE03ThRAISbRujfmW98hQNvrMDb hxOMiNiBjQhhp7cGb/uXWrS+zCJQAomgELuwHaKp6CwtSvYQvGYdkf5eKoHH4hBYXb2q GWKQ== 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=EK6vcn0woFpLsgpbnRx8atLsH6IZOejsQ+Iccfq+/kQ=; b=mpJXQSL29zUEfTIN2cGuepvrKGC1fiUBJiPN1FOeFEqE0jIv1NmUbRSzBriGUYLDZ8 5BWM76ygzP+SKQEngMmPJEJs3xamsSQVTvcKPQse4GxjuY/EqGZZu2Rkx7ygW+MEleyv O+FEAhcdnleTC2LyFNrvBvrVYYpQJe8ShO6pW3AGmD5PhrPxhu1WEZNxZ0/MXFCvTLLD LixW8LJ+fr6H0WbEbeMUegkwDn9yZh6UDU5KN+0JSXd01ju/gGS3UB3O87FFofhrwMZu eFYzIaDtepRkeTenjTBbCxuPWQ9QTGih8VIpBaorebSC1unspXlwDCSNa4RH8bhN2Jq8 yxOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=C88z90Dk; 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 f21si1095036otf.31.2020.04.01.09.44.49; Wed, 01 Apr 2020 09:45:03 -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=C88z90Dk; 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 S2389593AbgDAQnK (ORCPT + 99 others); Wed, 1 Apr 2020 12:43:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:43840 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389591AbgDAQnH (ORCPT ); Wed, 1 Apr 2020 12:43:07 -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 9E2F1214D8; Wed, 1 Apr 2020 16:43:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585759386; bh=8c9L/V/NFaE7MJiSJqrGZJsOP7sIRux2YXMZXzY50dI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C88z90DkBt0TbktGs6ov66kBpN4Ddi1zvvjrN0a94xb2Glcw7uUSPukF1fAlhKkMw C1o7r7V91FOQaz+Yw8Oe+ax64mnmXA3PXNofR1nSJ7YJi8+UYEno49OhV4QzymwYdh WqNlFBs93wliEJnGDkKq6uy/FAnrp2mkJhAMGEVk= 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 4.14 063/148] net_sched: keep alloc_hash updated after hash allocation Date: Wed, 1 Apr 2020 18:17:35 +0200 Message-Id: <20200401161559.731808028@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200401161552.245876366@linuxfoundation.org> References: <20200401161552.245876366@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 @@ -375,6 +375,7 @@ tcindex_set_parms(struct net *net, struc if (tcindex_alloc_perfect_hash(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;