public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH linux-next] befs: befs_fill_super(): remove unreachable code
@ 2013-02-12 17:34 Tim Gardner
  2013-02-12 17:46 ` Eric W. Biederman
  0 siblings, 1 reply; 3+ messages in thread
From: Tim Gardner @ 2013-02-12 17:34 UTC (permalink / raw)
  To: linux-kernel
  Cc: Tim Gardner, Al Viro, Andrew Morton, Eric W. Biederman,
	Kirill A. Shutemov

befs_sb->num_blocks is of base type u64 which is the same as sector_t.
Therefore, num_blocks can never be larger then the maximum
value of sector_t.

smatch analysis:

fs/befs/linuxvfs.c:851 befs_fill_super() warn: impossible
 condition '(befs_sb->num_blocks > ~(0)) => (0-u64max > u64max)'

Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
---
 fs/befs/linuxvfs.c |    7 -------
 1 file changed, 7 deletions(-)

diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index 2b3bda8..2ce5705 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -848,13 +848,6 @@ befs_fill_super(struct super_block *sb, void *data, int silent)
 	if (befs_check_sb(sb) != BEFS_OK)
 		goto unacquire_priv_sbp;
 
-	if( befs_sb->num_blocks > ~((sector_t)0) ) {
-		befs_error(sb, "blocks count: %Lu "
-			"is larger than the host can use",
-			befs_sb->num_blocks);
-		goto unacquire_priv_sbp;
-	}
-
 	/*
 	 * set up enough so that it can read an inode
 	 * Fill in kernel superblock fields from private sb
-- 
1.7.9.5


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

* Re: [PATCH linux-next] befs: befs_fill_super(): remove unreachable code
  2013-02-12 17:34 [PATCH linux-next] befs: befs_fill_super(): remove unreachable code Tim Gardner
@ 2013-02-12 17:46 ` Eric W. Biederman
  2013-02-12 18:07   ` Tim Gardner
  0 siblings, 1 reply; 3+ messages in thread
From: Eric W. Biederman @ 2013-02-12 17:46 UTC (permalink / raw)
  To: Tim Gardner; +Cc: linux-kernel, Al Viro, Andrew Morton, Kirill A. Shutemov

Tim Gardner <tim.gardner@canonical.com> writes:

> befs_sb->num_blocks is of base type u64 which is the same as sector_t.
> Therefore, num_blocks can never be larger then the maximum
> value of sector_t.

The analysys is wrong.  On 32bit with CONFIG_LBAF unset sector_t is an
unsigned long aka a u32, while befs_off_t is always a u64.

Nacked-by: "Eric W. Biederman" <ebiederm@xmission.com>

> smatch analysis:
>
> fs/befs/linuxvfs.c:851 befs_fill_super() warn: impossible
>  condition '(befs_sb->num_blocks > ~(0)) => (0-u64max > u64max)'
>
> Cc: Al Viro <viro@zeniv.linux.org.uk>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: "Eric W. Biederman" <ebiederm@xmission.com>
> Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
> ---
>  fs/befs/linuxvfs.c |    7 -------
>  1 file changed, 7 deletions(-)
>
> diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
> index 2b3bda8..2ce5705 100644
> --- a/fs/befs/linuxvfs.c
> +++ b/fs/befs/linuxvfs.c
> @@ -848,13 +848,6 @@ befs_fill_super(struct super_block *sb, void *data, int silent)
>  	if (befs_check_sb(sb) != BEFS_OK)
>  		goto unacquire_priv_sbp;
>  
> -	if( befs_sb->num_blocks > ~((sector_t)0) ) {
> -		befs_error(sb, "blocks count: %Lu "
> -			"is larger than the host can use",
> -			befs_sb->num_blocks);
> -		goto unacquire_priv_sbp;
> -	}
> -
>  	/*
>  	 * set up enough so that it can read an inode
>  	 * Fill in kernel superblock fields from private sb

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

* Re: [PATCH linux-next] befs: befs_fill_super(): remove unreachable code
  2013-02-12 17:46 ` Eric W. Biederman
@ 2013-02-12 18:07   ` Tim Gardner
  0 siblings, 0 replies; 3+ messages in thread
From: Tim Gardner @ 2013-02-12 18:07 UTC (permalink / raw)
  To: Eric W. Biederman
  Cc: linux-kernel, Al Viro, Andrew Morton, Kirill A. Shutemov

On 02/12/2013 10:46 AM, Eric W. Biederman wrote:
> Tim Gardner <tim.gardner@canonical.com> writes:
> 
>> befs_sb->num_blocks is of base type u64 which is the same as sector_t.
>> Therefore, num_blocks can never be larger then the maximum
>> value of sector_t.
> 
> The analysys is wrong.  On 32bit with CONFIG_LBAF unset sector_t is an
> unsigned long aka a u32, while befs_off_t is always a u64.
> 
> Nacked-by: "Eric W. Biederman" <ebiederm@xmission.com>

Dang - you're right.

-- 
Tim Gardner tim.gardner@canonical.com

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

end of thread, other threads:[~2013-02-12 18:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-12 17:34 [PATCH linux-next] befs: befs_fill_super(): remove unreachable code Tim Gardner
2013-02-12 17:46 ` Eric W. Biederman
2013-02-12 18:07   ` Tim Gardner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox