]> git.ipfire.org Git - thirdparty/linux.git/commit
lockd: Move nlm4svc_set_file_lock_range()
authorChuck Lever <chuck.lever@oracle.com>
Wed, 28 Jan 2026 15:19:34 +0000 (10:19 -0500)
committerChuck Lever <chuck.lever@oracle.com>
Mon, 30 Mar 2026 01:25:09 +0000 (21:25 -0400)
commitb3f76a9b13f014edcba9eaae2bc09a6af7267cee
tree635323bde51850d347333aadabf49e9bc26648fa
parent5829352e568d24dd04ae112128a4f44748d073bc
lockd: Move nlm4svc_set_file_lock_range()

Both client-side and server-side NLMv4 code convert lock byte ranges
from the wire format (start, length) to the kernel's file_lock format
(start, end). The current nlm4svc_set_file_lock_range() performs this
conversion, but the "svc" prefix incorrectly suggests server-only use,
and client code must include server-internal headers to access it.

Rename to lockd_set_file_lock_range4() and relocate to the shared
lockd.h header, making it accessible to both client and server code.
This eliminates the need for client code to include xdr4.h, reducing
coupling between the XDR implementation files.

While relocating the function, add input validation: clamp the
starting offset to OFFSET_MAX before use. Without this, a malformed
lock request with off > OFFSET_MAX results in fl_start > fl_end,
violating file_lock invariants and potentially causing incorrect
lock conflict detection.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/lockd/clnt4xdr.c
fs/lockd/lockd.h
fs/lockd/xdr4.c
fs/lockd/xdr4.h