diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2005-08-23 13:11:30 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2005-08-23 13:11:30 -0400 |
commit | 53b924b31fa53ac3007df3fef6870d5074a9adf8 (patch) | |
tree | 117e7f530fa2aa37751cfd22908cd81253fd08f8 | |
parent | 66a79a19a7c582efd99bb143c3a59fbda006eb39 (diff) |
[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: Ralf Baechle DL5RB <ralf@linux-mips.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/net/sock.h | 5 | ||||
-rw-r--r-- | net/ax25/af_ax25.c | 7 | ||||
-rw-r--r-- | net/netrom/af_netrom.c | 7 | ||||
-rw-r--r-- | net/rose/af_rose.c | 7 |
4 files changed, 8 insertions, 18 deletions
diff --git a/include/net/sock.h b/include/net/sock.h index a1042d08becd..e9b1dbab90d0 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
@@ -384,6 +384,11 @@ enum sock_flags { | |||
384 | SOCK_QUEUE_SHRUNK, /* write queue has been shrunk recently */ | 384 | SOCK_QUEUE_SHRUNK, /* write queue has been shrunk recently */ |
385 | }; | 385 | }; |
386 | 386 | ||
387 | static inline void sock_copy_flags(struct sock *nsk, struct sock *osk) | ||
388 | { | ||
389 | nsk->sk_flags = osk->sk_flags; | ||
390 | } | ||
391 | |||
387 | static inline void sock_set_flag(struct sock *sk, enum sock_flags flag) | 392 | static inline void sock_set_flag(struct sock *sk, enum sock_flags flag) |
388 | { | 393 | { |
389 | __set_bit(flag, &sk->sk_flags); | 394 | __set_bit(flag, &sk->sk_flags); |
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c index 707097deac3d..7d8ecadba668 100644 --- a/net/ax25/af_ax25.c +++ b/net/ax25/af_ax25.c | |||
@@ -875,12 +875,7 @@ struct sock *ax25_make_new(struct sock *osk, struct ax25_dev *ax25_dev) | |||
875 | sk->sk_sndbuf = osk->sk_sndbuf; | 875 | sk->sk_sndbuf = osk->sk_sndbuf; |
876 | sk->sk_state = TCP_ESTABLISHED; | 876 | sk->sk_state = TCP_ESTABLISHED; |
877 | sk->sk_sleep = osk->sk_sleep; | 877 | sk->sk_sleep = osk->sk_sleep; |
878 | 878 | sock_copy_flags(sk, osk); | |
879 | if (sock_flag(osk, SOCK_DBG)) | ||
880 | sock_set_flag(sk, SOCK_DBG); | ||
881 | |||
882 | if (sock_flag(osk, SOCK_ZAPPED)) | ||
883 | sock_set_flag(sk, SOCK_ZAPPED); | ||
884 | 879 | ||
885 | oax25 = ax25_sk(osk); | 880 | oax25 = ax25_sk(osk); |
886 | 881 | ||
diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c index 31ed4a9a1d06..5385835e9267 100644 --- a/net/netrom/af_netrom.c +++ b/net/netrom/af_netrom.c | |||
@@ -459,12 +459,7 @@ static struct sock *nr_make_new(struct sock *osk) | |||
459 | sk->sk_sndbuf = osk->sk_sndbuf; | 459 | sk->sk_sndbuf = osk->sk_sndbuf; |
460 | sk->sk_state = TCP_ESTABLISHED; | 460 | sk->sk_state = TCP_ESTABLISHED; |
461 | sk->sk_sleep = osk->sk_sleep; | 461 | sk->sk_sleep = osk->sk_sleep; |
462 | 462 | sock_copy_flags(sk, osk); | |
463 | if (sock_flag(osk, SOCK_ZAPPED)) | ||
464 | sock_set_flag(sk, SOCK_ZAPPED); | ||
465 | |||
466 | if (sock_flag(osk, SOCK_DBG)) | ||
467 | sock_set_flag(sk, SOCK_DBG); | ||
468 | 463 | ||
469 | skb_queue_head_init(&nr->ack_queue); | 464 | skb_queue_head_init(&nr->ack_queue); |
470 | skb_queue_head_init(&nr->reseq_queue); | 465 | skb_queue_head_init(&nr->reseq_queue); |
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c index 7eb6a5bf93ea..3fe7e562125a 100644 --- a/net/rose/af_rose.c +++ b/net/rose/af_rose.c | |||
@@ -556,12 +556,7 @@ static struct sock *rose_make_new(struct sock *osk) | |||
556 | sk->sk_sndbuf = osk->sk_sndbuf; | 556 | sk->sk_sndbuf = osk->sk_sndbuf; |
557 | sk->sk_state = TCP_ESTABLISHED; | 557 | sk->sk_state = TCP_ESTABLISHED; |
558 | sk->sk_sleep = osk->sk_sleep; | 558 | sk->sk_sleep = osk->sk_sleep; |
559 | 559 | sock_copy_flags(sk, osk); | |
560 | if (sock_flag(osk, SOCK_ZAPPED)) | ||
561 | sock_set_flag(sk, SOCK_ZAPPED); | ||
562 | |||
563 | if (sock_flag(osk, SOCK_DBG)) | ||
564 | sock_set_flag(sk, SOCK_DBG); | ||
565 | 560 | ||
566 | init_timer(&rose->timer); | 561 | init_timer(&rose->timer); |
567 | init_timer(&rose->idletimer); | 562 | init_timer(&rose->idletimer); |