exofs: fix endian conversion in exofs_sync_fs()
PATCH 1/1 exofs: fix endian conversion in exofs_sync_fs()
fscb->s_numfiles is an __le64 field so we need to use cpu_to_le64() to get a little endian 64 bit on big endian systems.
---
This is a static checker fix. Untested.
fs/exofs/super.c +1 -1
@@ -390,7 +390,7 @@ static int exofs_sync_fs(struct super_block *sb, int wait) ios->length = offsetof(struct exofs_fscb , s_dev_table_oid);memset (fscb,0 , ios->length); fscb->s_nextid =cpu_to_le64 (sbi->s_nextid); - fscb->s_numfiles =cpu_to_le32 (sbi->s_numfiles); + fscb->s_numfiles =cpu_to_le64 (sbi->s_numfiles); fscb->s_magic =cpu_to_le16 (sb->s_magic); fscb->s_newfs =0 ; fscb->s_version =EXOFS_FSCB_VER ;
Quoted 7 lines · Dan Carpenter
fscb->s_numfilesis an__le64field so we need to usecpu_to_le64()to get a little endian 64 bit on big endian systems.Signed-off-by Dan Carpenter <[email protected]>---
This is a static checker fix. Untested.
Will apply. s_numfiles is never used but should be loaded correctly regardless.
Thanks
Boaz
Quoted 13 lines
fs/exofs/super.c +1
-1@@ -390,7 +390,7 @@ static int exofs_sync_fs(struct super_block *sb, int wait) ios->length = offsetof(struct exofs_fscb , s_dev_table_oid);memset (fscb,0 , ios->length); fscb->s_nextid =cpu_to_le64 (sbi->s_nextid); - fscb->s_numfiles =cpu_to_le32 (sbi->s_numfiles); + fscb->s_numfiles =cpu_to_le64 (sbi->s_numfiles); fscb->s_magic =cpu_to_le16 (sb->s_magic); fscb->s_newfs =0 ; fscb->s_version =EXOFS_FSCB_VER ;
Quoted 4 lines · Boaz Harrosh
Quoted 3 lines · Dan Carpenter
fscb->s_numfilesis an__le64field so we need to usecpu_to_le64()to get a little endian 64 bit on big endian systems.
Quoted 8 lines
Quoted 4 lines
Signed-off-by Dan Carpenter <[email protected]>---
This is a static checker fix. Untested.Will apply.
s_numfilesis never used but should be loaded correctly regardless.
This is still the same in linux-next.
regards,
dan carpenter
Quoted 10 lines · Dan Carpenter
Quoted 9 lines · Boaz Harrosh
Quoted 7 lines · Dan Carpenter
fscb->s_numfilesis an__le64field so we need to usecpu_to_le64()to get a little endian 64 bit on big endian systems.Signed-off-by Dan Carpenter <[email protected]>---
This is a static checker fix. Untested.
Quoted 5 lines
Quoted 3 lines
Will apply.
s_numfilesis never used but should be loaded correctly regardless.This is still the same in linux-next.
Also Sparse warns about the following potential stack overflows. The kernel has an 8k stack and the upper limit on these array sizes are not capped.
fs/exofs/super.c:562:51: error: bad constant expression fs/exofs/super.c:563:38: error: bad constant expression
regards,
dan carpenter
Quoted 11 lines · Dan Carpenter
Quoted 10 lines · Dan Carpenter
Quoted 9 lines · Boaz Harrosh
Quoted 7 lines · Dan Carpenter
fscb->s_numfilesis an__le64field so we need to usecpu_to_le64()to get a little endian 64 bit on big endian systems.Signed-off-by Dan Carpenter <[email protected]>---
This is a static checker fix. Untested.
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
Will apply.
s_numfilesis never used but should be loaded correctly regardless.This is still the same in linux-next.
Sorry will fix.
Quoted 7 lines
Also Sparse warns about the following potential stack overflows. The kernel has an 8k stack and the upper limit on these array sizes are not capped.
fs/exofs/super.c:562:51: error: bad constant expressionfs/exofs/super.c:563:38: error: bad constant expression
Do you mean this code:
struct __alloc_ore_devs_and_exofs_devs {
/* Twice bigger table: See exofs_init_comps() and comment at
* exofs_read_lookup_dev_table()
*/
=> struct ore_dev *oreds[numdevs * 2 - 1];
=> struct exofs_dev eds[numdevs];
} *aoded;If so than Sparse should be fixed. It is plain wrong. This complete structure is kmalloc(ed) two lines below.
The only limit is, perhaps, the entire struct should not be bigger than PAGE_SIZE but kmalloc would fail and we will not mount. That code is fine
Quoted 2 lines
regards,
dan carpenter
Cheers
Boaz
Quoted 10 lines · Boaz Harrosh
Do you mean this code:
struct __alloc_ore_devs_and_exofs_devs { /* Twice bigger table: See exofs_init_comps() and comment at * exofs_read_lookup_dev_table() */ => struct ore_dev *oreds[numdevs * 2 - 1]; => struct exofs_dev eds[numdevs]; } *aoded;
Quoted 3 lines
If so than Sparse should be fixed. It is plain wrong. This complete structure is kmalloc(ed) two lines below.
Oh yeah. You are right. I misread how that worked.
regards,
dan carpenter