diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-11-19 16:43:19 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-11-19 16:43:19 -0500 |
commit | e6236f781cc7777a2e74d256c478bb07496f35ec (patch) | |
tree | 559a5816b803ec3f86dae82bdb9e5d3f9c20deee | |
parent | 308efab5e231d1510cd35931d87629bf5171caae (diff) | |
parent | 1e360a60b24ad8f8685af66fa6de10ce46693a4b (diff) |
Merge branch 'bugfixes' of git://git.linux-nfs.org/projects/trondmy/nfs-2.6
* 'bugfixes' of git://git.linux-nfs.org/projects/trondmy/nfs-2.6:
SUNRPC: Address buffer overrun in rpc_uaddr2sockaddr()
NFSv4: Fix a cache validation bug which causes getcwd() to return ENOENT
-rw-r--r-- | fs/nfs/nfs4proc.c | 2 | ||||
-rw-r--r-- | net/sunrpc/addr.c | 18 |
2 files changed, 9 insertions, 11 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index ff37454fa783..741a562177fc 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -2767,7 +2767,7 @@ static int _nfs4_proc_readdir(struct dentry *dentry, struct rpc_cred *cred, | |||
2767 | .pages = &page, | 2767 | .pages = &page, |
2768 | .pgbase = 0, | 2768 | .pgbase = 0, |
2769 | .count = count, | 2769 | .count = count, |
2770 | .bitmask = NFS_SERVER(dentry->d_inode)->cache_consistency_bitmask, | 2770 | .bitmask = NFS_SERVER(dentry->d_inode)->attr_bitmask, |
2771 | }; | 2771 | }; |
2772 | struct nfs4_readdir_res res; | 2772 | struct nfs4_readdir_res res; |
2773 | struct rpc_message msg = { | 2773 | struct rpc_message msg = { |
diff --git a/net/sunrpc/addr.c b/net/sunrpc/addr.c index 22e8fd89477f..c7450c8f0a7c 100644 --- a/net/sunrpc/addr.c +++ b/net/sunrpc/addr.c | |||
@@ -306,24 +306,25 @@ EXPORT_SYMBOL_GPL(rpc_sockaddr2uaddr); | |||
306 | * @sap: buffer into which to plant socket address | 306 | * @sap: buffer into which to plant socket address |
307 | * @salen: size of buffer | 307 | * @salen: size of buffer |
308 | * | 308 | * |
309 | * @uaddr does not have to be '\0'-terminated, but strict_strtoul() and | ||
310 | * rpc_pton() require proper string termination to be successful. | ||
311 | * | ||
309 | * Returns the size of the socket address if successful; otherwise | 312 | * Returns the size of the socket address if successful; otherwise |
310 | * zero is returned. | 313 | * zero is returned. |
311 | */ | 314 | */ |
312 | size_t rpc_uaddr2sockaddr(const char *uaddr, const size_t uaddr_len, | 315 | size_t rpc_uaddr2sockaddr(const char *uaddr, const size_t uaddr_len, |
313 | struct sockaddr *sap, const size_t salen) | 316 | struct sockaddr *sap, const size_t salen) |
314 | { | 317 | { |
315 | char *c, buf[RPCBIND_MAXUADDRLEN]; | 318 | char *c, buf[RPCBIND_MAXUADDRLEN + sizeof('\0')]; |
316 | unsigned long portlo, porthi; | 319 | unsigned long portlo, porthi; |
317 | unsigned short port; | 320 | unsigned short port; |
318 | 321 | ||
319 | if (uaddr_len > sizeof(buf)) | 322 | if (uaddr_len > RPCBIND_MAXUADDRLEN) |
320 | return 0; | 323 | return 0; |
321 | 324 | ||
322 | memcpy(buf, uaddr, uaddr_len); | 325 | memcpy(buf, uaddr, uaddr_len); |
323 | 326 | ||
324 | buf[uaddr_len] = '\n'; | 327 | buf[uaddr_len] = '\0'; |
325 | buf[uaddr_len + 1] = '\0'; | ||
326 | |||
327 | c = strrchr(buf, '.'); | 328 | c = strrchr(buf, '.'); |
328 | if (unlikely(c == NULL)) | 329 | if (unlikely(c == NULL)) |
329 | return 0; | 330 | return 0; |
@@ -332,9 +333,7 @@ size_t rpc_uaddr2sockaddr(const char *uaddr, const size_t uaddr_len, | |||
332 | if (unlikely(portlo > 255)) | 333 | if (unlikely(portlo > 255)) |
333 | return 0; | 334 | return 0; |
334 | 335 | ||
335 | c[0] = '\n'; | 336 | *c = '\0'; |
336 | c[1] = '\0'; | ||
337 | |||
338 | c = strrchr(buf, '.'); | 337 | c = strrchr(buf, '.'); |
339 | if (unlikely(c == NULL)) | 338 | if (unlikely(c == NULL)) |
340 | return 0; | 339 | return 0; |
@@ -345,8 +344,7 @@ size_t rpc_uaddr2sockaddr(const char *uaddr, const size_t uaddr_len, | |||
345 | 344 | ||
346 | port = (unsigned short)((porthi << 8) | portlo); | 345 | port = (unsigned short)((porthi << 8) | portlo); |
347 | 346 | ||
348 | c[0] = '\0'; | 347 | *c = '\0'; |
349 | |||
350 | if (rpc_pton(buf, strlen(buf), sap, salen) == 0) | 348 | if (rpc_pton(buf, strlen(buf), sap, salen) == 0) |
351 | return 0; | 349 | return 0; |
352 | 350 | ||