lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Mon, 18 Mar 2019 08:21:39 -0600
From:   Jens Axboe <axboe@...nel.dk>
To:     Dongli Zhang <dongli.zhang@...cle.com>, linux-block@...r.kernel.org
Cc:     linux-kernel@...r.kernel.org, jack@...e.cz,
        penguin-kernel@...ove.sakura.ne.jp
Subject: Re: [PATCH 1/1] loop: access lo_backing_file only when the loop
 device is Lo_bound

On 3/18/19 6:23 AM, Dongli Zhang wrote:
> Commit 758a58d0bc67 ("loop: set GENHD_FL_NO_PART_SCAN after
> blkdev_reread_part()") separates "lo->lo_backing_file = NULL" and
> "lo->lo_state = Lo_unbound" into different critical regions protected by
> loop_ctl_mutex.
> 
> However, there is below race that the NULL lo->lo_backing_file would be
> accessed when the backend of a loop is another loop device, e.g., loop0's
> backend is a file, while loop1's backend is loop0.
> 
> loop0's backend is file            loop1's backend is loop0
> 
> __loop_clr_fd()
>   mutex_lock(&loop_ctl_mutex);
>   lo->lo_backing_file = NULL; --> set to NULL
>   mutex_unlock(&loop_ctl_mutex);
>                                    loop_set_fd()
>                                      mutex_lock_killable(&loop_ctl_mutex);
>                                      loop_validate_file()
>                                        f = l->lo_backing_file; --> NULL
>                                          access if loop0 is not Lo_unbound
>   mutex_lock(&loop_ctl_mutex);
>   lo->lo_state = Lo_unbound;
>   mutex_unlock(&loop_ctl_mutex);
> 
> lo->lo_backing_file should be accessed only when the loop device is
> Lo_bound.
> 
> In fact, the problem has been introduced already in commit 7ccd0791d985
> ("loop: Push loop_ctl_mutex down into loop_clr_fd()") after which
> loop_validate_file() could see devices in Lo_rundown state with which it
> did not count. It was harmless at that point but still.

Thanks, applied.

-- 
Jens Axboe

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