All of lore.kernel.org
 help / color / mirror / Atom feed
From: "PaX Team" <pageexec@freemail.hu>
To: linux-ext4@vger.kernel.org
Cc: re.emese@gmail.com
Subject: possible unintended integer truncation in fs/ext4/extents.c:get_implied_cluster_alloc
Date: Sat, 14 Dec 2013 23:29:18 +0100	[thread overview]
Message-ID: <52ACDBBE.32014.145F911E@pageexec.freemail.hu> (raw)

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


             reply	other threads:[~2013-12-14 22:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-14 22:29 PaX Team [this message]
2013-12-20  4:59 ` possible unintended integer truncation in fs/ext4/extents.c:get_implied_cluster_alloc Theodore Ts'o
2013-12-20  5:12   ` Theodore Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52ACDBBE.32014.145F911E@pageexec.freemail.hu \
    --to=pageexec@freemail.hu \
    --cc=linux-ext4@vger.kernel.org \
    --cc=re.emese@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.