mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Suspected bug in fs/ufs/inode.c - test for < 0 on unsigned sector_t - [2.6.1-rc1-mm1]
@ 2004-01-03 22:45 Jesper Juhl
  2004-01-04  3:04 ` Suspected bug in fs/ufs/inode.c and other filesystems " Jesper Juhl
  2004-01-04 12:57 ` Suspected bug in fs/ufs/inode.c " Tim Cambrant
  0 siblings, 2 replies; 4+ messages in thread
From: Jesper Juhl @ 2004-01-03 22:45 UTC (permalink / raw)
  To: linux-kernel


Hi,

I think I may have found a bug in fs/ufs/inode.c

lines 334 & 335 have this code (in function ufs_getfrag_block) :

	if (fragment < 0)
		goto abort_negative;

fragment is an argument to ufs_getfrag_block of type sector_t
digging a little in include/linux and include/asm reveals sector_t to be
an an unsigned type in all archs (at least as far as I've been able to
determine).

include/linux/types.h defines sector_t as

typedef unsigned long sector_t;

and in include/asm* sector_t is defined as :

asm-sh/types.h:typedef u64 sector_t;
asm-x86_64/types.h:typedef u64 sector_t;
asm-h8300/types.h:typedef u64 sector_t;
asm-i386/types.h:typedef u64 sector_t;
asm-mips/types.h:typedef u64 sector_t;
asm-s390/types.h:typedef u64 sector_t;
asm-ppc/types.h:typedef u64 sector_t;

all unsigned types.

So, since sector_t is unsigned it can never be less than zero, hence the
branch on line 334 will never be taken and the assiciated label
"abort_negative" will never be reached (and it's not referenced anywhere
else).

I don't know enough about UFS to be able to tell if this is actually a
problem or not, but I suspect that it might be.. If it's not a problem,
then the code that tests for (fragment < 0) and the associated code
in abort_negative might as well be removed.

Is this analysis correct?  If it is, can the code simply be removed?


Kind regards,

Jesper Juhl

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

end of thread, other threads:[~2004-01-04 22:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-03 22:45 Suspected bug in fs/ufs/inode.c - test for < 0 on unsigned sector_t - [2.6.1-rc1-mm1] Jesper Juhl
2004-01-04  3:04 ` Suspected bug in fs/ufs/inode.c and other filesystems " Jesper Juhl
2004-01-04 12:57 ` Suspected bug in fs/ufs/inode.c " Tim Cambrant
2004-01-04 22:14   ` Suspected bug in fs/ufs/inode.c - test for < 0 on unsigned se ctor_t " Jesper Juhl

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

Powered by JetHome