linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* possible unintended integer truncation in fs/ext4/extents.c:get_implied_cluster_alloc
@ 2013-12-14 22:29 PaX Team
  2013-12-20  4:59 ` Theodore Ts'o
  0 siblings, 1 reply; 3+ messages in thread
From: PaX Team @ 2013-12-14 22:29 UTC (permalink / raw)
  To: linux-ext4; +Cc: re.emese

Hello folks,

while running a simple analyzer plugin on linux 3.12.5 written by Emese Revfy
we found a case in ext4 that looks like a potential problem. the code looks
like this:

4082 		map->m_pblk = (ee_start & ~(sbi->s_cluster_ratio - 1)) +
4083 			c_offset;

here the expression ~(sbi->s_cluster_ratio - 1) will first do the negation
on an unsigned int then extend the result to unsigned long long (i.e, there's
a 32->64 bit conversion on both 32 and 64 bit archs) and stores it as such.
now this will obviously lose the higher 32 bits of ee_start and the question
is: is this intended behaviour or a bug? later the code compares map->m_pblk
against ee_block which is as unsigned int only so there's some mixture of
integer types here that may warrant further review.

cheers,
 PaX Team


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

end of thread, other threads:[~2013-12-20  5:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-14 22:29 possible unintended integer truncation in fs/ext4/extents.c:get_implied_cluster_alloc PaX Team
2013-12-20  4:59 ` Theodore Ts'o
2013-12-20  5:12   ` Theodore Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).