Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp409257pxu; Tue, 1 Dec 2020 14:32:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJyGfLvBaYc86Z+JmwgMVl8ikjHB60pDnzDI34M8lu+e+gL6jnDcWN5u/8rCcuRHqh2pJHTM X-Received: by 2002:aa7:d3cc:: with SMTP id o12mr5515495edr.235.1606861976346; Tue, 01 Dec 2020 14:32:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606861976; cv=none; d=google.com; s=arc-20160816; b=ZlMyQa9rAQCctbBvw+PjNCJxxVFbSegX8VKNayxpOABBsW7yjVhnZFvRPnUNiv7Uo1 kykZIxootICwj9JIEG82xXdXfZl5MTSJTcUS5Zrlv3lTSxugJqzFsXeaz/3OZDdFYxD1 bhOiK2FCICVF8AB26d95RMN0BV3IFjsUPLxIxTA1yyq2PshfPFpYBwDz4LUnJyrZbWEm ExdxOT1D19UIF/8SwcuvsBg2npCmggxzfZiWkberjJwWf9FE6oYPKTGl0l62RRrl4NEa MLdVc95OX89tmhK9NdrV3D8ugtMeIzFu2d2bONLMAUV9juXIiAE9N6XxE+cl06MpCvXL w9oQ== 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=z8aPe+pxvKXvCl/d9rG3jeeci37ZneyIyrxyhLXD+dQ=; b=I45Kj/fuJI5w4GgMt5zOaZN8q4ecZkIOfMUbqFd/QF0M3y9JplKYasY5mjM+FxuT/T lXw6p5Rdne4zQvK8MnTabAtS7QDzlEksN8u1c+5lsMB52V3Mr8oXQ46vYA9Ej6tZ1jBM e4EqZsBKUUNBJLLBv0DuXCkbOT1gT2d8KfCeKbakEqrMx5uAXJKDTroJhdrNT5roa0i2 Q0QFHaGO+gx52nChl6El8LTIFljuqQss2XbizuKtqiWAxaOlfXnA+9/9LLSuouD9Az87 47LIcBJtxOP29EQFuRB6LAzssPiaxFIrUWGGeHCrIr4up1xM3v9AtEFqGEgdTSOIoZpU b7Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EzgYA5Tx; 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 a16si833559ejd.678.2020.12.01.14.32.33; Tue, 01 Dec 2020 14:32:56 -0800 (PST) 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=EzgYA5Tx; 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 S2388022AbgLAJ37 (ORCPT + 99 others); Tue, 1 Dec 2020 04:29:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:34130 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388021AbgLAI6w (ORCPT ); Tue, 1 Dec 2020 03:58:52 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 1457B22263; Tue, 1 Dec 2020 08:58:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606813116; bh=FWYzyAvsmH9gmnk3+mnNy3OO/7bB/gYePgJTO7uXDJ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EzgYA5TxfqL0O+q4okSGi2znCK/r7luq7VuT72Ys/Q7VvraPJItWp2uIUZllqnLUv VjN9PPGL7sBfKv7QxfNZInX7njZ38EZ22CGXFsSxTmlQ6H7UAFQx23HjdvllwVaUq6 OolN/rppQYj8HKC4Vdyh5+cx4RuB0CvubGZyVOxE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vamshi K Sthambamkadi , David Laight , Ard Biesheuvel , Sasha Levin Subject: [PATCH 4.14 38/50] efivarfs: revert "fix memory leak in efivarfs_create()" Date: Tue, 1 Dec 2020 09:53:37 +0100 Message-Id: <20201201084649.724315321@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201084644.803812112@linuxfoundation.org> References: <20201201084644.803812112@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: Ard Biesheuvel [ Upstream commit ff04f3b6f2e27f8ae28a498416af2a8dd5072b43 ] The memory leak addressed by commit fe5186cf12e3 is a false positive: all allocations are recorded in a linked list, and freed when the filesystem is unmounted. This leads to double frees, and as reported by David, leads to crashes if SLUB is configured to self destruct when double frees occur. So drop the redundant kfree() again, and instead, mark the offending pointer variable so the allocation is ignored by kmemleak. Cc: Vamshi K Sthambamkadi Fixes: fe5186cf12e3 ("efivarfs: fix memory leak in efivarfs_create()") Reported-by: David Laight Signed-off-by: Ard Biesheuvel Signed-off-by: Sasha Levin --- fs/efivarfs/inode.c | 2 ++ fs/efivarfs/super.c | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/efivarfs/inode.c b/fs/efivarfs/inode.c index 71fccccf317e8..5decb3e06563f 100644 --- a/fs/efivarfs/inode.c +++ b/fs/efivarfs/inode.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -104,6 +105,7 @@ static int efivarfs_create(struct inode *dir, struct dentry *dentry, var->var.VariableName[i] = '\0'; inode->i_private = var; + kmemleak_ignore(var); err = efivar_entry_add(var, &efivarfs_list); if (err) diff --git a/fs/efivarfs/super.c b/fs/efivarfs/super.c index 7808a26bd33fa..834615f13f3e3 100644 --- a/fs/efivarfs/super.c +++ b/fs/efivarfs/super.c @@ -23,7 +23,6 @@ LIST_HEAD(efivarfs_list); static void efivarfs_evict_inode(struct inode *inode) { clear_inode(inode); - kfree(inode->i_private); } static const struct super_operations efivarfs_ops = { -- 2.27.0