Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2661465imj; Mon, 11 Feb 2019 06:38:27 -0800 (PST) X-Google-Smtp-Source: AHgI3Ia5eczEEQCaPug2OBKBRap9Gplt2EkDOD74Ra75rmzIQoEjfSMmWwVOHumFoIBIiVyTBruL X-Received: by 2002:aa7:808f:: with SMTP id v15mr29525126pff.30.1549895907192; Mon, 11 Feb 2019 06:38:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549895907; cv=none; d=google.com; s=arc-20160816; b=GcMYt4U3OgxTt12NcKJXEViMJwmMFXQFmsLlIplZQ3MYwdUYZZf4ABt8Z0gS1Iwngz dIQXnbijp8fME0f0GudsovoiwEb53TsYS4nOkRmMdPEXhE3i2F2EDzgxPv26hY7UYOLM snStd2ErRGj8xvg8wZFKlJAuTaysqbFGCcWsWjNW2cP2gKcJ9u3LdpjgW94cI45WYIVL iMb+o9Iw+sva9qojy6CXRcdMHAnyFzLineD8CLex3ePyCnwN1q8ywJewD3e4sZL6IKog SngNY4QH7SYEExEiyqpldEyUVNRTD/6uDMontOvuWWd+RnCSPJuWDeIIRb3wqe7Fv42L MksQ== 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=2iybBUnVYDOtpPJ7JxHb6Sh2pFdhDqhNdSaBDLCHfx4=; b=bb9gQxMQqexXcIZwO9LuC6MCgzE056N/+ycebAZHSAZUT66AmDcmPvpsF82ZcACVwj Rvj6o8lERRcyViIPh8uvRS4UPDw0ogRr67PqG4EXDsVwN8qJjeabATWbNgF99egXRiVM Abe1WcXX8TLDHxudDmZoKUjiZbv4exFJN0N1EjqYle8eXnuxIcuyDvdH4RBZFaucIf3j v66uFwRb4aHudDWqegzOom4122kIrKz7O9YzPWWJd+mOywEzFVEKZAwSRn8rc5LsHIAD NkjcHl6FDoIktgPP8hh954qsxok27uXbc1yKIpSE6dCsXq9OIYOCDG/te8g0H/6qrkw/ f4Ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1HMSgQhy; 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 v11si691433pgo.11.2019.02.11.06.38.11; Mon, 11 Feb 2019 06:38:27 -0800 (PST) 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=1HMSgQhy; 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 S1730688AbfBKOhW (ORCPT + 99 others); Mon, 11 Feb 2019 09:37:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:46684 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727856AbfBKOhU (ORCPT ); Mon, 11 Feb 2019 09:37:20 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 6E7AE20700; Mon, 11 Feb 2019 14:37:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895839; bh=tD7xVjHiAbceYoaqAulRpyXeSOTx8m1bXDAjDNIah9k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1HMSgQhyeDz6t64hzT/zgLYG1kRKhF45CfNvCwtZjbETDwUrAZ99ytr+R3hKCRzes qEHvuzEIQvKL4oxEPJFMJI6ywQyDV3Fr7A+W32w1YEsDvYbLTPyHafTdACSCx/hYHE ma/o4YXS8FowYLqIkD9hu8QdEJPNRievppLkzaWg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Petr Machata , Jiri Pirko , Ido Schimmel , "David S. Miller" Subject: [PATCH 4.20 309/352] net: cls_flower: Remove filter from mask before freeing it Date: Mon, 11 Feb 2019 15:18:56 +0100 Message-Id: <20190211141906.508563277@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ From: Petr Machata [ Upstream commit c1f7e02979edd7a3a3e69fe04be60b1d650dc8a7 ] In fl_change(), when adding a new rule (i.e. fold == NULL), a driver may reject the new rule, for example due to resource exhaustion. By that point, the new rule was already assigned a mask, and it was added to that mask's hash table. The clean-up path that's invoked as a result of the rejection however neglects to undo the hash table addition, and proceeds to free the new rule, thus leaving a dangling pointer in the hash table. Fix by removing fnew from the mask's hash table before it is freed. Fixes: 35cc3cefc4de ("net/sched: cls_flower: Reject duplicated rules also under skip_sw") Signed-off-by: Petr Machata Acked-by: Jiri Pirko Reviewed-by: Ido Schimmel Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/sched/cls_flower.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -1257,7 +1257,7 @@ static int fl_change(struct net *net, st if (!tc_skip_hw(fnew->flags)) { err = fl_hw_replace_filter(tp, fnew, extack); if (err) - goto errout_mask; + goto errout_mask_ht; } if (!tc_in_hw(fnew->flags)) @@ -1287,6 +1287,10 @@ static int fl_change(struct net *net, st kfree(mask); return 0; +errout_mask_ht: + rhashtable_remove_fast(&fnew->mask->ht, &fnew->ht_node, + fnew->mask->filter_ht_params); + errout_mask: fl_mask_put(head, fnew->mask, false);