Skip to content

Commit 57ef692

Browse files
chuckleverJ. Bruce Fields
authored andcommitted
NLM: Rewrite IPv4 privileged requester's check
Clean up. For consistency, rewrite the IPv4 check to match the same style as the new IPv6 check. Note that ipv4_is_loopback() is somewhat broader in its interpretation of what is a loopback address than simply "127.0.0.1". Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
1 parent d1208f7 commit 57ef692

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎include/linux/lockd/lockd.h‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,11 @@ static inline struct inode *nlmsvc_file_inode(struct nlm_file *file)
291291
static inline int __nlm_privileged_request4(const struct sockaddr *sap)
292292
{
293293
const struct sockaddr_in *sin = (struct sockaddr_in *)sap;
294-
return (sin->sin_addr.s_addr == htonl(INADDR_LOOPBACK)) &&
295-
(ntohs(sin->sin_port) < 1024);
294+
295+
if (ntohs(sin->sin_port) > 1023)
296+
return 0;
297+
298+
return ipv4_is_loopback(sin->sin_addr.s_addr);
296299
}
297300

298301
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)

0 commit comments

Comments
 (0)