From 8cfd5be8b04bdaaa4a0c794392cc2e6835e103eb Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Thu, 7 May 2020 08:59:40 +0200 Subject: [PATCH] LU-13528 llite: prevent MAX_DIO_SIZE 32-bit truncation On 4kB PAGE_SIZE systems, kmalloc can allocate up to 4MB, which makes MAX_DIO_SIZE up to 682MB. This number can fit into 32 bits. But on 64kB PAGE_SIZE systems, kmalloc can allocate up to 512MB, which then makes MAX_DIO_SIZE up to 1365GB. This needs 64 bits to fit. Make sure that for every platform MAX_DIO_SIZE is not abusively truncated, by casting it to size_t. Signed-off-by: Sebastien Buisson Change-Id: I9d2c8c4a1ccf0abf0b7647e569b8454365369e8a Reviewed-on: https://review.whamcloud.com/38526 Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Tested-by: jenkins Tested-by: Maloo --- lustre/llite/rw26.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lustre/llite/rw26.c b/lustre/llite/rw26.c index 2dc2f16..5c4dd7b 100644 --- a/lustre/llite/rw26.c +++ b/lustre/llite/rw26.c @@ -384,7 +384,7 @@ ll_direct_rw_pages(const struct lu_env *env, struct cl_io *io, size_t size, * then truncate this to be a full-sized RPC. For 4kB PAGE_SIZE this is * up to 22MB for 128kB kmalloc and up to 682MB for 4MB kmalloc. */ #define MAX_DIO_SIZE ((MAX_MALLOC / sizeof(struct brw_page) * PAGE_SIZE) & \ - ~(DT_MAX_BRW_SIZE - 1)) + ~((size_t)DT_MAX_BRW_SIZE - 1)) static ssize_t ll_direct_IO_impl(struct kiocb *iocb, struct iov_iter *iter, int rw) -- 1.8.3.1