Skip to content

Commit 627f551

Browse files
committed
wireguard: Update to version 1.0.20200908
Signed-off-by: yaelahsem <[email protected]>
1 parent b14dfe1 commit 627f551

File tree

7 files changed

+33
-27
lines changed

7 files changed

+33
-27
lines changed

net/wireguard/compat/compat.h

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@
3737
#define ISUBUNTU1910
3838
#endif
3939
#endif
40-
#if defined(CONFIG_SUSE_KERNEL) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0) && LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
41-
#define ISOPENSUSE151
42-
#endif
4340

4441
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 0)
4542
#error "WireGuard requires Linux >= 3.10"
@@ -287,7 +284,7 @@ static const struct in6_addr __compat_in6addr_any = IN6ADDR_ANY_INIT;
287284
#define in6addr_any __compat_in6addr_any
288285
#endif
289286

290-
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0) && LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) && !defined(ISOPENSUSE151)
287+
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0) && LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
291288
#include <linux/completion.h>
292289
#include <linux/random.h>
293290
#include <linux/errno.h>
@@ -383,7 +380,7 @@ static inline bool rng_is_initialized(void)
383380
}
384381
#endif
385382

386-
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0) && !defined(ISOPENSUSE151)
383+
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0)
387384
static inline int get_random_bytes_wait(void *buf, int nbytes)
388385
{
389386
int ret = wait_for_random_bytes();
@@ -526,7 +523,7 @@ static inline void __compat_kvfree(const void *addr)
526523
#define priv_destructor destructor
527524
#endif
528525

529-
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0) && !defined(ISOPENSUSE151)
526+
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0)
530527
#define wg_newlink(a,b,c,d,e) wg_newlink(a,b,c,d)
531528
#endif
532529

@@ -665,12 +662,12 @@ struct __compat_dummy_container { char dev; };
665662
#define COMPAT_CANNOT_USE_AVX512
666663
#endif
667664

668-
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) && !defined(ISOPENSUSE151)
665+
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
669666
#include <net/genetlink.h>
670667
#define genl_dump_check_consistent(a, b) genl_dump_check_consistent(a, b, &genl_family)
671668
#endif
672669

673-
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0) && !defined(ISRHEL7) && !defined(ISOPENSUSE151)
670+
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0) && !defined(ISRHEL7)
674671
static inline void *skb_put_data(struct sk_buff *skb, const void *data, unsigned int len)
675672
{
676673
void *tmp = skb_put(skb, len);
@@ -727,7 +724,7 @@ static inline void cpu_to_le32_array(u32 *buf, unsigned int words)
727724
}
728725
#endif
729726

730-
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0) && !defined(ISOPENSUSE151)
727+
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0)
731728
#include <crypto/algapi.h>
732729
static inline void crypto_xor_cpy(u8 *dst, const u8 *src1, const u8 *src2,
733730
unsigned int size)
@@ -829,18 +826,18 @@ static __always_inline void old_rcu_barrier(void)
829826
#define COMPAT_CANNOT_DEPRECIATE_BH_RCU
830827
#endif
831828

832-
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 10) && !defined(ISRHEL8) && !defined(ISOPENSUSE151)
829+
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 10) && !defined(ISRHEL8)
833830
static inline void skb_mark_not_on_list(struct sk_buff *skb)
834831
{
835832
skb->next = NULL;
836833
}
837834
#endif
838835

839836
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0) && !defined(ISRHEL8)
840-
#define NLA_EXACT_LEN NLA_UNSPEC
837+
#define NLA_POLICY_EXACT_LEN(_len) { .type = NLA_UNSPEC, .len = _len }
841838
#endif
842839
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 2, 0) && !defined(ISRHEL8)
843-
#define NLA_MIN_LEN NLA_UNSPEC
840+
#define NLA_POLICY_MIN_LEN(_len) { .type = NLA_UNSPEC, .len = _len }
844841
#define COMPAT_CANNOT_INDIVIDUAL_NETLINK_OPS_POLICY
845842
#endif
846843

@@ -1070,6 +1067,10 @@ static const struct header_ops ip_tunnel_header_ops = { .parse_protocol = ip_tun
10701067
#endif
10711068
#endif
10721069

1070+
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 9, 0)
1071+
#define kfree_sensitive(a) kzfree(a)
1072+
#endif
1073+
10731074
#if defined(ISUBUNTU1604) || defined(ISRHEL7)
10741075
#include <linux/siphash.h>
10751076
#ifndef _WG_LINUX_SIPHASH_H

net/wireguard/dkms.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PACKAGE_NAME="wireguard"
2-
PACKAGE_VERSION="1.0.20200729"
2+
PACKAGE_VERSION="1.0.20200908"
33
AUTOINSTALL=yes
44

55
BUILT_MODULE_NAME="wireguard"

net/wireguard/netlink.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@ static struct genl_family genl_family;
2020
static const struct nla_policy device_policy[WGDEVICE_A_MAX + 1] = {
2121
[WGDEVICE_A_IFINDEX] = { .type = NLA_U32 },
2222
[WGDEVICE_A_IFNAME] = { .type = NLA_NUL_STRING, .len = IFNAMSIZ - 1 },
23-
[WGDEVICE_A_PRIVATE_KEY] = { .type = NLA_EXACT_LEN, .len = NOISE_PUBLIC_KEY_LEN },
24-
[WGDEVICE_A_PUBLIC_KEY] = { .type = NLA_EXACT_LEN, .len = NOISE_PUBLIC_KEY_LEN },
23+
[WGDEVICE_A_PRIVATE_KEY] = NLA_POLICY_EXACT_LEN(NOISE_PUBLIC_KEY_LEN),
24+
[WGDEVICE_A_PUBLIC_KEY] = NLA_POLICY_EXACT_LEN(NOISE_PUBLIC_KEY_LEN),
2525
[WGDEVICE_A_FLAGS] = { .type = NLA_U32 },
2626
[WGDEVICE_A_LISTEN_PORT] = { .type = NLA_U16 },
2727
[WGDEVICE_A_FWMARK] = { .type = NLA_U32 },
2828
[WGDEVICE_A_PEERS] = { .type = NLA_NESTED }
2929
};
3030

