linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] block: initialise bd_super in bdget()
@ 2011-06-30  1:01 Lachlan McIlroy
  2011-06-30 20:12 ` Eric Sandeen
  0 siblings, 1 reply; 2+ messages in thread
From: Lachlan McIlroy @ 2011-06-30  1:01 UTC (permalink / raw)
  To: Alexander Viro; +Cc: linux-fsdevel, linux-kernel, Lachlan McIlroy

bd_super is currently reset to NULL in kill_block_super() so we rely on previous
users of the block_device object to initialise this value for the next user.
This quirk was exposed on RHEL5 when a third party filesystem did not always use
kill_block_super() and therefore bd_super wasn't being reset when a block_device
object was recycled within the cache.  This may not be a problem upstream but
makes sense to be defensive.

Signed-off-by: Lachlan McIlroy <lmcilroy@redhat.com>
---
 fs/block_dev.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 610e8e0..2b0dc33 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -547,6 +547,7 @@ struct block_device *bdget(dev_t dev)
 
 	if (inode->i_state & I_NEW) {
 		bdev->bd_contains = NULL;
+		bdev->bd_super = NULL;
 		bdev->bd_inode = inode;
 		bdev->bd_block_size = (1 << inode->i_blkbits);
 		bdev->bd_part_count = 0;
-- 
1.7.2.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/1] block: initialise bd_super in bdget()
  2011-06-30  1:01 [PATCH 1/1] block: initialise bd_super in bdget() Lachlan McIlroy
@ 2011-06-30 20:12 ` Eric Sandeen
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Sandeen @ 2011-06-30 20:12 UTC (permalink / raw)
  To: Lachlan McIlroy; +Cc: Alexander Viro, linux-fsdevel, linux-kernel

On 6/29/11 8:01 PM, Lachlan McIlroy wrote:
> bd_super is currently reset to NULL in kill_block_super() so we rely on previous
> users of the block_device object to initialise this value for the next user.
> This quirk was exposed on RHEL5 when a third party filesystem did not always use
> kill_block_super() and therefore bd_super wasn't being reset when a block_device
> object was recycled within the cache.  This may not be a problem upstream but
> makes sense to be defensive.
> 
> Signed-off-by: Lachlan McIlroy <lmcilroy@redhat.com>
> ---

This seems reasonable to me, I think it's dangerous to assume the prior user
will "put it away" properly.

blkdev_releasepage() then may try to deref it and go boom, without this
explicit initialization.

And there is already other initialization in bdget()...

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

>  fs/block_dev.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/fs/block_dev.c b/fs/block_dev.c
> index 610e8e0..2b0dc33 100644
> --- a/fs/block_dev.c
> +++ b/fs/block_dev.c
> @@ -547,6 +547,7 @@ struct block_device *bdget(dev_t dev)
>  
>  	if (inode->i_state & I_NEW) {
>  		bdev->bd_contains = NULL;
> +		bdev->bd_super = NULL;
>  		bdev->bd_inode = inode;
>  		bdev->bd_block_size = (1 << inode->i_blkbits);
>  		bdev->bd_part_count = 0;


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-06-30 20:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-30  1:01 [PATCH 1/1] block: initialise bd_super in bdget() Lachlan McIlroy
2011-06-30 20:12 ` Eric Sandeen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).