From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2FBDEC433ED for ; Sun, 4 Apr 2021 10:09:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EA02461380 for ; Sun, 4 Apr 2021 10:09:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230244AbhDDKIN (ORCPT ); Sun, 4 Apr 2021 06:08:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:50892 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229578AbhDDKIL (ORCPT ); Sun, 4 Apr 2021 06:08:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D0ED6610CB; Sun, 4 Apr 2021 10:08:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617530885; bh=YyFWNQbFjzqQMXREpTHaLfKBIJsSJScF8WfbAhO4hJo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=reXhkqEHty7WHp9aNF6kuyLl339Ua3ZUmBohwVFOpOXewmXA1eHXdg2uu4zN71AgE gxUrXsfLBAJlvgXLUHtqOxDFMMIG4jYWew1MWArbu0zf2HahwaOzdiM4cF4nRYAB0k Wj7xrumCgiVReGYhXnQj+h71zuM8P7K6XTvHcct8= Date: Sun, 4 Apr 2021 12:08:01 +0200 From: Greg Kroah-Hartman To: Samuel Holland Cc: "Rafael J. Wysocki" , Arend van Spriel , linux-kernel@vger.kernel.org Subject: Re: [PATCH] debugfs: Fix use-after-free in debugfs_create_devm_seqfile() Message-ID: References: <20210404004504.5547-1-samuel@sholland.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210404004504.5547-1-samuel@sholland.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Apr 03, 2021 at 07:45:04PM -0500, Samuel Holland wrote: > This function uses devres to clean up its allocation, but it never removes the > file referencing that allocation. This causes a use-after-free and an oops if > the file is accessed after the owning device is removed. What in-kernel user of this is having this problem? The driver should clean up the debugfs file, it is not the debugfs core's job to auto-remove the file. The resource is what is being cleaned up by the devm usage in debugfs, that's all, not the file. Please fix up the driver that is creating the file but then not removing it. thanks, greg k-h