Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3284798ybb; Tue, 31 Mar 2020 02:05:30 -0700 (PDT) X-Google-Smtp-Source: ADFU+vteM2J32pxmZuz1PHCeo1Ig8ri6MeqSWPCkWPLo1ixqd+lA/AeQE2cmI3Qdby2HG+oyhgAh X-Received: by 2002:a4a:db7b:: with SMTP id o27mr12590805ood.25.1585645530107; Tue, 31 Mar 2020 02:05:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585645530; cv=none; d=google.com; s=arc-20160816; b=p5oI0eIMyzPIsEFBJkfJVUULZAjH4VhbtJEygT2q5/IaEQLahwcCM+dP7y+aLj3md2 bU58kDUw1PXBBIT9R7ELFHBAq4UKFPIxSKPHFVKKwLgjWm4PUGC68Mlmsr/DL79YWgRW mWuRouuP3watMXqfWd2BN04Tc0+dPL7GJwLlAV0rchNcIvTx12RURd6En5/41khqzVoS tKQBFETUmEbKfP388U8Em6MxR8QyNjVhTXZuHj9eBrVruldFMogvoIaJDywa3v04SuZN g4LgQKO87kYeT1xvvc9eWC6h1QLocJ2nAfr1yWTN7ShNSLOxI4NffOHGpXqyXwb0aUrP qN6A== 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=gQgU+mzyTKMnnAg5ZHrvsUVraaQ6ZwcFJBYPIStntcE=; b=fexOtynqficIIVFS0/1U3h4KRimqO5W3Z91hGPRQpDi6gnKrPz4KMOJZoW72Xy3CCb ayY0cT8tx0fqA5VXhbX+KrAyS0enpndG/1LLCvITZAzuOLw843GI1BeiIGIhkcTTxR1T juQ9fBMsPWNNxtLtoiBNDf1Idb7BrKZNbkW5Qxuqmo1rP/4y8dnYLbvXtFIPYjhJf+OI EuECUwDbNHBILcnSp7arM32CWSRbT6bdipGYwPR+VMAG2eky3TUCx0XFdKJTIDvjfWyJ AdPdQVN0NP6apjGOeAmvOOJxvwvsuCNGGU9N/De3jN3fq2LSiZKO3mawpAI27JpInQLP wbfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Wa8gP2Ry; 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 f10si7846760oti.88.2020.03.31.02.05.18; Tue, 31 Mar 2020 02:05:30 -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=Wa8gP2Ry; 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 S1730800AbgCaJEt (ORCPT + 99 others); Tue, 31 Mar 2020 05:04:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:45422 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730662AbgCaJEj (ORCPT ); Tue, 31 Mar 2020 05:04:39 -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 0B2A720787; Tue, 31 Mar 2020 09:04:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585645478; bh=IKMRmH74vmWvgonCOt9OVPayC8V5NZ4cwRm+9cNEM0k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wa8gP2RyfeKaIhDNlUNtXCenrvX/DcJgxjM01HFpyBKsmwRO/9VVUKf880l5f0Rtc hZrlwnZnIY40f8/xgtHJdTu1oBiXKXxRHpqtW2uuT27bIGLZ1PZTibYjjw7FH79P5T qLD65Pg3d5a2ZuURCs9FbSQ2s4WE9FmXePsr+Tsc= 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+653090db2562495901dc@syzkaller.appspotmail.com Subject: [PATCH 5.5 030/170] net_sched: hold rtnl lock in tcindex_partial_destroy_work() Date: Tue, 31 Mar 2020 10:57:24 +0200 Message-Id: <20200331085427.277734183@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 b1be2e8cd290f620777bfdb8aa00890cd2fa02b5 ] syzbot reported a use-after-free in tcindex_dump(). This is due to the lack of RTNL in the deferred rcu work. We queue this work with RTNL in tcindex_change(), later, tcindex_dump() is called: fh = tp->ops->get(tp, t->tcm_handle); ... err = tp->ops->change(..., &fh, ...); tfilter_notify(..., fh, ...); but there is nothing to serialize the pending tcindex_partial_destroy_work() with tcindex_dump(). Fix this by simply holding RTNL in tcindex_partial_destroy_work(), so that it won't be called until RTNL is released after tc_new_tfilter() is completed. Reported-and-tested-by: syzbot+653090db2562495901dc@syzkaller.appspotmail.com Fixes: 3d210534cc93 ("net_sched: fix a race condition in tcindex_destroy()") 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 | 2 ++ 1 file changed, 2 insertions(+) --- a/net/sched/cls_tcindex.c +++ b/net/sched/cls_tcindex.c @@ -261,8 +261,10 @@ static void tcindex_partial_destroy_work struct tcindex_data, rwork); + rtnl_lock(); kfree(p->perfect); kfree(p); + rtnl_unlock(); } static void tcindex_free_perfect_hash(struct tcindex_data *cp)