<feed xmlns='http://www.w3.org/2005/Atom'>
<title>wireguard-linux-compat/src/compat, branch master</title>
<subtitle>WireGuard kernel module backport for Linux 3.10 - 5.5</subtitle>
<id>https://git.zx2c4.com/wireguard-linux-compat/atom/src/compat?h=master</id>
<link rel='self' href='https://git.zx2c4.com/wireguard-linux-compat/atom/src/compat?h=master'/>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux-compat/'/>
<updated>2022-06-29T13:36:49Z</updated>
<entry>
<title>compat: drop CentOS 8 Stream support</title>
<updated>2022-06-29T13:36:49Z</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2022-06-29T13:36:49Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux-compat/commit/?id=3d3c92b4711b42169137b2ddf42ed4382e2babdf'/>
<id>urn:sha1:3d3c92b4711b42169137b2ddf42ed4382e2babdf</id>
<content type='text'>
Nobody uses this and it's impossible to maintain given the current CI
situation.

RHEL 7 and 8 release remain for now, though that might not always be the
case. See the link for details.

Link: https://lists.zx2c4.com/pipermail/wireguard/2022-June/007664.html
Suggested-by: Philip J. Perry &lt;phil@elrepo.org&gt;
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>compat: do not backport ktime_get_coarse_boottime_ns to c8s</title>
<updated>2022-06-28T10:44:18Z</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2022-06-28T10:43:06Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux-compat/commit/?id=99935b07b48a2ff696d64996277d89efe8242d37'/>
<id>urn:sha1:99935b07b48a2ff696d64996277d89efe8242d37</id>
<content type='text'>
Also bump the c8s version stamp.

Reported-by: Vladimír Beneš &lt;vbenes@redhat.com&gt;
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>compat: handle backported rng and blake2s</title>
<updated>2022-06-22T15:14:00Z</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2022-06-22T13:41:15Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux-compat/commit/?id=3ec3e822b615e8f07ed0dfc464e026bb508bbcdc'/>
<id>urn:sha1:3ec3e822b615e8f07ed0dfc464e026bb508bbcdc</id>
<content type='text'>
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>device: check for metadata_dst with skb_valid_dst()</title>
<updated>2022-04-14T12:49:25Z</updated>
<author>
<name>Nikolay Aleksandrov</name>
<email>razor@blackwall.org</email>
</author>
<published>2022-04-14T10:44:57Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux-compat/commit/?id=f9d9b4db6fcdb06bd54d876255e66fee767bc87f'/>
<id>urn:sha1:f9d9b4db6fcdb06bd54d876255e66fee767bc87f</id>
<content type='text'>
When we try to transmit an skb with md_dst attached through wireguard
we hit a null pointer dereference in wg_xmit() due to the use of
dst_mtu() which calls into dst_blackhole_mtu() which in turn tries to
dereference dst-&gt;dev.

Since wireguard doesn't use md_dsts we should use skb_valid_dst(), which
checks for DST_METADATA flag, and if it's set, then falls back to
wireguard's device mtu. That gives us the best chance of transmitting
the packet; otherwise if the blackhole netdev is used we'd get
ETH_MIN_MTU.

 [  263.693506] BUG: kernel NULL pointer dereference, address: 00000000000000e0
 [  263.693908] #PF: supervisor read access in kernel mode
 [  263.694174] #PF: error_code(0x0000) - not-present page
 [  263.694424] PGD 0 P4D 0
 [  263.694653] Oops: 0000 [#1] PREEMPT SMP NOPTI
 [  263.694876] CPU: 5 PID: 951 Comm: mausezahn Kdump: loaded Not tainted 5.18.0-rc1+ #522
 [  263.695190] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1.fc35 04/01/2014
 [  263.695529] RIP: 0010:dst_blackhole_mtu+0x17/0x20
 [  263.695770] Code: 00 00 00 0f 1f 44 00 00 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 8b 47 10 48 83 e0 fc 8b 40 04 85 c0 75 09 48 8b 07 &lt;8b&gt; 80 e0 00 00 00 c3 66 90 0f 1f 44 00 00 48 89 d7 be 01 00 00 00
 [  263.696339] RSP: 0018:ffffa4a4422fbb28 EFLAGS: 00010246
 [  263.696600] RAX: 0000000000000000 RBX: ffff8ac9c3553000 RCX: 0000000000000000
 [  263.696891] RDX: 0000000000000401 RSI: 00000000fffffe01 RDI: ffffc4a43fb48900
 [  263.697178] RBP: ffffa4a4422fbb90 R08: ffffffff9622635e R09: 0000000000000002
 [  263.697469] R10: ffffffff9b69a6c0 R11: ffffa4a4422fbd0c R12: ffff8ac9d18b1a00
 [  263.697766] R13: ffff8ac9d0ce1840 R14: ffff8ac9d18b1a00 R15: ffff8ac9c3553000
 [  263.698054] FS:  00007f3704c337c0(0000) GS:ffff8acaebf40000(0000) knlGS:0000000000000000
 [  263.698470] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
 [  263.698826] CR2: 00000000000000e0 CR3: 0000000117a5c000 CR4: 00000000000006e0
 [  263.699214] Call Trace:
 [  263.699505]  &lt;TASK&gt;
 [  263.699759]  wg_xmit+0x411/0x450
 [  263.700059]  ? bpf_skb_set_tunnel_key+0x46/0x2d0
 [   263.700382]  ? dev_queue_xmit_nit+0x31/0x2b0
 [  263.700719]  dev_hard_start_xmit+0xd9/0x220
 [  263.701047]  __dev_queue_xmit+0x8b9/0xd30
 [  263.701344]  __bpf_redirect+0x1a4/0x380
 [  263.701664]  __dev_queue_xmit+0x83b/0xd30
 [  263.701961]  ? packet_parse_headers+0xb4/0xf0
 [  263.702275]  packet_sendmsg+0x9a8/0x16a0
 [  263.702596]  ? _raw_spin_unlock_irqrestore+0x23/0x40
 [  263.702933]  sock_sendmsg+0x5e/0x60
 [  263.703239]  __sys_sendto+0xf0/0x160
 [  263.703549]  __x64_sys_sendto+0x20/0x30
 [  263.703853]  do_syscall_64+0x3b/0x90
 [  263.704162]  entry_SYSCALL_64_after_hwframe+0x44/0xae
 [  263.704494] RIP: 0033:0x7f3704d50506
 [  263.704789] Code: 48 c7 c0 ff ff ff ff eb b7 66 2e 0f 1f 84 00 00 00 00 00 90 41 89 ca 64 8b 04 25 18 00 00 00 85 c0 75 11 b8 2c 00 00 00 0f 05 &lt;48&gt; 3d 00 f0 ff ff 77 72 c3 90 55 48 83 ec 30 44 89 4c 24 2c 4c 89
 [  263.705652] RSP: 002b:00007ffe954b0b88 EFLAGS: 00000246 ORIG_RAX: 000000000000002c
 [  263.706141] RAX: ffffffffffffffda RBX: 0000558bb259b490 RCX: 00007f3704d50506
 [  263.706544] RDX: 000000000000004a RSI: 0000558bb259b7b2 RDI: 0000000000000003
 [  263.706952] RBP: 0000000000000000 R08: 00007ffe954b0b90 R09: 0000000000000014
 [  263.707339] R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffe954b0b90
 [  263.707735] R13: 000000000000004a R14: 0000558bb259b7b2 R15: 0000000000000001
 [  263.708132]  &lt;/TASK&gt;
 [  263.708398] Modules linked in: bridge netconsole bonding [last unloaded: bridge]
 [  263.708942] CR2: 00000000000000e0

Link: https://github.com/cilium/cilium/issues/19428
Reported-by: Martynas Pumputis &lt;m@lambda.lt&gt;
Signed-off-by: Nikolay Aleksandrov &lt;razor@blackwall.org&gt;
Acked-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
[Jason: polyfilled for &lt; 4.3]
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>queueing: use CFI-safe ptr_ring cleanup function</title>
<updated>2022-03-02T22:49:51Z</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2022-03-02T22:48:40Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux-compat/commit/?id=4eff63d292f714a67834bfbd7cbc4c0fa0b1dd52'/>
<id>urn:sha1:4eff63d292f714a67834bfbd7cbc4c0fa0b1dd52</id>
<content type='text'>
We make too nuanced use of ptr_ring to entirely move to the skb_array
wrappers, but we at least should avoid the naughty function pointer cast
when cleaning up skbs. Otherwise RAP/CFI will honk at us. This patch
uses the __skb_array_destroy_skb wrapper for the cleanup, rather than
directly providing kfree_skb, which is what other drivers in the same
situation do too.

Reported-by: PaX Team &lt;pageexec@freemail.hu&gt;
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>compat: drop Ubuntu 14.04</title>
<updated>2021-12-13T14:06:45Z</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2021-12-13T14:06:45Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux-compat/commit/?id=4f4c019873d657e0dcc1d8b26fc1bd455c32142a'/>
<id>urn:sha1:4f4c019873d657e0dcc1d8b26fc1bd455c32142a</id>
<content type='text'>
It's been over a year since we announced sunsetting this.

Link: https://lore.kernel.org/wireguard/CAHmME9rckipsdZYW+LA=x6wCMybdFFA+VqoogFXnR=kHYiCteg@mail.gmail.com/T
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>compat: udp_tunnel: don't take reference to non-init namespace</title>
<updated>2021-12-06T17:34:54Z</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2021-12-06T17:31:49Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux-compat/commit/?id=8e40dd627085ca9cf1e7ab1725709f26ab0a5b73'/>
<id>urn:sha1:8e40dd627085ca9cf1e7ab1725709f26ab0a5b73</id>
<content type='text'>
The comment to sk_change_net is instructive:

  Kernel sockets, f.e. rtnl or icmp_socket, are a part of a namespace.
  They should not hold a reference to a namespace in order to allow
  to stop it.
  Sockets after sk_change_net should be released using sk_release_kernel

We weren't following these rules before, and were instead using
__sock_create, which means we kept a reference to the namespace, which
in turn meant that interfaces were not cleaned up on namespace
exit.

Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>compat: siphash: use _unaligned version by default</title>
<updated>2021-12-03T22:24:03Z</updated>
<author>
<name>Arnd Bergmann</name>
<email>arnd@arndb.de</email>
</author>
<published>2021-11-29T18:58:57Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux-compat/commit/?id=ea6b8e7be5072553b37df4b0b8ee6e0a37134738'/>
<id>urn:sha1:ea6b8e7be5072553b37df4b0b8ee6e0a37134738</id>
<content type='text'>
On ARM v6 and later, we define CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
because the ordinary load/store instructions (ldr, ldrh, ldrb) can
tolerate any misalignment of the memory address. However, load/store
double and load/store multiple instructions (ldrd, ldm) may still only
be used on memory addresses that are 32-bit aligned, and so we have to
use the CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS macro with care, or we
may end up with a severe performance hit due to alignment traps that
require fixups by the kernel. Testing shows that this currently happens
with clang-13 but not gcc-11. In theory, any compiler version can
produce this bug or other problems, as we are dealing with undefined
behavior in C99 even on architectures that support this in hardware,
see also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100363.

Fortunately, the get_unaligned() accessors do the right thing: when
building for ARMv6 or later, the compiler will emit unaligned accesses
using the ordinary load/store instructions (but avoid the ones that
require 32-bit alignment). When building for older ARM, those accessors
will emit the appropriate sequence of ldrb/mov/orr instructions. And on
architectures that can truly tolerate any kind of misalignment, the
get_unaligned() accessors resolve to the leXX_to_cpup accessors that
operate on aligned addresses.

Since the compiler will in fact emit ldrd or ldm instructions when
building this code for ARM v6 or later, the solution is to use the
unaligned accessors unconditionally on architectures where this is
known to be fast. The _aligned version of the hash function is
however still needed to get the best performance on architectures
that cannot do any unaligned access in hardware.

This new version avoids the undefined behavior and should produce
the fastest hash on all architectures we support.

Reported-by: Ard Biesheuvel &lt;ard.biesheuvel@linaro.org&gt;
Signed-off-by: Arnd Bergmann &lt;arnd@arndb.de&gt;
Reviewed-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
Acked-by: Ard Biesheuvel &lt;ardb@kernel.org&gt;
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>ratelimiter: use kvcalloc() instead of kvzalloc()</title>
<updated>2021-12-03T22:24:03Z</updated>
<author>
<name>Gustavo A. R. Silva</name>
<email>gustavoars@kernel.org</email>
</author>
<published>2021-09-28T22:17:05Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux-compat/commit/?id=5325bc82aa7b6d60fbda2ad4f64b1c676cea01fe'/>
<id>urn:sha1:5325bc82aa7b6d60fbda2ad4f64b1c676cea01fe</id>
<content type='text'>
Use 2-factor argument form kvcalloc() instead of kvzalloc().

Signed-off-by: Gustavo A. R. Silva &lt;gustavoars@kernel.org&gt;
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>device: reset peer src endpoint when netns exits</title>
<updated>2021-12-03T22:24:03Z</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2021-11-29T18:52:14Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux-compat/commit/?id=68abb1b9ba6c9726ea108f796ae7d84f8553d620'/>
<id>urn:sha1:68abb1b9ba6c9726ea108f796ae7d84f8553d620</id>
<content type='text'>
Each peer's endpoint contains a dst_cache entry that takes a reference
to another netdev. When the containing namespace exits, we take down the
socket and prevent future sockets from being created (by setting
creating_net to NULL), which removes that potential reference on the
netns. However, it doesn't release references to the netns that a netdev
cached in dst_cache might be taking, so the netns still might fail to
exit. Since the socket is gimped anyway, we can simply clear all the
dst_caches (by way of clearing the endpoint src), which will release all
references.

However, the current dst_cache_reset function only releases those
references lazily. But it turns out that all of our usages of
wg_socket_clear_peer_endpoint_src are called from contexts that are not
exactly high-speed or bottle-necked. For example, when there's
connection difficulty, or when userspace is reconfiguring the interface.
And in particular for this patch, when the netns is exiting. So for
those cases, it makes more sense to call dst_release immediately. For
that, we add a small helper function to dst_cache.

This patch also adds a test to netns.sh from Hangbin Liu to ensure this
doesn't regress.

Test-by: Hangbin Liu &lt;liuhangbin@gmail.com&gt;
Reported-by: Xiumei Mu &lt;xmu@redhat.com&gt;
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
</feed>