3131
static const struct nla_policy peer_policy[WGPEER_A_MAX + 1] = {
32-
[WGPEER_A_PUBLIC_KEY] = { .type = NLA_EXACT_LEN, .len = NOISE_PUBLIC_KEY_LEN },
33-
[WGPEER_A_PRESHARED_KEY] = { .type = NLA_EXACT_LEN, .len = NOISE_SYMMETRIC_KEY_LEN },
32+
[WGPEER_A_PUBLIC_KEY] = NLA_POLICY_EXACT_LEN(NOISE_PUBLIC_KEY_LEN),
33+
[WGPEER_A_PRESHARED_KEY] = NLA_POLICY_EXACT_LEN(NOISE_SYMMETRIC_KEY_LEN),
3434
[WGPEER_A_FLAGS] = { .type = NLA_U32 },
35-
[WGPEER_A_ENDPOINT] = { .type = NLA_MIN_LEN, .len = sizeof(struct sockaddr) },
35+
[WGPEER_A_ENDPOINT] = NLA_POLICY_MIN_LEN(sizeof(struct sockaddr)),
3636
[WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL] = { .type = NLA_U16 },
37-
[WGPEER_A_LAST_HANDSHAKE_TIME] = { .type = NLA_EXACT_LEN, .len = sizeof(struct __kernel_timespec) },
37+
[WGPEER_A_LAST_HANDSHAKE_TIME] = NLA_POLICY_EXACT_LEN(sizeof(struct __kernel_timespec)),
3838
[WGPEER_A_RX_BYTES] = { .type = NLA_U64 },
3939
[WGPEER_A_TX_BYTES] = { .type = NLA_U64 },
4040
[WGPEER_A_ALLOWEDIPS] = { .type = NLA_NESTED },
@@ -43,7 +43,7 @@ static const struct nla_policy peer_policy[WGPEER_A_MAX + 1] = {
4343

4444
static const struct nla_policy allowedip_policy[WGALLOWEDIP_A_MAX + 1] = {
4545
[WGALLOWEDIP_A_FAMILY] = { .type = NLA_U16 },
46-
[WGALLOWEDIP_A_IPADDR] = { .type = NLA_MIN_LEN, .len = sizeof(struct in_addr) },
46+
[WGALLOWEDIP_A_IPADDR] = NLA_POLICY_MIN_LEN(sizeof(struct in_addr)),
4747
[WGALLOWEDIP_A_CIDR_MASK] = { .type = NLA_U8 }
4848
};
4949

net/wireguard/noise.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ static struct noise_keypair *keypair_create(struct wg_peer *peer)
114114

115115
static void keypair_free_rcu(struct rcu_head *rcu)
116116
{
117-
kzfree(container_of(rcu, struct noise_keypair, rcu));
117+
kfree_sensitive(container_of(rcu, struct noise_keypair, rcu));
118118
}
119119

120120
static void keypair_free_kref(struct kref *kref)
@@ -823,7 +823,7 @@ bool wg_noise_handshake_begin_session(struct noise_handshake *handshake,
823823
handshake->entry.peer->device->index_hashtable,
824824
&handshake->entry, &new_keypair->entry);
825825
} else {
826-
kzfree(new_keypair);
826+
kfree_sensitive(new_keypair);
827827
}
828828
rcu_read_unlock_bh();
829829

net/wireguard/peer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ static void rcu_release(struct rcu_head *rcu)
203203
/* The final zeroing takes care of clearing any remaining handshake key
204204
* material and other potentially sensitive information.
205205
*/
206-
kzfree(peer);
206+
kfree_sensitive(peer);
207207
}
208208

209209
static void kref_release(struct kref *refcount)

net/wireguard/peerlookup.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,13 @@ bool wg_index_hashtable_replace(struct index_hashtable *table,
167167
struct index_hashtable_entry *old,
168168
struct index_hashtable_entry *new)
169169
{
170-
if (unlikely(hlist_unhashed(&old->index_hash)))
171-
return false;
170+
bool ret;
171+
172172
spin_lock_bh(&table->lock);
173+
ret = !hlist_unhashed(&old->index_hash);
174+
if (unlikely(!ret))
175+
goto out;
176+
173177
new->index = old->index;
174178
hlist_replace_rcu(&old->index_hash, &new->index_hash);
175179

@@ -180,8 +184,9 @@ bool wg_index_hashtable_replace(struct index_hashtable *table,
180184
* simply gets dropped, which isn't terrible.
181185
*/
182186
INIT_HLIST_NODE(&old->index_hash);
187+
out:
183188
spin_unlock_bh(&table->lock);
184-
return true;
189+
return ret;
185190
}
186191

187192
void wg_index_hashtable_remove(struct index_hashtable *table,

net/wireguard/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#ifndef WIREGUARD_VERSION
2-
#define WIREGUARD_VERSION "1.0.20200729"
2+
#define WIREGUARD_VERSION "1.0.20200908"
33
#endif

0 commit comments

Comments
 (0)