hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/net/ipv4/inet_connection_sock.c
....@@ -147,10 +147,14 @@
147147 */
148148
149149 sk_for_each_bound(sk2, &tb->owners) {
150
- if (sk != sk2 &&
151
- (!sk->sk_bound_dev_if ||
152
- !sk2->sk_bound_dev_if ||
153
- sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
150
+ int bound_dev_if2;
151
+
152
+ if (sk == sk2)
153
+ continue;
154
+ bound_dev_if2 = READ_ONCE(sk2->sk_bound_dev_if);
155
+ if ((!sk->sk_bound_dev_if ||
156
+ !bound_dev_if2 ||
157
+ sk->sk_bound_dev_if == bound_dev_if2)) {
154158 if (reuse && sk2->sk_reuse &&
155159 sk2->sk_state != TCP_LISTEN) {
156160 if ((!relax ||
....@@ -912,11 +916,25 @@
912916 }
913917 EXPORT_SYMBOL(inet_csk_prepare_forced_close);
914918
919
+static int inet_ulp_can_listen(const struct sock *sk)
920
+{
921
+ const struct inet_connection_sock *icsk = inet_csk(sk);
922
+
923
+ if (icsk->icsk_ulp_ops && !icsk->icsk_ulp_ops->clone)
924
+ return -EINVAL;
925
+
926
+ return 0;
927
+}
928
+
915929 int inet_csk_listen_start(struct sock *sk, int backlog)
916930 {
917931 struct inet_connection_sock *icsk = inet_csk(sk);
918932 struct inet_sock *inet = inet_sk(sk);
919
- int err = -EADDRINUSE;
933
+ int err;
934
+
935
+ err = inet_ulp_can_listen(sk);
936
+ if (unlikely(err))
937
+ return err;
920938
921939 reqsk_queue_alloc(&icsk->icsk_accept_queue);
922940
....@@ -928,6 +946,7 @@
928946 * It is OK, because this socket enters to hash table only
929947 * after validation is complete.
930948 */
949
+ err = -EADDRINUSE;
931950 inet_sk_state_store(sk, TCP_LISTEN);
932951 if (!sk->sk_prot->get_port(sk, inet->inet_num)) {
933952 inet->inet_sport = htons(inet->inet_num);