Re: [PATCH] ext3: return FSID for statvfs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <[email protected]>
---

 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;
 }
 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux