Skip to content

Commit 89c485c

Browse files
committed
NLM: Fix svcxdr_encode_owner()
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 <[email protected]> Fixes: a6a63ca ("lockd: Common NLM XDR helpers") Signed-off-by: Chuck Lever <[email protected]>
1 parent 0c217d5 commit 89c485c

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

fs/lockd/svcxdr.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -134,18 +134,9 @@ svcxdr_decode_owner(struct xdr_stream *xdr, struct xdr_netobj *obj)
134134
static inline bool
135135
svcxdr_encode_owner(struct xdr_stream *xdr, const struct xdr_netobj *obj)
136136
{
137-
unsigned int quadlen = XDR_QUADLEN(obj->len);
138-
__be32 *p;
139-
140-
if (xdr_stream_encode_u32(xdr, obj->len) < 0)
141-
return false;
142-
p = xdr_reserve_space(xdr, obj->len);
143-
if (!p)
137+
if (obj->len > XDR_MAX_NETOBJ)
144138
return false;
145-
p[quadlen - 1] = 0; /* XDR pad */
146-
memcpy(p, obj->data, obj->len);
147-
148-
return true;
139+
return xdr_stream_encode_opaque(xdr, obj->data, obj->len) > 0;
149140
}
150141

151142
#endif /* _LOCKD_SVCXDR_H_ */

0 commit comments

Comments
 (0)