Commit a23389e4 authored by Jean Tourrilhes's avatar Jean Tourrilhes Committed by Linus Torvalds

[PATCH] : ir256_sock_connect_cli.diff

ir256_sock_connect_cli.diff :
 ---------------------------
	o [CRITICA] Fix socket connect to remove dangerous cli()
	<Tested on SMP>
parent a18e3e5c
...@@ -1022,29 +1022,27 @@ static int irda_connect(struct socket *sock, struct sockaddr *uaddr, ...@@ -1022,29 +1022,27 @@ static int irda_connect(struct socket *sock, struct sockaddr *uaddr,
/* Now the loop */ /* Now the loop */
if (sk->state != TCP_ESTABLISHED && (flags & O_NONBLOCK)) if (sk->state != TCP_ESTABLISHED && (flags & O_NONBLOCK))
return -EINPROGRESS; return -EINPROGRESS;
cli(); /* To avoid races on the sleep */ /* Here, there is a race condition : the state may change between
* our test and the sleep, via irda_connect_confirm().
/* A Connect Ack with Choke or timeout or failed routing will go to * The way to workaround that is to sleep with a timeout, so that
* closed. */ * we don't sleep forever and check the state when waking up.
* 50ms is plenty good enough, because the LAP is already connected.
* Jean II */
while (sk->state == TCP_SYN_SENT) { while (sk->state == TCP_SYN_SENT) {
interruptible_sleep_on(sk->sleep); interruptible_sleep_on_timeout(sk->sleep, HZ/20);
if (signal_pending(current)) { if (signal_pending(current)) {
sti();
return -ERESTARTSYS; return -ERESTARTSYS;
} }
} }
if (sk->state != TCP_ESTABLISHED) { if (sk->state != TCP_ESTABLISHED) {
sti();
sock->state = SS_UNCONNECTED; sock->state = SS_UNCONNECTED;
return sock_error(sk); /* Always set at this point */ return sock_error(sk); /* Always set at this point */
} }
sock->state = SS_CONNECTED; sock->state = SS_CONNECTED;
sti();
/* At this point, IrLMP has assigned our source address */ /* At this point, IrLMP has assigned our source address */
self->saddr = irttp_get_saddr(self->tsap); self->saddr = irttp_get_saddr(self->tsap);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment