From: Dan Carpenter <dan.carpenter@oracle.com>
To: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: Changman Lee <cm224.lee@samsung.com>,
linux-f2fs-devel@lists.sourceforge.net,
kernel-janitors@vger.kernel.org
Subject: [patch] f2fs: potential shift wrapping buf in f2fs_trim_fs()
Date: Thu, 25 Sep 2014 11:39:17 +0000 [thread overview]
Message-ID: <20140925113917.GA3708@mwanda> (raw)
My static checker complains that segment is a u64 but only the lower 31
bits can be used before we hit a shift wrapping bug.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index b423005..d8ed1b8 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -949,7 +949,7 @@ int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range)
block_t start_addr = SM_I(sbi)->main_blkaddr;
__u64 start = range->start >> sbi->log_blocksize;
__u64 end = start + (range->len >> sbi->log_blocksize) - 1;
- __u64 segment = 1 << (sbi->log_blocksize + sbi->log_blocks_per_seg);
+ __u64 segment = 1ULL << (sbi->log_blocksize + sbi->log_blocks_per_seg);
unsigned int start_segno, end_segno;
struct cp_control cpc;
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: Changman Lee <cm224.lee@samsung.com>,
linux-f2fs-devel@lists.sourceforge.net,
kernel-janitors@vger.kernel.org
Subject: [patch] f2fs: potential shift wrapping buf in f2fs_trim_fs()
Date: Thu, 25 Sep 2014 14:39:17 +0300 [thread overview]
Message-ID: <20140925113917.GA3708@mwanda> (raw)
My static checker complains that segment is a u64 but only the lower 31
bits can be used before we hit a shift wrapping bug.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index b423005..d8ed1b8 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -949,7 +949,7 @@ int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range)
block_t start_addr = SM_I(sbi)->main_blkaddr;
__u64 start = range->start >> sbi->log_blocksize;
__u64 end = start + (range->len >> sbi->log_blocksize) - 1;
- __u64 segment = 1 << (sbi->log_blocksize + sbi->log_blocks_per_seg);
+ __u64 segment = 1ULL << (sbi->log_blocksize + sbi->log_blocks_per_seg);
unsigned int start_segno, end_segno;
struct cp_control cpc;
next reply other threads:[~2014-09-25 11:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-25 11:39 Dan Carpenter [this message]
2014-09-25 11:39 ` [patch] f2fs: potential shift wrapping buf in f2fs_trim_fs() Dan Carpenter
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=20140925113917.GA3708@mwanda \
--to=dan.carpenter@oracle.com \
--cc=cm224.lee@samsung.com \
--cc=jaegeuk@kernel.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
/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.