Commit 53b924b3 authored by Ralf Baechle's avatar Ralf Baechle Committed by David S. Miller

[NET]: Fix socket bitop damage

The socket flag cleanups that went into 2.6.12-rc1 are basically oring
the flags of an old socket into the socket just being created.
Unfortunately that one was just initialized by sock_init_data(), so already
has SOCK_ZAPPED set.  As the result zapped sockets are created and all
incoming connection will fail due to this bug which again was carefully
replicated to at least AX.25, NET/ROM or ROSE.

In order to keep the abstraction alive I've introduced sock_copy_flags()
to copy the socket flags from one sockets to another and used that
instead of the bitwise copy thing.  Anyway, the idea here has probably
been to copy all flags, so sock_copy_flags() should be the right thing.
With this the ham radio protocols are usable again, so I hope this will
make it into 2.6.13.
Signed-off-by: default avatarRalf Baechle DL5RB <ralf@linux-mips.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 66a79a19
...@@ -384,6 +384,11 @@ enum sock_flags { ...@@ -384,6 +384,11 @@ enum sock_flags {
SOCK_QUEUE_SHRUNK, /* write queue has been shrunk recently */ SOCK_QUEUE_SHRUNK, /* write queue has been shrunk recently */
}; };
static inline void sock_copy_flags(struct sock *nsk, struct sock *osk)
{
nsk->sk_flags = osk->sk_flags;
}
static inline void sock_set_flag(struct sock *sk, enum sock_flags flag) static inline void sock_set_flag(struct sock *sk, enum sock_flags flag)
{ {
__set_bit(flag, &sk->sk_flags); __set_bit(flag, &sk->sk_flags);
......
...@@ -875,12 +875,7 @@ struct sock *ax25_make_new(struct sock *osk, struct ax25_dev *ax25_dev) ...@@ -875,12 +875,7 @@ struct sock *ax25_make_new(struct sock *osk, struct ax25_dev *ax25_dev)
sk->sk_sndbuf = osk->sk_sndbuf; sk->sk_sndbuf = osk->sk_sndbuf;
sk->sk_state = TCP_ESTABLISHED; sk->sk_state = TCP_ESTABLISHED;
sk->sk_sleep = osk->sk_sleep; sk->sk_sleep = osk->sk_sleep;
sock_copy_flags(sk, osk);
if (sock_flag(osk, SOCK_DBG))
sock_set_flag(sk, SOCK_DBG);
if (sock_flag(osk, SOCK_ZAPPED))
sock_set_flag(sk, SOCK_ZAPPED);
oax25 = ax25_sk(osk); oax25 = ax25_sk(osk);
......
...@@ -459,12 +459,7 @@ static struct sock *nr_make_new(struct sock *osk) ...@@ -459,12 +459,7 @@ static struct sock *nr_make_new(struct sock *osk)
sk->sk_sndbuf = osk->sk_sndbuf; sk->sk_sndbuf = osk->sk_sndbuf;
sk->sk_state = TCP_ESTABLISHED; sk->sk_state = TCP_ESTABLISHED;
sk->sk_sleep = osk->sk_sleep; sk->sk_sleep = osk->sk_sleep;
sock_copy_flags(sk, osk);
if (sock_flag(osk, SOCK_ZAPPED))
sock_set_flag(sk, SOCK_ZAPPED);
if (sock_flag(osk, SOCK_DBG))
sock_set_flag(sk, SOCK_DBG);
skb_queue_head_init(&nr->ack_queue); skb_queue_head_init(&nr->ack_queue);
skb_queue_head_init(&nr->reseq_queue); skb_queue_head_init(&nr->reseq_queue);
......
...@@ -556,12 +556,7 @@ static struct sock *rose_make_new(struct sock *osk) ...@@ -556,12 +556,7 @@ static struct sock *rose_make_new(struct sock *osk)
sk->sk_sndbuf = osk->sk_sndbuf; sk->sk_sndbuf = osk->sk_sndbuf;
sk->sk_state = TCP_ESTABLISHED; sk->sk_state = TCP_ESTABLISHED;
sk->sk_sleep = osk->sk_sleep; sk->sk_sleep = osk->sk_sleep;
sock_copy_flags(sk, osk);
if (sock_flag(osk, SOCK_ZAPPED))
sock_set_flag(sk, SOCK_ZAPPED);
if (sock_flag(osk, SOCK_DBG))
sock_set_flag(sk, SOCK_DBG);
init_timer(&rose->timer); init_timer(&rose->timer);
init_timer(&rose->idletimer); init_timer(&rose->idletimer);
......
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