public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: David Timber <dxdt@dev.snart.me>
Cc: Namjae Jeon <linkinjeon@kernel.org>,
	sj1557.seo@samsung.com, yuezhang.mo@sony.com,
	linux-fsdevel@vger.kernel.org, anmuxixixi@gmail.com, hch@lst.de,
	chizhiling@163.com
Subject: Re: [PATCH 3/5] exfat: add iomap buffered I/O support
Date: Tue, 7 Apr 2026 08:28:49 +0200	[thread overview]
Message-ID: <20260407062849.GA6966@lst.de> (raw)
In-Reply-To: <149dabc5-5e88-4589-aec6-fd22925ce974@dev.snart.me>

On Mon, Apr 06, 2026 at 10:09:42PM +0900, David Timber wrote:
> > -#define EXFAT_CLU_TO_B(b, sbi)		((b) << (sbi)->cluster_size_bits)
> > +#define EXFAT_CLU_TO_B(b, sbi)		((loff_t)(b) << (sbi)->cluster_size_bits)
> 
> I think type casting should be left to the users of the macro. These
> helper macros are quite dangerous in case of (ex)FAT because integer
> overflows are unchecked for shift op. The on-disk format is 32 bit but
> the kernel has switched over to "all-64-bit".
> 
> That particular macro is used in dirent update code and, in particular,
> in exfat_map_cluster():
> 
>     inode->i_blocks += EXFAT_CLU_TO_B(num_to_be_allocated, sbi) >> 9;
> 
> The type of i_blocks is blkcnt_t, which is unsigned. loff_t is signed.
> exFAT got away with it because Linux write calls expand the size of
> files no more than 0x7ffff000 bytes and the size of dir is limited to
> 256MB. However, someone could come in and decide to use
> exfat_map_cluster() to allocate more than this limit.

But that will blow up in some many other ways.  The only sane thing
to do here is to replace those macros with inline functions that
include the proper casting.


  reply	other threads:[~2026-04-07  6:28 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-26 11:50 [PATCH 0/5] exfat: convert to iomap Namjae Jeon
2026-03-26 11:50 ` [PATCH 1/5] exfat: add iomap support Namjae Jeon
2026-03-30  2:45   ` Chi Zhiling
2026-03-31  5:29     ` Namjae Jeon
2026-03-30  6:30   ` Christoph Hellwig
2026-03-31  5:26     ` Namjae Jeon
2026-03-31  5:48       ` Christoph Hellwig
2026-03-31  6:44         ` Namjae Jeon
2026-04-01  3:07       ` Chi Zhiling
2026-04-01  2:24   ` Yuezhang.Mo
2026-04-01  2:47     ` Namjae Jeon
2026-04-06 13:45   ` David Timber
2026-04-06 14:13   ` David Timber
2026-03-26 11:50 ` [PATCH 2/5] exfat: add iomap direct I/O support Namjae Jeon
2026-03-30  6:33   ` Christoph Hellwig
2026-03-31  5:23     ` Namjae Jeon
2026-03-26 11:50 ` [PATCH 3/5] exfat: add iomap buffered " Namjae Jeon
2026-03-30  6:38   ` Christoph Hellwig
2026-03-31  5:22     ` Namjae Jeon
2026-03-31  5:46       ` Christoph Hellwig
2026-03-31  6:36         ` Namjae Jeon
2026-03-31  6:37           ` Christoph Hellwig
2026-03-31  6:58             ` Namjae Jeon
2026-04-06 13:09   ` David Timber
2026-04-07  6:28     ` Christoph Hellwig [this message]
2026-03-26 11:50 ` [PATCH 4/5] exfat: add support for multi-cluster allocation Namjae Jeon
2026-03-26 11:50 ` [PATCH 5/5] exfat: add support for SEEK_HOLE and SEEK_DATA in llseek Namjae Jeon
2026-03-30  6:39   ` Christoph Hellwig
2026-03-31  4:55     ` Namjae Jeon
2026-03-27  6:33 ` [PATCH 0/5] exfat: convert to iomap Christoph Hellwig
2026-03-27  6:46   ` Namjae Jeon

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=20260407062849.GA6966@lst.de \
    --to=hch@lst.de \
    --cc=anmuxixixi@gmail.com \
    --cc=chizhiling@163.com \
    --cc=dxdt@dev.snart.me \
    --cc=linkinjeon@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=sj1557.seo@samsung.com \
    --cc=yuezhang.mo@sony.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox