lkml.org 
[lkml]   [2021]   [Sep]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.4 080/144] debugfs: Return error during {full/open}_proxy_open() on rmmod
    Date
    From: Sven Eckelmann <sven@narfation.org>

    [ Upstream commit 112cedc8e600b668688eb809bf11817adec58ddc ]

    If a kernel module gets unloaded then it printed report about a leak before
    commit 275678e7a9be ("debugfs: Check module state before warning in
    {full/open}_proxy_open()"). An additional check was added in this commit to
    avoid this printing. But it was forgotten that the function must return an
    error in this case because it was not actually opened.

    As result, the systems started to crash or to hang when a module was
    unloaded while something was trying to open a file.

    Fixes: 275678e7a9be ("debugfs: Check module state before warning in {full/open}_proxy_open()")
    Cc: Taehee Yoo <ap420073@gmail.com>
    Reported-by: Mário Lopes <ml@simonwunderlich.de>
    Signed-off-by: Sven Eckelmann <sven@narfation.org>
    Link: https://lore.kernel.org/r/20210802162444.7848-1-sven@narfation.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    fs/debugfs/file.c | 8 ++++++--
    1 file changed, 6 insertions(+), 2 deletions(-)

    diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
    index 943637298f65..a32c5c7dcfd8 100644
    --- a/fs/debugfs/file.c
    +++ b/fs/debugfs/file.c
    @@ -178,8 +178,10 @@ static int open_proxy_open(struct inode *inode, struct file *filp)
    if (!fops_get(real_fops)) {
    #ifdef CONFIG_MODULES
    if (real_fops->owner &&
    - real_fops->owner->state == MODULE_STATE_GOING)
    + real_fops->owner->state == MODULE_STATE_GOING) {
    + r = -ENXIO;
    goto out;
    + }
    #endif

    /* Huh? Module did not clean up after itself at exit? */
    @@ -313,8 +315,10 @@ static int full_proxy_open(struct inode *inode, struct file *filp)
    if (!fops_get(real_fops)) {
    #ifdef CONFIG_MODULES
    if (real_fops->owner &&
    - real_fops->owner->state == MODULE_STATE_GOING)
    + real_fops->owner->state == MODULE_STATE_GOING) {
    + r = -ENXIO;
    goto out;
    + }
    #endif

    /* Huh? Module did not cleanup after itself at exit? */
    --
    2.30.2


    \
     
     \ /
      Last update: 2021-09-13 15:23    [W:4.276 / U:0.044 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site