diff mbox

[net-next] tipc: fix a potential oops

Message ID 1409191361-28179-1-git-send-email-ying.xue@windriver.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Ying Xue Aug. 28, 2014, 2:02 a.m. UTC
Commit 6c9808ce09f7 ("tipc: remove port_lock") accidentally involves
a potential bug: when tipc socket instance(tsk) is not got with given
reference number in tipc_sk_get(), tsk is set to NULL. Subsequently
we jump to exit label where to decrease socket reference counter
pointed by tsk pointer in tipc_sk_put(). However, As now tsk is NULL,
oops may happen because of touching a NULL pointer.

Signed-off-by: Ying Xue <ying.xue@windriver.com>
Acked-by: Erik Hugne <erik.hugne@ericsson.com>
Acked-by: Jon Maloy <jon.maloy@ericsson.com>
---
Hi David, please notice that I just sumibt the patch to net-next as
the commit 6c9808ce09f7 is not merged into net tree so far.

 net/tipc/socket.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

David Miller Aug. 30, 2014, 3:22 a.m. UTC | #1
From: Ying Xue <ying.xue@windriver.com>
Date: Thu, 28 Aug 2014 10:02:41 +0800

> Commit 6c9808ce09f7 ("tipc: remove port_lock") accidentally involves
> a potential bug: when tipc socket instance(tsk) is not got with given
> reference number in tipc_sk_get(), tsk is set to NULL. Subsequently
> we jump to exit label where to decrease socket reference counter
> pointed by tsk pointer in tipc_sk_put(). However, As now tsk is NULL,
> oops may happen because of touching a NULL pointer.
> 
> Signed-off-by: Ying Xue <ying.xue@windriver.com>
> Acked-by: Erik Hugne <erik.hugne@ericsson.com>
> Acked-by: Jon Maloy <jon.maloy@ericsson.com>

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index d416e83..75275c5 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -2118,9 +2118,9 @@  static void tipc_sk_timeout(unsigned long ref)
 
 	tsk = tipc_sk_get(ref);
 	if (!tsk)
-		goto exit;
-	sk = &tsk->sk;
+		return;
 
+	sk = &tsk->sk;
 	bh_lock_sock(sk);
 	if (!tsk->connected) {
 		bh_unlock_sock(sk);