From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753450AbdASPyV (ORCPT ); Thu, 19 Jan 2017 10:54:21 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:56232 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753019AbdASPyU (ORCPT ); Thu, 19 Jan 2017 10:54:20 -0500 Date: Thu, 19 Jan 2017 16:53:45 +0100 From: Greg Kroah-Hartman To: Omar Sandoval Cc: linux-kernel@vger.kernel.org, Jiri Kosina Subject: Re: debugfs vs. device removal Message-ID: <20170119155345.GA11660@kroah.com> References: <20170119154841.GA6416@vader> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170119154841.GA6416@vader> User-Agent: Mutt/1.7.2 (2016-11-26) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 19, 2017 at 07:48:41AM -0800, Omar Sandoval wrote: > Hi, > > In the block layer, we abuse sysfs to export some per-device debugging > information. I was looking into moving this to debugfs, but I realized > that debugfs doesn't have a mechanism to ensure that a file associated > with a device is safe to use when the device is removed. What do you mean by "safe"? The race conditions where you remove a file and still have it open should all now be resolved in 4.8 and 4.9, di dwe miss something? > At a quick glance, HID has some per-device information in debugfs. > However, I don't see any sort of protection against a device being > removed. I was easily able to trigger an oops by reading from > /sys/kernel/debug/hid/*/rdesc in a loop and removing the USB device > (trace attached). > > How can I safely export per-device debugging information to debugfs? Try 4.9 and see if you can still reproduce this, it should be fixed. If not, we might have forgotten to include the .owner field for the hid debugfs file... thanks, greg k-h