[GH-ISSUE #197] linux kernel 7.1.5 build errors #117

Closed
opened 2026-10-13 21:06:42 +00:00 by bsakaguchi · 1 comment
Owner

Originally created by @olegStreejak on GitHub (Jul 30, 2026).
Original GitHub issue: https://github.com/amnezia-vpn/amneziawg-linux-kernel-module/issues/197

Hello!

Today I tried to install 7.1.5 kernel on my linuxmint installation, and there're errors while building amnezia kernel module:

...
  CC [M]  allowedips.o
  CC [M]  ratelimiter.o
socket.c: In function ‘sock_free’:
socket.c:344:37: error: passing argument 1 of ‘udp_tunnel_sock_release’ from incompatible pointer type [-Wincompatible-pointer-types]
  344 |         udp_tunnel_sock_release(sock->sk_socket);
      |                                 ~~~~^~~~~~~~~~~
      |                                     |
      |                                     struct socket *
In file included from socket.c:17:
/usr/src/linux-headers-7.1.5-070105-generic/include/net/udp_tunnel.h:179:43: note: expected ‘struct sock *’ but argument is of type ‘struct socket *’
  179 | void udp_tunnel_sock_release(struct sock *sk);
      |                              ~~~~~~~~~~~~~^~
socket.c: In function ‘wg_socket_init’:
socket.c:398:36: error: passing argument 2 of ‘setup_udp_tunnel_sock’ from incompatible pointer type [-Wincompatible-pointer-types]
  398 |         setup_udp_tunnel_sock(net, new4, &cfg);
      |                                    ^~~~
      |                                    |
      |                                    struct socket *
/usr/src/linux-headers-7.1.5-070105-generic/include/net/udp_tunnel.h:97:58: note: expected ‘struct sock *’ but argument is of type ‘struct socket *’
   97 | void setup_udp_tunnel_sock(struct net *net, struct sock *sk,
      |                                             ~~~~~~~~~~~~~^~
socket.c:405:49: error: passing argument 1 of ‘udp_tunnel_sock_release’ from incompatible pointer type [-Wincompatible-pointer-types]
  405 |                         udp_tunnel_sock_release(new4);
      |                                                 ^~~~
      |                                                 |
      |                                                 struct socket *
/usr/src/linux-headers-7.1.5-070105-generic/include/net/udp_tunnel.h:179:43: note: expected ‘struct sock *’ but argument is of type ‘struct socket *’
  179 | void udp_tunnel_sock_release(struct sock *sk);
      |                              ~~~~~~~~~~~~~^~
socket.c:413:44: error: passing argument 2 of ‘setup_udp_tunnel_sock’ from incompatible pointer type [-Wincompatible-pointer-types]
  413 |                 setup_udp_tunnel_sock(net, new6, &cfg);
      |                                            ^~~~
      |                                            |
      |                                            struct socket *
/usr/src/linux-headers-7.1.5-070105-generic/include/net/udp_tunnel.h:97:58: note: expected ‘struct sock *’ but argument is of type ‘struct socket *’
   97 | void setup_udp_tunnel_sock(struct net *net, struct sock *sk,
      |                                             ~~~~~~~~~~~~~^~
make[3]: *** [/usr/src/linux-headers-7.1.5-070105-generic/scripts/Makefile.build:289: socket.o] Ошибка 1
...

There was no build errors for kernels 7.1.3, 7.1.4, so I've just looked through the 7.1.5 changelog @https://cdn.kernel.org/pub/linux/kernel/v7.x/ChangeLog-7.1.5 and it seems to me that it's due to these commits:

commit 46d8d5b02f897903a820f007c645c229d06bace5
Author: Kuniyuki Iwashima <kuniyu@google.com>
Date:   Sat May 2 03:13:07 2026 +0000

    tipc: Store struct sock in struct udp_bearer.
    
    [ Upstream commit 1ae552c7b6658c23fba8e964e687785297078880 ]
    
    tipc udp_bearer does not need to access struct socket itself in
    the fast path; it only reads struct sock, and struct socket is
    only used for tunnel setup and teardown.
    
    Let's store struct sock directly in struct udp_bearer.
    
    Note that cleanup_bearer() calls synchronize_net() after
    udp_tunnel_sock_release(), so udp_bearer is not freed until
    inflight fast paths finish.
    
    Note also that synchronize_rcu() is added in the error path
    of tipc_udp_enable() since udp_bearer will be kfree()d
    immediately once we remove synchronize_rcu() in
    udp_tunnel_sock_release().
    
    This can be later converted to kfree_rcu().
    
    Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
    Link: https://patch.msgid.link/20260502031401.3557229-15-kuniyu@google.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Stable-dep-of: c1481c94e74c ("tipc: avoid busy looping in tipc_exit_net()")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 80e9adfed05d687a984b18d2f6ab2ee2bba370cf
Author: Kuniyuki Iwashima <kuniyu@google.com>
Date:   Sat May 2 03:12:55 2026 +0000

    udp_tunnel: Pass struct sock to setup_udp_tunnel_sock().
    
    [ Upstream commit 2cba193628fe523cee6dd61938db2c4563ce15a9 ]
    
    None of the udp_tunnel users need struct socket in their
    fast paths; it is only used for tunnel setup / teardown.
    
    Even setup_udp_tunnel_sock() does not need struct socket.
    
    Let's change setup_udp_tunnel_sock() to take struct sock
    instead of struct socket.
    
    Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
    Link: https://patch.msgid.link/20260502031401.3557229-3-kuniyu@google.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Stable-dep-of: c1481c94e74c ("tipc: avoid busy looping in tipc_exit_net()")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit ea0eb61029e08aa44d70f2ad9a5c5bd984a1efbe
Author: Kuniyuki Iwashima <kuniyu@google.com>
Date:   Sat May 2 03:12:54 2026 +0000

    udp_tunnel: Pass struct sock to udp_tunnel_sock_release().
    
    [ Upstream commit 944bfc1b1c6fe9417668006aae7124886bcca038 ]
    
    None of the udp_tunnel users need struct socket in their
    fast paths; it is only used for tunnel setup / teardown.
    
    While the UDP tunnel interface accepts struct socket, this
    encourages users to store the pointer unnecessarily.  This
    leads to extra dereferences when accessing struct sock fields
    (e.g., sk->sk_user_data instead of sock->sk->sk_user_data).
    
    Furthermore, these dereferences necessitate synchronize_rcu()
    in udp_tunnel_sock_release() to protect the fast paths from
    sock_orphan() setting sk->sk_socket to NULL.
    
    This overhead can be avoided if users store the struct sock
    pointer directly in their private structures.
    
    As a prep, let's change udp_tunnel_sock_release() to take
    struct sock instead of struct socket.
    
    Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
    Link: https://patch.msgid.link/20260502031401.3557229-2-kuniyu@google.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Stable-dep-of: c1481c94e74c ("tipc: avoid busy looping in tipc_exit_net()")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

Hope that can help to correct the source in order to support fresh kernels.

Thank you zillion times for your great work and wish you happiness and great health as well as swift fair peace for us all!

Originally created by @olegStreejak on GitHub (Jul 30, 2026). Original GitHub issue: https://github.com/amnezia-vpn/amneziawg-linux-kernel-module/issues/197 Hello! Today I tried to install 7.1.5 kernel on my linuxmint installation, and there're errors while building amnezia kernel module: ``` ... CC [M] allowedips.o CC [M] ratelimiter.o socket.c: In function ‘sock_free’: socket.c:344:37: error: passing argument 1 of ‘udp_tunnel_sock_release’ from incompatible pointer type [-Wincompatible-pointer-types] 344 | udp_tunnel_sock_release(sock->sk_socket); | ~~~~^~~~~~~~~~~ | | | struct socket * In file included from socket.c:17: /usr/src/linux-headers-7.1.5-070105-generic/include/net/udp_tunnel.h:179:43: note: expected ‘struct sock *’ but argument is of type ‘struct socket *’ 179 | void udp_tunnel_sock_release(struct sock *sk); | ~~~~~~~~~~~~~^~ socket.c: In function ‘wg_socket_init’: socket.c:398:36: error: passing argument 2 of ‘setup_udp_tunnel_sock’ from incompatible pointer type [-Wincompatible-pointer-types] 398 | setup_udp_tunnel_sock(net, new4, &cfg); | ^~~~ | | | struct socket * /usr/src/linux-headers-7.1.5-070105-generic/include/net/udp_tunnel.h:97:58: note: expected ‘struct sock *’ but argument is of type ‘struct socket *’ 97 | void setup_udp_tunnel_sock(struct net *net, struct sock *sk, | ~~~~~~~~~~~~~^~ socket.c:405:49: error: passing argument 1 of ‘udp_tunnel_sock_release’ from incompatible pointer type [-Wincompatible-pointer-types] 405 | udp_tunnel_sock_release(new4); | ^~~~ | | | struct socket * /usr/src/linux-headers-7.1.5-070105-generic/include/net/udp_tunnel.h:179:43: note: expected ‘struct sock *’ but argument is of type ‘struct socket *’ 179 | void udp_tunnel_sock_release(struct sock *sk); | ~~~~~~~~~~~~~^~ socket.c:413:44: error: passing argument 2 of ‘setup_udp_tunnel_sock’ from incompatible pointer type [-Wincompatible-pointer-types] 413 | setup_udp_tunnel_sock(net, new6, &cfg); | ^~~~ | | | struct socket * /usr/src/linux-headers-7.1.5-070105-generic/include/net/udp_tunnel.h:97:58: note: expected ‘struct sock *’ but argument is of type ‘struct socket *’ 97 | void setup_udp_tunnel_sock(struct net *net, struct sock *sk, | ~~~~~~~~~~~~~^~ make[3]: *** [/usr/src/linux-headers-7.1.5-070105-generic/scripts/Makefile.build:289: socket.o] Ошибка 1 ... ``` There was no build errors for kernels 7.1.3, 7.1.4, so I've just looked through the 7.1.5 changelog @https://cdn.kernel.org/pub/linux/kernel/v7.x/ChangeLog-7.1.5 and it seems to me that it's due to these commits: ``` commit 46d8d5b02f897903a820f007c645c229d06bace5 Author: Kuniyuki Iwashima <kuniyu@google.com> Date: Sat May 2 03:13:07 2026 +0000 tipc: Store struct sock in struct udp_bearer. [ Upstream commit 1ae552c7b6658c23fba8e964e687785297078880 ] tipc udp_bearer does not need to access struct socket itself in the fast path; it only reads struct sock, and struct socket is only used for tunnel setup and teardown. Let's store struct sock directly in struct udp_bearer. Note that cleanup_bearer() calls synchronize_net() after udp_tunnel_sock_release(), so udp_bearer is not freed until inflight fast paths finish. Note also that synchronize_rcu() is added in the error path of tipc_udp_enable() since udp_bearer will be kfree()d immediately once we remove synchronize_rcu() in udp_tunnel_sock_release(). This can be later converted to kfree_rcu(). Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com> Link: https://patch.msgid.link/20260502031401.3557229-15-kuniyu@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Stable-dep-of: c1481c94e74c ("tipc: avoid busy looping in tipc_exit_net()") Signed-off-by: Sasha Levin <sashal@kernel.org> commit 80e9adfed05d687a984b18d2f6ab2ee2bba370cf Author: Kuniyuki Iwashima <kuniyu@google.com> Date: Sat May 2 03:12:55 2026 +0000 udp_tunnel: Pass struct sock to setup_udp_tunnel_sock(). [ Upstream commit 2cba193628fe523cee6dd61938db2c4563ce15a9 ] None of the udp_tunnel users need struct socket in their fast paths; it is only used for tunnel setup / teardown. Even setup_udp_tunnel_sock() does not need struct socket. Let's change setup_udp_tunnel_sock() to take struct sock instead of struct socket. Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com> Link: https://patch.msgid.link/20260502031401.3557229-3-kuniyu@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Stable-dep-of: c1481c94e74c ("tipc: avoid busy looping in tipc_exit_net()") Signed-off-by: Sasha Levin <sashal@kernel.org> commit ea0eb61029e08aa44d70f2ad9a5c5bd984a1efbe Author: Kuniyuki Iwashima <kuniyu@google.com> Date: Sat May 2 03:12:54 2026 +0000 udp_tunnel: Pass struct sock to udp_tunnel_sock_release(). [ Upstream commit 944bfc1b1c6fe9417668006aae7124886bcca038 ] None of the udp_tunnel users need struct socket in their fast paths; it is only used for tunnel setup / teardown. While the UDP tunnel interface accepts struct socket, this encourages users to store the pointer unnecessarily. This leads to extra dereferences when accessing struct sock fields (e.g., sk->sk_user_data instead of sock->sk->sk_user_data). Furthermore, these dereferences necessitate synchronize_rcu() in udp_tunnel_sock_release() to protect the fast paths from sock_orphan() setting sk->sk_socket to NULL. This overhead can be avoided if users store the struct sock pointer directly in their private structures. As a prep, let's change udp_tunnel_sock_release() to take struct sock instead of struct socket. Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com> Link: https://patch.msgid.link/20260502031401.3557229-2-kuniyu@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Stable-dep-of: c1481c94e74c ("tipc: avoid busy looping in tipc_exit_net()") Signed-off-by: Sasha Levin <sashal@kernel.org> ``` Hope that can help to correct the source in order to support fresh kernels. Thank you zillion times for your great work and wish you happiness and great health as well as swift fair peace for us all!
Author
Owner

@olegStreejak commented on GitHub (Jul 31, 2026):

Sorry for being so neglecting, see that here's already a pull on this case.

<!-- gh-comment-id:5140676692 --> @olegStreejak commented on GitHub (Jul 31, 2026): Sorry for being so neglecting, see that here's already a [pull](https://github.com/amnezia-vpn/amneziawg-linux-kernel-module/pull/194) on this case.
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
amnezia-vpn/amneziawg-linux-kernel-module#117
No description provided.