Thread (1 message) 1 message, 1 author, 2020-10-27

[PATCH AUTOSEL 4.14 35/46] net: 9p: initialize sun_server.sun_path to have addr's value only when addr is valid

flat view
DORMANTno replies REVIEWED: 1 (0M)

From: Sasha Levin <sashal@kernel.org>
Date: 2020-10-27 00:11:03
Also in: lkml, stable
Subsystem: 9p file system, the rest · Maintainers: Eric Van Hensbergen, Latchesar Ionkov, Dominique Martinet, Linus Torvalds

Status: Reviewed.

1 review trailer.

From: Anant Thazhemadam <redacted>

[ Upstream commit 7ca1db21ef8e0e6725b4d25deed1ca196f7efb28 ]

In p9_fd_create_unix, checking is performed to see if the addr (passed
as an argument) is NULL or not.
However, no check is performed to see if addr is a valid address, i.e.,
it doesn't entirely consist of only 0's.
The initialization of sun_server.sun_path to be equal to this faulty
addr value leads to an uninitialized variable, as detected by KMSAN.
Checking for this (faulty addr) and returning a negative error number
appropriately, resolves this issue.

Link: http://lkml.kernel.org/r/20201012042404.2508-1-anant.thazhemadam@gmail.com
Reported-by: <redacted>
Tested-by: <redacted>
Signed-off-by: Anant Thazhemadam <redacted>
Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/9p/trans_fd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
index 9f020559c1928..1b56b22c5c5d7 100644
--- a/net/9p/trans_fd.c
+++ b/net/9p/trans_fd.c
@@ -1029,7 +1029,7 @@ p9_fd_create_unix(struct p9_client *client, const char *addr, char *args)
 
 	csocket = NULL;
 
-	if (addr == NULL)
+	if (!addr || !strlen(addr))
 		return -EINVAL;
 
 	if (strlen(addr) >= UNIX_PATH_MAX) {
-- 
2.25.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help