public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block: use "unsigned long" for blk_validate_block_size()
@ 2021-12-17 11:38 Tetsuo Handa
  2021-12-17 16:25 ` Jens Axboe
  0 siblings, 1 reply; 7+ messages in thread
From: Tetsuo Handa @ 2021-12-17 11:38 UTC (permalink / raw)
  To: linux-block

Use of "unsigned short" for loop_validate_block_size() is wrong [1], and
commit af3c570fb0df422b ("loop: Use blk_validate_block_size() to validate
block size") changed to use "unsigned int".

However, since lo_simple_ioctl(LOOP_SET_BLOCK_SIZE) passes "unsigned long
arg" to loop_set_block_size(), blk_validate_block_size() can't validate
the upper 32bits on 64bits environment. A block size like 0x100000200
should be rejected.

Link: https://lkml.kernel.org/r/20210927094327.644665-1-arnd@kernel.org [1]
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
---
 include/linux/blkdev.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index bd4370baccca..e13e41f7fad2 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -44,7 +44,7 @@ struct blk_crypto_profile;
  */
 #define BLKCG_MAX_POLS		6
 
-static inline int blk_validate_block_size(unsigned int bsize)
+static inline int blk_validate_block_size(unsigned long bsize)
 {
 	if (bsize < 512 || bsize > PAGE_SIZE || !is_power_of_2(bsize))
 		return -EINVAL;
-- 
2.32.0

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-12-21 16:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-17 11:38 [PATCH] block: use "unsigned long" for blk_validate_block_size() Tetsuo Handa
2021-12-17 16:25 ` Jens Axboe
2021-12-17 18:09   ` Tetsuo Handa
2021-12-18  1:32     ` Tetsuo Handa
2021-12-18  9:41       ` [PATCH v2] " Tetsuo Handa
2021-12-21 16:20         ` Christoph Hellwig
2021-12-21 16:33         ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox