* [PATCH net] rxrpc: Fix potential NULL-pointer exception
@ 2017-03-02 23:48 David Howells
0 siblings, 0 replies; 4+ messages in thread
From: David Howells @ 2017-03-02 23:48 UTC (permalink / raw)
To: netdev; +Cc: dhowells, linux-afs, linux-kernel
Fix a potential NULL-pointer exception in rxrpc_do_sendmsg(). The call
state check that I added should have gone into the else-body of the
if-statement where we actually have a call to check.
Found by CoverityScan CID#1414316 ("Dereference after null check").
Fixes: 540b1c48c37a ("rxrpc: Fix deadlock between call creation and sendmsg/recvmsg")
Reported-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: David Howells <dhowells@redhat.com>
---
net/rxrpc/sendmsg.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/net/rxrpc/sendmsg.c b/net/rxrpc/sendmsg.c
index 31c1538c1a8d..27685d8cba1a 100644
--- a/net/rxrpc/sendmsg.c
+++ b/net/rxrpc/sendmsg.c
@@ -517,13 +517,6 @@ int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, size_t len)
ret = -EBADSLT;
if (cmd != RXRPC_CMD_SEND_DATA)
goto error_release_sock;
- ret = -EBUSY;
- if (call->state == RXRPC_CALL_UNINITIALISED ||
- call->state == RXRPC_CALL_CLIENT_AWAIT_CONN ||
- call->state == RXRPC_CALL_SERVER_PREALLOC ||
- call->state == RXRPC_CALL_SERVER_SECURING ||
- call->state == RXRPC_CALL_SERVER_ACCEPTING)
- goto error_release_sock;
call = rxrpc_new_client_call_for_sendmsg(rx, msg, user_call_ID,
exclusive);
/* The socket is now unlocked... */
@@ -531,6 +524,14 @@ int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, size_t len)
return PTR_ERR(call);
/* ... and we have the call lock. */
} else {
+ ret = -EBUSY;
+ if (call->state == RXRPC_CALL_UNINITIALISED ||
+ call->state == RXRPC_CALL_CLIENT_AWAIT_CONN ||
+ call->state == RXRPC_CALL_SERVER_PREALLOC ||
+ call->state == RXRPC_CALL_SERVER_SECURING ||
+ call->state == RXRPC_CALL_SERVER_ACCEPTING)
+ goto error_release_sock;
+
ret = mutex_lock_interruptible(&call->user_mutex);
release_sock(&rx->sk);
if (ret < 0) {
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net] rxrpc: Fix potential NULL-pointer exception
2017-03-02 23:26 David Howells
2017-03-02 23:30 ` David Howells
@ 2017-03-03 17:48 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2017-03-03 17:48 UTC (permalink / raw)
To: dhowells; +Cc: netdev, linux-afs, linux-kernel
From: David Howells <dhowells@redhat.com>
Date: Thu, 02 Mar 2017 23:26:13 +0000
> Fix a potential NULL-pointer exception in rxrpc_do_sendmsg(). The call
> state check that I added should have gone into the else-body of the
> if-statement where we actually have a call to check.
>
> Found by CoverityScan CID#1414316 ("Dereference after null check").
>
> Fixes: 540b1c48c37a ("rxrpc: Fix deadlock between call creation and sendmsg/recvmsg")
> Reported-by: Colin Ian King <colin.king@canonical.com>
> Signed-off-by: David Howells <dhowells@redhat.com>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] rxrpc: Fix potential NULL-pointer exception
2017-03-02 23:26 David Howells
@ 2017-03-02 23:30 ` David Howells
2017-03-03 17:48 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: David Howells @ 2017-03-02 23:30 UTC (permalink / raw)
Cc: dhowells, netdev, linux-afs, linux-kernel
David Howells <dhowells@redhat.com> wrote:
> Fix a potential NULL-pointer exception in rxrpc_do_sendmsg(). The call
> state check that I added should have gone into the else-body of the
> if-statement where we actually have a call to check.
>
> Found by CoverityScan CID#1414316 ("Dereference after null check").
>
> Fixes: 540b1c48c37a ("rxrpc: Fix deadlock between call creation and sendmsg/recvmsg")
> Reported-by: Colin Ian King <colin.king@canonical.com>
> Signed-off-by: David Howells <dhowells@redhat.com>
Please ignore this - there's another patch interposed that I haven't sent
upstream yet. Will rebase on net/master.
David
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net] rxrpc: Fix potential NULL-pointer exception
@ 2017-03-02 23:26 David Howells
2017-03-02 23:30 ` David Howells
2017-03-03 17:48 ` David Miller
0 siblings, 2 replies; 4+ messages in thread
From: David Howells @ 2017-03-02 23:26 UTC (permalink / raw)
To: netdev; +Cc: dhowells, linux-afs, linux-kernel
Fix a potential NULL-pointer exception in rxrpc_do_sendmsg(). The call
state check that I added should have gone into the else-body of the
if-statement where we actually have a call to check.
Found by CoverityScan CID#1414316 ("Dereference after null check").
Fixes: 540b1c48c37a ("rxrpc: Fix deadlock between call creation and sendmsg/recvmsg")
Reported-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: David Howells <dhowells@redhat.com>
---
net/rxrpc/sendmsg.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/net/rxrpc/sendmsg.c b/net/rxrpc/sendmsg.c
index 75c5179227f2..344c2a60627b 100644
--- a/net/rxrpc/sendmsg.c
+++ b/net/rxrpc/sendmsg.c
@@ -518,6 +518,13 @@ int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, size_t len)
ret = -EBADSLT;
if (cmd != RXRPC_CMD_SEND_DATA)
goto error_release_sock;
+ call = rxrpc_new_client_call_for_sendmsg(rx, msg, user_call_ID,
+ exclusive);
+ /* The socket is now unlocked... */
+ if (IS_ERR(call))
+ return PTR_ERR(call);
+ /* ... and we have the call lock. */
+ } else {
switch (READ_ONCE(call->state)) {
case RXRPC_CALL_UNINITIALISED:
case RXRPC_CALL_CLIENT_AWAIT_CONN:
@@ -529,13 +536,7 @@ int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, size_t len)
default:
break;
}
- call = rxrpc_new_client_call_for_sendmsg(rx, msg, user_call_ID,
- exclusive);
- /* The socket is now unlocked... */
- if (IS_ERR(call))
- return PTR_ERR(call);
- /* ... and we have the call lock. */
- } else {
+
ret = mutex_lock_interruptible(&call->user_mutex);
release_sock(&rx->sk);
if (ret < 0) {
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-03-03 18:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-02 23:48 [PATCH net] rxrpc: Fix potential NULL-pointer exception David Howells
-- strict thread matches above, loose matches on Subject: below --
2017-03-02 23:26 David Howells
2017-03-02 23:30 ` David Howells
2017-03-03 17:48 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).