Re: FAT: Operating on broken FAT FS causes the write syscall to return negative number not equal to -1

2018-07-16 Thread Alan Cox
> Oops, I was just doing some testing and thought that correct behavior > for crafted FS is to return arbitrary valid error code (like -EIO) or > some arbitrary data, say, not larger than FS (not disclosing the > kernel memory, of course). Please excuse me if I was wrong. If fixing > this would

Re: FAT: Operating on broken FAT FS causes the write syscall to return negative number not equal to -1

2018-07-16 Thread Alan Cox
> Oops, I was just doing some testing and thought that correct behavior > for crafted FS is to return arbitrary valid error code (like -EIO) or > some arbitrary data, say, not larger than FS (not disclosing the > kernel memory, of course). Please excuse me if I was wrong. If fixing > this would

Re: FAT: Operating on broken FAT FS causes the write syscall to return negative number not equal to -1

2018-07-15 Thread Anatoly Trosinenko
Thanks for explanation! Best regards, Anatoly вс, 15 июл. 2018 г. в 18:26, OGAWA Hirofumi : > > Anatoly Trosinenko writes: > > >> This patch returns better error (-EIO) for me. > > > > This works for me likewise. > > Thanks for testing. > > >> (But note, the corrupted FS image doesn't guarantee

Re: FAT: Operating on broken FAT FS causes the write syscall to return negative number not equal to -1

2018-07-15 Thread Anatoly Trosinenko
Thanks for explanation! Best regards, Anatoly вс, 15 июл. 2018 г. в 18:26, OGAWA Hirofumi : > > Anatoly Trosinenko writes: > > >> This patch returns better error (-EIO) for me. > > > > This works for me likewise. > > Thanks for testing. > > >> (But note, the corrupted FS image doesn't guarantee

Re: FAT: Operating on broken FAT FS causes the write syscall to return negative number not equal to -1

2018-07-15 Thread OGAWA Hirofumi
Anatoly Trosinenko writes: >> This patch returns better error (-EIO) for me. > > This works for me likewise. Thanks for testing. >> (But note, the corrupted FS image doesn't guarantee POSIX behavior.) > > Oops, I was just doing some testing and thought that correct behavior > for crafted FS is

Re: FAT: Operating on broken FAT FS causes the write syscall to return negative number not equal to -1

2018-07-15 Thread OGAWA Hirofumi
Anatoly Trosinenko writes: >> This patch returns better error (-EIO) for me. > > This works for me likewise. Thanks for testing. >> (But note, the corrupted FS image doesn't guarantee POSIX behavior.) > > Oops, I was just doing some testing and thought that correct behavior > for crafted FS is

Re: FAT: Operating on broken FAT FS causes the write syscall to return negative number not equal to -1

2018-07-15 Thread Anatoly Trosinenko
Thank you! > This patch returns better error (-EIO) for me. This works for me likewise. > (But note, the corrupted FS image doesn't guarantee POSIX behavior.) Oops, I was just doing some testing and thought that correct behavior for crafted FS is to return arbitrary valid error code (like

Re: FAT: Operating on broken FAT FS causes the write syscall to return negative number not equal to -1

2018-07-15 Thread Anatoly Trosinenko
Thank you! > This patch returns better error (-EIO) for me. This works for me likewise. > (But note, the corrupted FS image doesn't guarantee POSIX behavior.) Oops, I was just doing some testing and thought that correct behavior for crafted FS is to return arbitrary valid error code (like

[PATCH v2] Re: FAT: Operating on broken FAT FS causes the write syscall to return negative number not equal to -1

2018-07-15 Thread OGAWA Hirofumi
Al Viro writes: > On Sun, Jul 15, 2018 at 11:20:06PM +0900, OGAWA Hirofumi wrote: >> +static inline bool fat_valid_entry(struct msdos_sb_info *sbi, int entry) >> +{ >> +if (entry < FAT_START_ENT || sbi->max_cluster <= entry) >> +return false; >> +return true; >> +} > > Pet

[PATCH v2] Re: FAT: Operating on broken FAT FS causes the write syscall to return negative number not equal to -1

2018-07-15 Thread OGAWA Hirofumi
Al Viro writes: > On Sun, Jul 15, 2018 at 11:20:06PM +0900, OGAWA Hirofumi wrote: >> +static inline bool fat_valid_entry(struct msdos_sb_info *sbi, int entry) >> +{ >> +if (entry < FAT_START_ENT || sbi->max_cluster <= entry) >> +return false; >> +return true; >> +} > > Pet

Re: FAT: Operating on broken FAT FS causes the write syscall to return negative number not equal to -1

2018-07-15 Thread Al Viro
On Sun, Jul 15, 2018 at 11:20:06PM +0900, OGAWA Hirofumi wrote: > +static inline bool fat_valid_entry(struct msdos_sb_info *sbi, int entry) > +{ > + if (entry < FAT_START_ENT || sbi->max_cluster <= entry) > + return false; > + return true; > +} Pet peeve: if (...) return

Re: FAT: Operating on broken FAT FS causes the write syscall to return negative number not equal to -1

2018-07-15 Thread Al Viro
On Sun, Jul 15, 2018 at 11:20:06PM +0900, OGAWA Hirofumi wrote: > +static inline bool fat_valid_entry(struct msdos_sb_info *sbi, int entry) > +{ > + if (entry < FAT_START_ENT || sbi->max_cluster <= entry) > + return false; > + return true; > +} Pet peeve: if (...) return

Re: FAT: Operating on broken FAT FS causes the write syscall to return negative number not equal to -1

2018-07-15 Thread OGAWA Hirofumi
Anatoly Trosinenko writes: > How to reproduce: > 1) Compile v4.18-rc4 kernel with the attached config > 1) Unpack the attached FS image (128 Mb) and mount it as vfat to /mnt > 2) Compile and run vfat-bug.c > > What is expected: > `write` returns either -1 or small positive number. > > What

Re: FAT: Operating on broken FAT FS causes the write syscall to return negative number not equal to -1

2018-07-15 Thread OGAWA Hirofumi
Anatoly Trosinenko writes: > How to reproduce: > 1) Compile v4.18-rc4 kernel with the attached config > 1) Unpack the attached FS image (128 Mb) and mount it as vfat to /mnt > 2) Compile and run vfat-bug.c > > What is expected: > `write` returns either -1 or small positive number. > > What