Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp6572148pxb; Wed, 17 Feb 2021 07:54:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJyCViJDGKbzs7NrkWBgWYj/lZTKy+2IDFjDr9LtCCmSQrslJY8Y3Aia1HzjbQaS2XP3v90V X-Received: by 2002:a17:906:4bc2:: with SMTP id x2mr26733347ejv.143.1613577279283; Wed, 17 Feb 2021 07:54:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613577279; cv=none; d=google.com; s=arc-20160816; b=azVn9GVnOz+/a4spSN18KUYFG2WyTfYplBcCv4RKqiB0VZSdFS2Bm9tM0W/rR/tuaz pAJYREM97pdI9WQoSHHFhRYeXhqd4SDGKoP1b4ARxXo+lLUbtMuw+Zz7d5qFvdYw7+r3 awWeSPhPVNvTPuk1ZDY4CFNUVrB9M8eKHiJsO155s4DhE+AzKZdwzkiGRY98KF6fQCYV IMEHek9VKAYPTWS5vgbdrEwZUco/gouABHpaUtrIdEZoanhdqZyS2zu9BZPb8+JvL1nN ruKjJAE5TFqm1I8tZ9sQhGaZ69EdjD4eFwY719nlzZA6fmXO7Zu39KhS53SDUT6bji3E YpJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=vyIz6XzbeaNCCfCuuD+2mwRTt6br0jc9ZpAqiPSLHBI=; b=X4SB/IdvhFgh8LKR6Nkl+HCmb5NLU/Kj857d8xwnJM2g+1AMt7G8X7c+vu/49HWmCH qtT0XWhTpIaRdgxW2Ww4Yd1hMY3Ypg/cCEmVhUnr4FkWO5ak1ZQBcwkGelGk7ADVvJSR RmUAFhguLX8cdf6+SR6J9RGq2syXaxtbPtwEeJOckAsSq626JEupJU8h6G+aLTUYYt3m bb0CLc+O7oM2/9avopkw1pJRbq8RG5h+kRuQiXWgghvvs5E00O8tCtgvzmQ3w9lHsp7u IhDWTmHqFzho1LEz7RSYp44oZNescOp7FACiSJWXZ+XXyoXzE8ISmcGm3ZNLceKk9KAR JtJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chrisdown.name header.s=google header.b="fdm/+1aA"; 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=chrisdown.name Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y7si66117ejm.72.2021.02.17.07.54.13; Wed, 17 Feb 2021 07:54:39 -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=@chrisdown.name header.s=google header.b="fdm/+1aA"; 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=chrisdown.name Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233645AbhBQPu5 (ORCPT + 99 others); Wed, 17 Feb 2021 10:50:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233634AbhBQPug (ORCPT ); Wed, 17 Feb 2021 10:50:36 -0500 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49FD1C0613D6 for ; Wed, 17 Feb 2021 07:49:56 -0800 (PST) Received: by mail-wm1-x32d.google.com with SMTP id v62so4050005wmg.4 for ; Wed, 17 Feb 2021 07:49:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisdown.name; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=vyIz6XzbeaNCCfCuuD+2mwRTt6br0jc9ZpAqiPSLHBI=; b=fdm/+1aAXgcX3VNEVSWNSNwU5smLpnydMyFDodUCVHoapRhjtEnrMuU2y8HZcghVSK /gqhQSKX3EFMKrdoY3t5ivRhZUxmbUjk9nvA3AqXtXUmenp3ewzLt8ahJlm+2/Do/cut Ao8rfCh4p72EwVvbkTxjIYEdiJcp+1BHN3ais= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=vyIz6XzbeaNCCfCuuD+2mwRTt6br0jc9ZpAqiPSLHBI=; b=T+tWxTF5SSiPbt6f0C6X8uegVfw2LJFekvOWw4CQy5cQXG8AO4/88CmyDkiM77Qlj8 1Ma/U494RUwvIOYfnUxZtMhUpa0oNyrncf2fXW+3zU9PPgkq4CzHAMwtTL5nj8TxwMnz 1NFafcbyB503yAKCy7ze4PdhNlKPErYn4Qsr2aB6JramtO8skpUeaD812vxX++yvrKMw P73xrBqECQ8FEVSbyoEL8vSshuIhGE9+lz8JwIzFwx0IZ6wCd8MG+0/czv0fVy64cdIe ph+5QWH3GtM5KwaD8WVdGF2h+iEgxTX2kRC7npehxJWD9G2wZNergsGWADdYOYIGVnqS vQeg== X-Gm-Message-State: AOAM531+O44muoN3tqV22XXYW1rm0Mav6XHeIyov9qb8jXRzDKVPUVmH udiFCR2VGN5vZlUNx1PaHHgTBg== X-Received: by 2002:a1c:bcc3:: with SMTP id m186mr7543013wmf.165.1613576994841; Wed, 17 Feb 2021 07:49:54 -0800 (PST) Received: from localhost ([2620:10d:c093:400::4:76fd]) by smtp.gmail.com with ESMTPSA id v204sm3622000wmg.38.2021.02.17.07.49.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Feb 2021 07:49:54 -0800 (PST) Date: Wed, 17 Feb 2021 15:49:54 +0000 From: Chris Down To: Petr Mladek Cc: linux-kernel@vger.kernel.org, Sergey Senozhatsky , John Ogness , Johannes Weiner , Andrew Morton , Steven Rostedt , Greg Kroah-Hartman , Kees Cook , kernel-team@fb.com Subject: Re: debugfs: was: Re: [PATCH v4] printk: Userspace format enumeration support Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: Mutt/2.0.5 (da5e3282) (2021-01-21) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Petr Mladek writes: >> > > + debugfs_remove(ps->file); >> > >> > IMHO, we should remove the file before we remove the way how >> > to read it. This should be done in the opposite order >> > than in store_printk_fmt_sec(). >> >> There is a subtle issue with doing this as-is: debugfs_remove(ps->file) >> cannot be called under printk_fmts_mutex, because we may deadlock due to a >> pinned debugfs refcnt if debugfs_remove() and _show happen at the same time. > >Do we need to call debugfs_remove(ps->file) under printk_fmts_mutex? Ah, my concern was simultaneous entries into remove_printk_fmt_sec (which would require setting a separate flag under the mutex), but now I think about it, the module notifier synchronously waits, so that can't happen anyway. As such it should be safe to just do: remove() { mutex_lock(&printk_fmts_mutex); ps = find_printk_fmt_sec(); mutex_unlock(&printk_fmts_mutex); if (!ps) return; /* waits for _show */ debugfs_remove(ps->file); mutex_lock(&printk_fmts_mutex); /* Do the data structure teardown */ mutex_unlock(&printk_fmts_mutex); } Sounds good to me, I'll do that for v5. Thanks! :-)