Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3715054pxv; Mon, 26 Jul 2021 10:04:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrEdBI7cCTvv/zLrhBs8ucM6tvoCS5WNyldgav96juUSP1Lm4lQzZzyJX9d5AxQcDJeFin X-Received: by 2002:a05:6402:1a35:: with SMTP id be21mr190479edb.332.1627319087897; Mon, 26 Jul 2021 10:04:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627319087; cv=none; d=google.com; s=arc-20160816; b=iKc3cQO34WipE5re0lyyrijSYetdviGLCIF2Zcl+6Elgn2RGND3Foej8vzvEIVULwV QgzCEQuyXOhPctp2o74sJcwGw6ZbHOy9d2Sv72+ayODvEtlln9uNy1vP5W6CJ/A8Y1bf SAQZQQIRT8/juIobbSVH+jbdSn1vk1MWbeTV37jzAEAxfJEs1gckuUVraiu9rli1qUnf LEUOOWaKD55cw8eXz+ca+7pvnjvruWW2tOP76oaYD46rjEzKDbTM2hdpNPFoUQS7oqaL R+tdCEIqJDF/cZSFccc42bYC0MCsdYrM/dX7OESsN7WC797VKRllfogOmjV0ZoiupDRB z5Rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Xqql854wJriSCfUxAgvIdIbM0yeXB1rIuRo1ubNRjrw=; b=0i3FPH5WrP44omqkCTY7xYvqZfZLrVV7T9MfUMRB6/UEhtP108+iFxMq8eiA5n2+ZV QlRUZe3v7slzuAm0AfgKrvuwSXdOmtlVEP+sT4CcVqVEpQRktvFhBnx8JQB5hK49BzLP LYk0egvJQa8ydQv2BsckOZNHEuSy5Sc96VPO0N0CEYL27zZ2ZeadaWf/95dDvBdEBq3s Ma3kISkOxEl/wNxTaM3NfZ1CXHGpeKv+MMX8+KPUuzptetQPvba48GV0ny6MJt5B0XjA xRhr7eDriaoYCUKI4saP7ehdlqf5REBAmBtRShvy0DIVN+zJiUb76vtfugf3SBPQ+5Zw FYMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mF5lrnBO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t5si472408eds.212.2021.07.26.10.04.23; Mon, 26 Jul 2021 10:04:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mF5lrnBO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238438AbhGZPnD (ORCPT + 99 others); Mon, 26 Jul 2021 11:43:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:39348 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237603AbhGZPX5 (ORCPT ); Mon, 26 Jul 2021 11:23:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0B83060240; Mon, 26 Jul 2021 16:04:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627315465; bh=MwThTflVdON8+PjJgXphdsRoMD83rejvJwXVY2l3kuQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mF5lrnBOhiGE8cd3vUuJfhFrqUa4CxBdTgcsNcvaepEd01firDbcyv3gpP9Kf8/nr zQffVX9ypktClJFsYiCS15/LBqKgbAmsMHhhNPleh7nVf/R9UY15ktBESDkpEmdGEl 0Xc0qZfXcAvYFeG6fwNM+4fnnLWeyJ/SZporw9Is= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Skripkin , "David S. Miller" , Sasha Levin , syzbot+f0bbb2287b8993d4fa74@syzkaller.appspotmail.com Subject: [PATCH 5.10 072/167] net: sched: fix memory leak in tcindex_partial_destroy_work Date: Mon, 26 Jul 2021 17:38:25 +0200 Message-Id: <20210726153841.812622560@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153839.371771838@linuxfoundation.org> References: <20210726153839.371771838@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pavel Skripkin [ Upstream commit f5051bcece50140abd1a11a2d36dc3ec5484fc32 ] Syzbot reported memory leak in tcindex_set_parms(). The problem was in non-freed perfect hash in tcindex_partial_destroy_work(). In tcindex_set_parms() new tcindex_data is allocated and some fields from old one are copied to new one, but not the perfect hash. Since tcindex_partial_destroy_work() is the destroy function for old tcindex_data, we need to free perfect hash to avoid memory leak. Reported-and-tested-by: syzbot+f0bbb2287b8993d4fa74@syzkaller.appspotmail.com Fixes: 331b72922c5f ("net: sched: RCU cls_tcindex") Signed-off-by: Pavel Skripkin Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/sched/cls_tcindex.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/sched/cls_tcindex.c b/net/sched/cls_tcindex.c index 5b274534264c..e9a8a2c86bbd 100644 --- a/net/sched/cls_tcindex.c +++ b/net/sched/cls_tcindex.c @@ -278,6 +278,8 @@ static int tcindex_filter_result_init(struct tcindex_filter_result *r, TCA_TCINDEX_POLICE); } +static void tcindex_free_perfect_hash(struct tcindex_data *cp); + static void tcindex_partial_destroy_work(struct work_struct *work) { struct tcindex_data *p = container_of(to_rcu_work(work), @@ -285,7 +287,8 @@ static void tcindex_partial_destroy_work(struct work_struct *work) rwork); rtnl_lock(); - kfree(p->perfect); + if (p->perfect) + tcindex_free_perfect_hash(p); kfree(p); rtnl_unlock(); } -- 2.30.2