* [PATCH 1/3] [IrDA] af_irda.c cleanups
@ 2006-09-11 5:46 Samuel Ortiz
[not found] ` <20060911054636.GA6368-jcdQHdrhKHMdnm+yROfE0A@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Samuel Ortiz @ 2006-09-11 5:46 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, irda-users, Jean Tourrilhes
Hi Dave,
We lock the socket when both releasing and getting a disconnected
notification. In the latter case, we also ste the socket as orphan.
This fixes a potential kernel bug that can be triggered when we get the
disconnection notification before closing the socket.
Signed-off-by: Samuel Ortiz <samuel@sortiz.org>
---
net/irda/af_irda.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c
index 17699ee..7b7cd5b 100644
--- a/net/irda/af_irda.c
+++ b/net/irda/af_irda.c
@@ -132,13 +132,14 @@ static void irda_disconnect_indication(v
/* Prevent race conditions with irda_release() and irda_shutdown() */
if (!sock_flag(sk, SOCK_DEAD) && sk->sk_state != TCP_CLOSE) {
+ lock_sock(sk);
sk->sk_state = TCP_CLOSE;
sk->sk_err = ECONNRESET;
sk->sk_shutdown |= SEND_SHUTDOWN;
sk->sk_state_change(sk);
- /* Uh-oh... Should use sock_orphan ? */
- sock_set_flag(sk, SOCK_DEAD);
+ sock_orphan(sk);
+ release_sock(sk);
/* Close our TSAP.
* If we leave it open, IrLMP put it back into the list of
@@ -1212,6 +1213,7 @@ static int irda_release(struct socket *s
if (sk == NULL)
return 0;
+ lock_sock(sk);
sk->sk_state = TCP_CLOSE;
sk->sk_shutdown |= SEND_SHUTDOWN;
sk->sk_state_change(sk);
@@ -1221,6 +1223,7 @@ static int irda_release(struct socket *s
sock_orphan(sk);
sock->sk = NULL;
+ release_sock(sk);
/* Purge queues (see sock_init_data()) */
skb_queue_purge(&sk->sk_receive_queue);
@@ -1353,6 +1356,7 @@ static int irda_recvmsg_dgram(struct kio
IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
IRDA_ASSERT(self != NULL, return -1;);
+ IRDA_ASSERT(!sock_error(sk), return -1;);
skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT,
flags & MSG_DONTWAIT, &err);
@@ -1405,6 +1409,7 @@ static int irda_recvmsg_stream(struct ki
IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
IRDA_ASSERT(self != NULL, return -1;);
+ IRDA_ASSERT(!sock_error(sk), return -1;);
if (sock->flags & __SO_ACCEPTCON)
return(-EINVAL);
--
1.4.1.1
^ permalink raw reply related [flat|nested] 3+ messages in thread[parent not found: <20060911054636.GA6368-jcdQHdrhKHMdnm+yROfE0A@public.gmane.org>]
* Re: [PATCH 1/3] [IrDA] af_irda.c cleanups [not found] ` <20060911054636.GA6368-jcdQHdrhKHMdnm+yROfE0A@public.gmane.org> @ 2006-09-11 17:50 ` Jean Tourrilhes 2006-09-28 3:05 ` David Miller 1 sibling, 0 replies; 3+ messages in thread From: Jean Tourrilhes @ 2006-09-11 17:50 UTC (permalink / raw) To: Samuel Ortiz Cc: netdev-u79uwXL29TY76Z2rM5mHXA, irda-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f On Mon, Sep 11, 2006 at 08:46:36AM +0300, Samuel Ortiz wrote: > Hi Dave, > > We lock the socket when both releasing and getting a disconnected > notification. In the latter case, we also ste the socket as orphan. > This fixes a potential kernel bug that can be triggered when we get the > disconnection notification before closing the socket. > > Signed-off-by: Samuel Ortiz <samuel-jcdQHdrhKHMdnm+yROfE0A@public.gmane.org> Yes, all those changes look good to me. Go for it ! Jean ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/3] [IrDA] af_irda.c cleanups [not found] ` <20060911054636.GA6368-jcdQHdrhKHMdnm+yROfE0A@public.gmane.org> 2006-09-11 17:50 ` Jean Tourrilhes @ 2006-09-28 3:05 ` David Miller 1 sibling, 0 replies; 3+ messages in thread From: David Miller @ 2006-09-28 3:05 UTC (permalink / raw) To: samuel-jcdQHdrhKHMdnm+yROfE0A Cc: jt-sDzT885Ts8HQT0dZR+AlfA, netdev-u79uwXL29TY76Z2rM5mHXA, irda-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f From: Samuel Ortiz <samuel-jcdQHdrhKHMdnm+yROfE0A@public.gmane.org> Date: Mon, 11 Sep 2006 08:46:36 +0300 > We lock the socket when both releasing and getting a disconnected > notification. In the latter case, we also ste the socket as orphan. > This fixes a potential kernel bug that can be triggered when we get the > disconnection notification before closing the socket. > > Signed-off-by: Samuel Ortiz <samuel-jcdQHdrhKHMdnm+yROfE0A@public.gmane.org> Applied, sorry for taking so long :) ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-09-28 3:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-11 5:46 [PATCH 1/3] [IrDA] af_irda.c cleanups Samuel Ortiz
[not found] ` <20060911054636.GA6368-jcdQHdrhKHMdnm+yROfE0A@public.gmane.org>
2006-09-11 17:50 ` Jean Tourrilhes
2006-09-28 3:05 ` 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).