All of lore.kernel.org
 help / color / mirror / Atom feed
From: yuchao0@huawei.com (Chao Yu)
Subject: [PATCH 02/11] erofs: fix to avoid potential overflow
Date: Fri, 22 Jun 2018 10:01:22 +0800	[thread overview]
Message-ID: <20180622020131.65525-2-yuchao0@huawei.com> (raw)
In-Reply-To: <20180622020131.65525-1-yuchao0@huawei.com>

Previsouly, we use 32bit unsigned variable to store 64bits page->index's
value, it will cause potential overflow, fix it.

Reviewed-by: Gao Xiang <gaoxiang25 at huawei.com>
Signed-off-by: Chao Yu <yuchao0 at huawei.com>
---
 fs/erofs/data.c     | 8 ++++----
 fs/erofs/internal.h | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index 432581d4ed0c..e76de71c85ff 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -200,12 +200,12 @@ static inline struct bio *erofs_read_raw_page(
 	struct bio *bio,
 	struct address_space *mapping,
 	struct page *page,
-	unsigned *last_block,
+	erofs_off_t *last_block,
 	unsigned nblocks,
 	bool ra)
 {
 	struct inode *inode = mapping->host;
-	unsigned current_block = page->index;
+	erofs_off_t current_block = (erofs_off_t)page->index;
 	int err;
 
 	BUG_ON(!nblocks);
@@ -334,7 +334,7 @@ static inline struct bio *erofs_read_raw_page(
  */
 static int erofs_raw_access_readpage(struct file *file, struct page *page)
 {
-	unsigned last_block;
+	erofs_off_t last_block;
 	struct bio *bio;
 
 	bio = erofs_read_raw_page(NULL, page->mapping,
@@ -351,7 +351,7 @@ static int erofs_raw_access_readpages(struct file *filp,
 	struct address_space *mapping,
 	struct list_head *pages, unsigned nr_pages)
 {
-	unsigned last_block;
+	erofs_off_t last_block;
 	struct bio *bio = NULL;
 	gfp_t gfp = readahead_gfp_mask(mapping);
 
diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index 0606a50a0067..7670c2ed53d2 100644
--- a/fs/erofs/internal.h
+++ b/fs/erofs/internal.h
@@ -127,7 +127,7 @@ static inline erofs_off_t iloc(struct erofs_sb_info *sbi, erofs_nid_t nid)
 
 #define erofs_blknr(addr)       ((addr) / EROFS_BLKSIZ)
 #define erofs_blkoff(addr)      ((addr) % EROFS_BLKSIZ)
-#define blknr_to_addr(nr)       ((nr) * EROFS_BLKSIZ)
+#define blknr_to_addr(nr)       ((erofs_off_t)(nr) * EROFS_BLKSIZ)
 
 #define inode_set_inited_xattr(inode)   (EROFS_V(inode)->flags |= 1)
 #define inode_has_inited_xattr(inode)   (EROFS_V(inode)->flags & 1)
-- 
2.18.0.rc1

  reply	other threads:[~2018-06-22  2:01 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-22  2:01 [PATCH 01/11] erofs: fix compile error Chao Yu
2018-06-22  2:01 ` Chao Yu [this message]
2018-06-22  2:01 ` [PATCH 03/11] erofs: fix missing endian conversion Chao Yu
2018-06-22  2:01 ` [PATCH 04/11] erofs: fix to do endian conversion correctly Chao Yu
2018-06-22  2:01 ` [PATCH 05/11] erofs: fix to handle return value of erofs_init_page_bundle() correctly Chao Yu
2018-06-22  2:01 ` [PATCH 06/11] erofs: fix to return correct value of alloc_inode Chao Yu
2018-06-22  2:01 ` [PATCH 07/11] erofs: remove unused EROFS_XATTR_INDEX_ADVISE Chao Yu
2018-06-22  2:01 ` [PATCH 08/11] erofs: support special inode Chao Yu
2018-07-03  5:31   ` Gao Xiang
2018-07-03 13:48     ` Chao Yu
2018-08-01  8:17       ` Gao Xiang
2018-08-01  8:40         ` 答复: " liguifu (C)
2018-06-22  2:01 ` [PATCH 09/11] erofs: introduce parse_options() Chao Yu
2018-06-22  2:01 ` [PATCH 10/11] erofs: introduce error injection infrastructure Chao Yu
2018-06-30 15:44   ` [PATCH v4] " Gao Xiang
2018-06-30 18:39   ` [PATCH v5] " Gao Xiang
2018-07-01  3:56     ` Chao Yu
2018-07-01  4:04       ` Gao Xiang
2018-06-22  2:01 ` [PATCH 11/11] erofs: support tracepoint Chao Yu
2018-07-03  9:44   ` Gao Xiang
2018-07-03 13:52     ` Chao Yu
2018-07-03 14:22       ` Gao Xiang

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=20180622020131.65525-2-yuchao0@huawei.com \
    --to=yuchao0@huawei.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.