public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ext3: return FSID for statvfs
@ 2005-12-06 20:23 Pekka Enberg
  2005-12-07 12:40 ` Andreas Dilger
  0 siblings, 1 reply; 5+ messages in thread
From: Pekka Enberg @ 2005-12-06 20:23 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, sct, adilger

This patch changes ext3_statfs() to return a FSID based on least significant
64-bits of the 128-bit filesystem UUID. This patch is a partial fix for
Bugzilla Bug <http://bugzilla.kernel.org/show_bug.cgi?id=136>.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
---

 super.c |    2 ++
 1 file changed, 2 insertions(+)

Index: 2.6/fs/ext3/super.c
===================================================================
--- 2.6.orig/fs/ext3/super.c
+++ 2.6/fs/ext3/super.c
@@ -2340,6 +2340,8 @@ static int ext3_statfs (struct super_blo
 	buf->f_files = le32_to_cpu(es->s_inodes_count);
 	buf->f_ffree = ext3_count_free_inodes (sb);
 	buf->f_namelen = EXT3_NAME_LEN;
+	buf->f_fsid.val[0] = le32_to_cpup((void *)es->s_uuid);
+	buf->f_fsid.val[1] = le32_to_cpup((void *)es->s_uuid + sizeof(u32));
 	return 0;
 }
 



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

* Re: [PATCH] ext3: return FSID for statvfs
  2005-12-06 20:23 [PATCH] ext3: return FSID for statvfs Pekka Enberg
@ 2005-12-07 12:40 ` Andreas Dilger
  2005-12-07 13:13   ` Pekka J Enberg
  0 siblings, 1 reply; 5+ messages in thread
From: Andreas Dilger @ 2005-12-07 12:40 UTC (permalink / raw)
  To: Pekka Enberg; +Cc: akpm, linux-kernel, sct

On Dec 06, 2005  22:23 +0200, Pekka Enberg wrote:
> This patch changes ext3_statfs() to return a FSID based on least significant
> 64-bits of the 128-bit filesystem UUID. This patch is a partial fix for
> Bugzilla Bug <http://bugzilla.kernel.org/show_bug.cgi?id=136>.

The bug mentions some reasons why this patch is sub-optimal - namely that
the beginning of the UUID has common fields in it.  It may make more sense
to e.g. XOR the first 2 * u32 with the last 2 * u32 to reduce the chance
of an FSID collision.

Also, there is a tiny memory of a security issue with exposing the FSID
to applications (something to do with NFS and guessing filehandles or
similar).  I have no idea if that is even relevant any longer, but
thought I'd mention it.

> @@ -2340,6 +2340,8 @@ static int ext3_statfs (struct super_blo
>  	buf->f_files = le32_to_cpu(es->s_inodes_count);
>  	buf->f_ffree = ext3_count_free_inodes (sb);
>  	buf->f_namelen = EXT3_NAME_LEN;
> +	buf->f_fsid.val[0] = le32_to_cpup((void *)es->s_uuid);
> +	buf->f_fsid.val[1] = le32_to_cpup((void *)es->s_uuid + sizeof(u32));
>  	return 0;
>  }
>  

Cheers, Andreas
--
Andreas Dilger
Principal Software Engineer
Cluster File Systems, Inc.


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

* Re: [PATCH] ext3: return FSID for statvfs
  2005-12-07 12:40 ` Andreas Dilger
@ 2005-12-07 13:13   ` Pekka J Enberg
  2005-12-07 20:01     ` Andreas Dilger
  0 siblings, 1 reply; 5+ messages in thread
From: Pekka J Enberg @ 2005-12-07 13:13 UTC (permalink / raw)
  To: Andreas Dilger; +Cc: akpm, linux-kernel, sct

Hi Andreas,

On Wed, 7 Dec 2005, Andreas Dilger wrote:
> The bug mentions some reasons why this patch is sub-optimal - namely that
> the beginning of the UUID has common fields in it.  It may make more sense
> to e.g. XOR the first 2 * u32 with the last 2 * u32 to reduce the chance
> of an FSID collision.
> 
> Also, there is a tiny memory of a security issue with exposing the FSID
> to applications (something to do with NFS and guessing filehandles or
> similar).  I have no idea if that is even relevant any longer, but
> thought I'd mention it.

Something like this?

This patch changes ext3_statfs() to return a FSID based on 64 bit XOR of the
128 bit filesystem UUID as suggested by Andreas Dilger. This patch is partial
fix for Bugzilla Bug <http://bugzilla.kernel.org/show_bug.cgi?id=136>.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
---

 super.c |    5 +++++
 1 file changed, 5 insertions(+)

