public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, "Wang\, Matt" <Matt.Wang@Dell.com>,
	"dan.carpenter\@oracle.com" <dan.carpenter@oracle.com>
Subject: [PATCH] fat: Fix potential shift wrap with FITRIM ioctl on FAT
Date: Fri, 13 Jul 2018 15:47:08 +0900	[thread overview]
Message-ID: <87h8l37hub.fsf@mail.parknet.co.jp> (raw)
In-Reply-To: <C8ECE1B7A767434691FEEFA3A01765D72AF77119@MX203CL03.corp.emc.com> (Matt Wang's message of "Fri, 13 Jul 2018 03:37:23 +0000")

This patch is the fix of fat-add-fitrim-ioctl-for-fat-file-system.patch.
Maybe better to merge with it (if it is easy).

Anyway, please apply this with above patch.

--------
From: Wentao Wang <witallwang@gmail.com>

If we keep "trimmed" as an u32, there will be a potential shift wrap.

It would be a problem on a larger than 4GB partition with
FAT32. Though most tools who call this ioctl would ignore this value,
it would be great to fix it.

Signed-off-by: Wentao Wang <witallwang@gmail.com>
Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
---

 fs/fat/fatent.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff -puN fs/fat/fatent.c~fat-fitrim-fix fs/fat/fatent.c
--- linux/fs/fat/fatent.c~fat-fitrim-fix	2018-07-13 15:39:14.417110998 +0900
+++ linux-hirofumi/fs/fat/fatent.c	2018-07-13 15:39:14.418110996 +0900
@@ -705,8 +705,8 @@ int fat_trim_fs(struct inode *inode, str
 	struct msdos_sb_info *sbi = MSDOS_SB(sb);
 	const struct fatent_operations *ops = sbi->fatent_ops;
 	struct fat_entry fatent;
-	u64 ent_start, ent_end, minlen;
-	u32 free = 0, trimmed = 0;
+	u64 ent_start, ent_end, minlen, trimmed = 0;
+	u32 free = 0;
 	unsigned long reada_blocks, reada_mask, cur_block = 0;
 	int err = 0;
 
_

-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

           reply	other threads:[~2018-07-13  6:47 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <C8ECE1B7A767434691FEEFA3A01765D72AF77119@MX203CL03.corp.emc.com>]

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=87h8l37hub.fsf@mail.parknet.co.jp \
    --to=hirofumi@mail.parknet.co.jp \
    --cc=Matt.Wang@Dell.com \
    --cc=akpm@linux-foundation.org \
    --cc=dan.carpenter@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox