[RFC PATCH v2 01/22] smb: client: Use PAGE_SIZE_MIN in the lock element build checks
From: Eric Curtin
Date: Tue Dec 01 2026 - 22:15:55 EST
From: Eric Curtin <eric.curtin@xxxxxxxxxx>
With arm64 boot-time page size selection PAGE_SIZE is not a compile-time
constant, so it cannot be used in BUILD_BUG_ON().
Compare the size of the LOCKING_ANDX_RANGE and smb2_lock_element lock
buffers against PAGE_SIZE_MIN in cifs_push_mandatory_locks(),
cifs_unlock_range(), smb2_unlock_range() and
smb2_push_mandatory_locks(), so that the checks hold for every supported
page size. The run-time clamps that use PAGE_SIZE are unchanged.
No functional change for compile-time page sizes.
Signed-off-by: Eric Curtin <eric.curtin@xxxxxxxxxx>
---
fs/smb/client/file.c | 4 ++--
fs/smb/client/smb2file.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
index d272320436b3..dd572b3c2a65 100644
--- a/fs/smb/client/file.c
+++ b/fs/smb/client/file.c
@@ -2417,7 +2417,7 @@ cifs_push_mandatory_locks(struct cifsFileInfo *cfile)
}
BUILD_BUG_ON(sizeof(struct smb_hdr) + sizeof(LOCKING_ANDX_RANGE) >
- PAGE_SIZE);
+ PAGE_SIZE_MIN);
max_buf = min_t(unsigned int, max_buf - sizeof(struct smb_hdr),
PAGE_SIZE);
max_num = (max_buf - sizeof(struct smb_hdr)) /
@@ -2793,7 +2793,7 @@ cifs_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock,
return -EINVAL;
BUILD_BUG_ON(sizeof(struct smb_hdr) + sizeof(LOCKING_ANDX_RANGE) >
- PAGE_SIZE);
+ PAGE_SIZE_MIN);
max_buf = min_t(unsigned int, max_buf - sizeof(struct smb_hdr),
PAGE_SIZE);
max_num = (max_buf - sizeof(struct smb_hdr)) /
diff --git a/fs/smb/client/smb2file.c b/fs/smb/client/smb2file.c
index 764cfd894ad0..7640e35d44d1 100644
--- a/fs/smb/client/smb2file.c
+++ b/fs/smb/client/smb2file.c
@@ -314,7 +314,7 @@ smb2_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock,
if (max_buf < sizeof(struct smb2_lock_element))
return -EINVAL;
- BUILD_BUG_ON(sizeof(struct smb2_lock_element) > PAGE_SIZE);
+ BUILD_BUG_ON(sizeof(struct smb2_lock_element) > PAGE_SIZE_MIN);
max_buf = min_t(unsigned int, max_buf, PAGE_SIZE);
max_num = max_buf / sizeof(struct smb2_lock_element);
buf = kzalloc_objs(struct smb2_lock_element, max_num);
@@ -457,7 +457,7 @@ smb2_push_mandatory_locks(struct cifsFileInfo *cfile)
return -EINVAL;
}
- BUILD_BUG_ON(sizeof(struct smb2_lock_element) > PAGE_SIZE);
+ BUILD_BUG_ON(sizeof(struct smb2_lock_element) > PAGE_SIZE_MIN);
max_buf = min_t(unsigned int, max_buf, PAGE_SIZE);
max_num = max_buf / sizeof(struct smb2_lock_element);
buf = kzalloc_objs(struct smb2_lock_element, max_num);