Index: 2.6/fs/ext3/super.c
===================================================================
--- 2.6.orig/fs/ext3/super.c
+++ 2.6/fs/ext3/super.c
@@ -2294,6 +2294,7 @@ static int ext3_statfs (struct super_blo
 	struct ext3_super_block *es = EXT3_SB(sb)->s_es;
 	unsigned long overhead;
 	int i;
+	u64 fsid;
 
 	if (test_opt (sb, MINIX_DF))
 		overhead = 0;
@@ -2340,6 +2341,10 @@ static int ext3_statfs (struct super_blo
 	buf->f_files = le32_to_cpu(es->s_inodes_count);
 	buf->f_ffree = ext3_count_free_inodes (sb);
 	buf->f_namelen = EXT3_NAME_LEN;
+	fsid = le64_to_cpup((void *)es->s_uuid) ^
+	       le64_to_cpup((void *)es->s_uuid + sizeof(u64));
+	buf->f_fsid.val[0] = fsid & 0xFFFFFFFFUL;
+	buf->f_fsid.val[1] = (fsid >> 32) & 0xFFFFFFFFUL;
 	return 0;
 }
 

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

* Re: [PATCH] ext3: return FSID for statvfs
  2005-12-07 13:13   ` Pekka J Enberg
@ 2005-12-07 20:01     ` Andreas Dilger
  2005-12-08  7:28       ` Pekka J Enberg
  0 siblings, 1 reply; 5+ messages in thread
From: Andreas Dilger @ 2005-12-07 20:01 UTC (permalink / raw)
  To: Pekka J Enberg; +Cc: akpm, linux-kernel, sct

On Dec 07, 2005  15:13 +0200, Pekka J Enberg wrote:
> On Wed, 7 Dec 2005, Andreas Dilger wrote:
> > The bug mentions some reasons why this patch is sub-optimal - namely that
> > the beginning of the UUID has common fields in it.  It may make more sense
> > to e.g. XOR the first 2 * u32 with the last 2 * u32 to reduce the chance
> > of an FSID collision.
> 
> This patch changes ext3_statfs() to return a FSID based on 64 bit XOR of the
> 128 bit filesystem UUID as suggested by Andreas Dilger. This patch is partial
> fix for Bugzilla Bug <http://bugzilla.kernel.org/show_bug.cgi?id=136>.

That seems at least slightly better, as it involves all the bits.  

Question - what is rule for "Signed-off-by:"?  I'm hesitant to add that if
I haven't actually compiled+tested a fix, as I've seen too many instances
of "obvious fix contains bug" to believe visual inspection is enough.  If
"Signed-off-by:" simply indicates "Yes, this person approves of the change
in principle" then that's OK by me.  Andrew, do you use the "CC" tag for
that?

> Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
> ---
> 
>  super.c |    5 +++++
>  1 file changed, 5 insertions(+)
> 
> Index: 2.6/fs/ext3/super.c
> ===================================================================
> --- 2.6.orig/fs/ext3/super.c
> +++ 2.6/fs/ext3/super.c
> @@ -2294,6 +2294,7 @@ static int ext3_statfs (struct super_blo
>  	struct ext3_super_block *es = EXT3_SB(sb)->s_es;
>  	unsigned long overhead;
>  	int i;
> +	u64 fsid;
>  
>  	if (test_opt (sb, MINIX_DF))
>  		overhead = 0;
> @@ -2340,6 +2341,10 @@ static int ext3_statfs (struct super_blo
>  	buf->f_files = le32_to_cpu(es->s_inodes_count);
>  	buf->f_ffree = ext3_count_free_inodes (sb);
>  	buf->f_namelen = EXT3_NAME_LEN;
> +	fsid = le64_to_cpup((void *)es->s_uuid) ^
> +	       le64_to_cpup((void *)es->s_uuid + sizeof(u64));
> +	buf->f_fsid.val[0] = fsid & 0xFFFFFFFFUL;
> +	buf->f_fsid.val[1] = (fsid >> 32) & 0xFFFFFFFFUL;
>  	return 0;
>  }
>  

Cheers, Andreas
--
Andreas Dilger
Principal Software Engineer
Cluster File Systems, Inc.


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

* Re: [PATCH] ext3: return FSID for statvfs
  2005-12-07 20:01     ` Andreas Dilger
@ 2005-12-08  7:28       ` Pekka J Enberg
  0 siblings, 0 replies; 5+ messages in thread
From: Pekka J Enberg @ 2005-12-08  7:28 UTC (permalink / raw)
  To: Andreas Dilger; +Cc: akpm, linux-kernel, sct

On Wed, 7 Dec 2005, Andreas Dilger wrote:
> Question - what is rule for "Signed-off-by:"?  I'm hesitant to add that if
> I haven't actually compiled+tested a fix, as I've seen too many instances
> of "obvious fix contains bug" to believe visual inspection is enough.  If
> "Signed-off-by:" simply indicates "Yes, this person approves of the change
> in principle" then that's OK by me.  Andrew, do you use the "CC" tag for
> that?

I think signed-off is only used when you either (1) change the patch or 
(2) pass it forward. I have seen people use "Acked-by:" for what you seem 
to want to do here.

FWIW, I have tested the patch with UML.

			Pekka

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

end of thread, other threads:[~2005-12-08  7:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-06 20:23 [PATCH] ext3: return FSID for statvfs Pekka Enberg
2005-12-07 12:40 ` Andreas Dilger
2005-12-07 13:13   ` Pekka J Enberg
2005-12-07 20:01     ` Andreas Dilger
2005-12-08  7:28       ` Pekka J Enberg

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