Skip to content

Commit

Permalink
NLM: Fix svcxdr_encode_owner()
Browse files Browse the repository at this point in the history
[ Upstream commit 89c485c ]

Dai Ngo reports that, since the XDR overhaul, the NLM server crashes
when the TEST procedure wants to return NLM_DENIED. There is a bug
in svcxdr_encode_owner() that none of our standard test cases found.

Replace the open-coded function with a call to an appropriate
pre-fabricated XDR helper.

Reported-by: Dai Ngo <Dai.Ngo@oracle.com>
Fixes: a6a63ca ("lockd: Common NLM XDR helpers")
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
chucklever authored and gregkh committed Sep 30, 2021
1 parent 2f95dd8 commit 9a5ba85
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions fs/lockd/svcxdr.h
Expand Up @@ -134,18 +134,9 @@ svcxdr_decode_owner(struct xdr_stream *xdr, struct xdr_netobj *obj)
static inline bool
svcxdr_encode_owner(struct xdr_stream *xdr, const struct xdr_netobj *obj)
{
unsigned int quadlen = XDR_QUADLEN(obj->len);
__be32 *p;

if (xdr_stream_encode_u32(xdr, obj->len) < 0)
return false;
p = xdr_reserve_space(xdr, obj->len);
if (!p)
if (obj->len > XDR_MAX_NETOBJ)
return false;
p[quadlen - 1] = 0; /* XDR pad */
memcpy(p, obj->data, obj->len);

return true;
return xdr_stream_encode_opaque(xdr, obj->data, obj->len) > 0;
}

#endif /* _LOCKD_SVCXDR_H_ */

0 comments on commit 9a5ba85

Please sign in to comment.