2025-04-15 13:17:20 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
/* OpenVPN data channel offload
|
|
|
|
*
|
|
|
|
* Copyright (C) 2019-2025 OpenVPN, Inc.
|
|
|
|
*
|
|
|
|
* Author: James Yonan <james@openvpn.net>
|
|
|
|
* Antonio Quartulli <antonio@openvpn.net>
|
|
|
|
*/
|
|
|
|
|
2025-04-15 13:17:26 +02:00
|
|
|
#include <crypto/aead.h>
|
2025-04-15 13:17:20 +02:00
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/skbuff.h>
|
2025-04-15 13:17:25 +02:00
|
|
|
#include <net/gro_cells.h>
|
2025-04-15 13:17:24 +02:00
|
|
|
#include <net/gso.h>
|
2025-04-15 13:17:27 +02:00
|
|
|
#include <net/ip.h>
|
2025-04-15 13:17:20 +02:00
|
|
|
|
2025-04-15 13:17:24 +02:00
|
|
|
#include "ovpnpriv.h"
|
|
|
|
#include "peer.h"
|
2025-04-15 13:17:25 +02:00
|
|
|
#include "io.h"
|
2025-04-15 13:17:26 +02:00
|
|
|
#include "bind.h"
|
|
|
|
#include "crypto.h"
|
|
|
|
#include "crypto_aead.h"
|
2025-04-15 13:17:25 +02:00
|
|
|
#include "netlink.h"
|
|
|
|
#include "proto.h"
|
2025-04-15 13:17:28 +02:00
|
|
|
#include "tcp.h"
|
2025-04-15 13:17:24 +02:00
|
|
|
#include "udp.h"
|
|
|
|
#include "skb.h"
|
|
|
|
#include "socket.h"
|
|
|
|
|
2025-04-15 13:17:33 +02:00
|
|
|
const unsigned char ovpn_keepalive_message[OVPN_KEEPALIVE_SIZE] = {
|
|
|
|
0x2a, 0x18, 0x7b, 0xf3, 0x64, 0x1e, 0xb4, 0xcb,
|
|
|
|
0x07, 0xed, 0x2d, 0x0a, 0x98, 0x1f, 0xc7, 0x48
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ovpn_is_keepalive - check if skb contains a keepalive message
|
|
|
|
* @skb: packet to check
|
|
|
|
*
|
|
|
|
* Assumes that the first byte of skb->data is defined.
|
|
|
|
*
|
|
|
|
* Return: true if skb contains a keepalive or false otherwise
|
|
|
|
*/
|
|
|
|
static bool ovpn_is_keepalive(struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
if (*skb->data != ovpn_keepalive_message[0])
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (skb->len != OVPN_KEEPALIVE_SIZE)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!pskb_may_pull(skb, OVPN_KEEPALIVE_SIZE))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return !memcmp(skb->data, ovpn_keepalive_message, OVPN_KEEPALIVE_SIZE);
|
|
|
|
}
|
|
|
|
|
2025-04-15 13:17:25 +02:00
|
|
|
/* Called after decrypt to write the IP packet to the device.
|
|
|
|
* This method is expected to manage/free the skb.
|
|
|
|
*/
|
|
|
|
static void ovpn_netdev_write(struct ovpn_peer *peer, struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
unsigned int pkt_len;
|
|
|
|
int ret;
|
|
|
|
|
ovpn: reset GSO metadata after decapsulation
The ovpn_netdev_write() function is responsible for injecting
decapsulated and decrypted packets back into the local network stack.
Prior to this patch, the skb could retain GSO metadata from the outer,
encrypted tunnel packet. This original GSO metadata, relevant to the
sender's transport context, becomes invalid and misleading for the
tunnel/data path once the inner packet is exposed.
Leaving this stale metadata intact causes internal GSO validation checks
further down the kernel's network stack (validate_xmit_skb()) to fail,
leading to packet drops. The reasons for these failures vary by
protocol, for example:
- for ICMP, no offload handler is registered;
- for TCP and UDP, the respective offload handlers return errors when
comparing skb->len to the outdated skb_shinfo(skb)->gso_size.
By calling skb_gso_reset(skb) we ensure the inner packet is presented to
gro_cells_receive() with a clean state, correctly indicating it is an
individual packet from the perspective of the local stack.
This change eliminates the "Driver has suspect GRO implementation, TCP
performance may be compromised" warning and improves overall TCP
performance by allowing GSO/GRO to function as intended on the
decapsulated traffic.
Fixes: 11851cbd60ea ("ovpn: implement TCP transport")
Reported-by: Gert Doering <gert@greenie.muc.de>
Closes: https://github.com/OpenVPN/ovpn-net-next/issues/4
Tested-by: Gert Doering <gert@greenie.muc.de>
Signed-off-by: Ralf Lici <ralf@mandelbit.com>
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2025-07-01 14:47:44 +02:00
|
|
|
/*
|
|
|
|
* GSO state from the transport layer is not valid for the tunnel/data
|
|
|
|
* path. Reset all GSO fields to prevent any further GSO processing
|
|
|
|
* from entering an inconsistent state.
|
|
|
|
*/
|
|
|
|
skb_gso_reset(skb);
|
|
|
|
|
2025-04-15 13:17:25 +02:00
|
|
|
/* we can't guarantee the packet wasn't corrupted before entering the
|
|
|
|
* VPN, therefore we give other layers a chance to check that
|
|
|
|
*/
|
|
|
|
skb->ip_summed = CHECKSUM_NONE;
|
|
|
|
|
|
|
|
/* skb hash for transport packet no longer valid after decapsulation */
|
|
|
|
skb_clear_hash(skb);
|
|
|
|
|
|
|
|
/* post-decrypt scrub -- prepare to inject encapsulated packet onto the
|
|
|
|
* interface, based on __skb_tunnel_rx() in dst.h
|
|
|
|
*/
|
|
|
|
skb->dev = peer->ovpn->dev;
|
|
|
|
skb_set_queue_mapping(skb, 0);
|
|
|
|
skb_scrub_packet(skb, true);
|
|
|
|
|
2025-04-15 13:17:26 +02:00
|
|
|
/* network header reset in ovpn_decrypt_post() */
|
2025-04-15 13:17:25 +02:00
|
|
|
skb_reset_transport_header(skb);
|
|
|
|
skb_reset_inner_headers(skb);
|
|
|
|
|
|
|
|
/* cause packet to be "received" by the interface */
|
|
|
|
pkt_len = skb->len;
|
|
|
|
ret = gro_cells_receive(&peer->ovpn->gro_cells, skb);
|
2025-04-15 13:17:27 +02:00
|
|
|
if (likely(ret == NET_RX_SUCCESS)) {
|
2025-04-15 13:17:25 +02:00
|
|
|
/* update RX stats with the size of decrypted packet */
|
2025-04-15 13:17:27 +02:00
|
|
|
ovpn_peer_stats_increment_rx(&peer->vpn_stats, pkt_len);
|
2025-04-15 13:17:25 +02:00
|
|
|
dev_dstats_rx_add(peer->ovpn->dev, pkt_len);
|
2025-04-15 13:17:27 +02:00
|
|
|
}
|
2025-04-15 13:17:25 +02:00
|
|
|
}
|
|
|
|
|
2025-04-15 13:17:26 +02:00
|
|
|
void ovpn_decrypt_post(void *data, int ret)
|
2025-04-15 13:17:25 +02:00
|
|
|
{
|
2025-04-15 13:17:26 +02:00
|
|
|
struct ovpn_crypto_key_slot *ks;
|
|
|
|
unsigned int payload_offset = 0;
|
|
|
|
struct sk_buff *skb = data;
|
2025-04-15 13:17:34 +02:00
|
|
|
struct ovpn_socket *sock;
|
2025-04-15 13:17:26 +02:00
|
|
|
struct ovpn_peer *peer;
|
|
|
|
__be16 proto;
|
|
|
|
__be32 *pid;
|
|
|
|
|
|
|
|
/* crypto is happening asynchronously. this function will be called
|
|
|
|
* again later by the crypto callback with a proper return code
|
|
|
|
*/
|
|
|
|
if (unlikely(ret == -EINPROGRESS))
|
|
|
|
return;
|
|
|
|
|
|
|
|
payload_offset = ovpn_skb_cb(skb)->payload_offset;
|
|
|
|
ks = ovpn_skb_cb(skb)->ks;
|
|
|
|
peer = ovpn_skb_cb(skb)->peer;
|
|
|
|
|
|
|
|
/* crypto is done, cleanup skb CB and its members */
|
|
|
|
kfree(ovpn_skb_cb(skb)->iv);
|
|
|
|
kfree(ovpn_skb_cb(skb)->sg);
|
|
|
|
aead_request_free(ovpn_skb_cb(skb)->req);
|
2025-04-15 13:17:25 +02:00
|
|
|
|
|
|
|
if (unlikely(ret < 0))
|
|
|
|
goto drop;
|
|
|
|
|
2025-04-15 13:17:26 +02:00
|
|
|
/* PID sits after the op */
|
|
|
|
pid = (__force __be32 *)(skb->data + OVPN_OPCODE_SIZE);
|
|
|
|
ret = ovpn_pktid_recv(&ks->pid_recv, ntohl(*pid), 0);
|
|
|
|
if (unlikely(ret < 0)) {
|
|
|
|
net_err_ratelimited("%s: PKT ID RX error for peer %u: %d\n",
|
|
|
|
netdev_name(peer->ovpn->dev), peer->id,
|
|
|
|
ret);
|
|
|
|
goto drop;
|
|
|
|
}
|
|
|
|
|
2025-04-15 13:17:33 +02:00
|
|
|
/* keep track of last received authenticated packet for keepalive */
|
|
|
|
WRITE_ONCE(peer->last_recv, ktime_get_real_seconds());
|
|
|
|
|
2025-04-15 13:17:34 +02:00
|
|
|
rcu_read_lock();
|
|
|
|
sock = rcu_dereference(peer->sock);
|
ovpn: ensure sk is still valid during cleanup
Removing a peer while userspace attempts to close its transport
socket triggers a race condition resulting in the following
crash:
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000077: 0000 [#1] SMP KASAN
KASAN: null-ptr-deref in range [0x00000000000003b8-0x00000000000003bf]
CPU: 12 UID: 0 PID: 162 Comm: kworker/12:1 Tainted: G O 6.15.0-rc2-00635-g521139ac3840 #272 PREEMPT(full)
Tainted: [O]=OOT_MODULE
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-20240910_120124-localhost 04/01/2014
Workqueue: events ovpn_peer_keepalive_work [ovpn]
RIP: 0010:ovpn_socket_release+0x23c/0x500 [ovpn]
Code: ea 03 80 3c 02 00 0f 85 71 02 00 00 48 b8 00 00 00 00 00 fc ff df 4d 8b 64 24 18 49 8d bc 24 be 03 00 00 48 89 fa 48 c1 ea 03 <0f> b6 14 02 48 89 f8 83 e0 07 83 c0 01 38 d0 7c 08 84 d2 0f 85 30
RSP: 0018:ffffc90000c9fb18 EFLAGS: 00010217
RAX: dffffc0000000000 RBX: ffff8881148d7940 RCX: ffffffff817787bb
RDX: 0000000000000077 RSI: 0000000000000008 RDI: 00000000000003be
RBP: ffffc90000c9fb30 R08: 0000000000000000 R09: fffffbfff0d3e840
R10: ffffffff869f4207 R11: 0000000000000000 R12: 0000000000000000
R13: ffff888115eb9300 R14: ffffc90000c9fbc8 R15: 000000000000000c
FS: 0000000000000000(0000) GS:ffff8882b0151000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f37266b6114 CR3: 00000000054a8000 CR4: 0000000000750ef0
PKRU: 55555554
Call Trace:
<TASK>
unlock_ovpn+0x8b/0xe0 [ovpn]
ovpn_peer_keepalive_work+0xe3/0x540 [ovpn]
? ovpn_peers_free+0x780/0x780 [ovpn]
? lock_acquire+0x56/0x70
? process_one_work+0x888/0x1740
process_one_work+0x933/0x1740
? pwq_dec_nr_in_flight+0x10b0/0x10b0
? move_linked_works+0x12d/0x2c0
? assign_work+0x163/0x270
worker_thread+0x4d6/0xd90
? preempt_count_sub+0x4c/0x70
? process_one_work+0x1740/0x1740
kthread+0x36c/0x710
? trace_preempt_on+0x8c/0x1e0
? kthread_is_per_cpu+0xc0/0xc0
? preempt_count_sub+0x4c/0x70
? _raw_spin_unlock_irq+0x36/0x60
? calculate_sigpending+0x7b/0xa0
? kthread_is_per_cpu+0xc0/0xc0
ret_from_fork+0x3a/0x80
? kthread_is_per_cpu+0xc0/0xc0
ret_from_fork_asm+0x11/0x20
</TASK>
Modules linked in: ovpn(O)
This happens because the peer deletion operation reaches
ovpn_socket_release() while ovpn_sock->sock (struct socket *)
and its sk member (struct sock *) are still both valid.
Here synchronize_rcu() is invoked, after which ovpn_sock->sock->sk
becomes NULL, due to the concurrent socket closing triggered
from userspace.
After having invoked synchronize_rcu(), ovpn_socket_release() will
attempt dereferencing ovpn_sock->sock->sk, triggering the crash
reported above.
The reason for accessing sk is that we need to retrieve its
protocol and continue the cleanup routine accordingly.
This crash can be easily produced by running openvpn userspace in
client mode with `--keepalive 10 20`, while entirely omitting this
option on the server side.
After 20 seconds ovpn will assume the peer (server) to be dead,
will start removing it and will notify userspace. The latter will
receive the notification and close the transport socket, thus
triggering the crash.
To fix the race condition for good, we need to refactor struct ovpn_socket.
Since ovpn is always only interested in the sock->sk member (struct sock *)
we can directly hold a reference to it, raher than accessing it via
its struct socket container.
This means changing "struct socket *ovpn_socket->sock" to
"struct sock *ovpn_socket->sk".
While acquiring a reference to sk, we can increase its refcounter
without affecting the socket close()/destroy() notification
(which we rely on when userspace closes a socket we are using).
By increasing sk's refcounter we know we can dereference it
in ovpn_socket_release() without incurring in any race condition
anymore.
ovpn_socket_release() will ultimately decrease the reference
counter.
Cc: Oleksandr Natalenko <oleksandr@natalenko.name>
Fixes: 11851cbd60ea ("ovpn: implement TCP transport")
Reported-by: Qingfang Deng <dqfext@gmail.com>
Closes: https://github.com/OpenVPN/ovpn-net-next/issues/1
Tested-by: Gert Doering <gert@greenie.muc.de>
Link: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31575.html
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2025-04-30 02:26:49 +02:00
|
|
|
if (sock && sock->sk->sk_protocol == IPPROTO_UDP)
|
2025-04-15 13:17:34 +02:00
|
|
|
/* check if this peer changed local or remote endpoint */
|
|
|
|
ovpn_peer_endpoints_update(peer, skb);
|
|
|
|
rcu_read_unlock();
|
|
|
|
|
2025-04-15 13:17:26 +02:00
|
|
|
/* point to encapsulated IP packet */
|
|
|
|
__skb_pull(skb, payload_offset);
|
|
|
|
|
|
|
|
/* check if this is a valid datapacket that has to be delivered to the
|
|
|
|
* ovpn interface
|
|
|
|
*/
|
|
|
|
skb_reset_network_header(skb);
|
|
|
|
proto = ovpn_ip_check_protocol(skb);
|
|
|
|
if (unlikely(!proto)) {
|
|
|
|
/* check if null packet */
|
|
|
|
if (unlikely(!pskb_may_pull(skb, 1))) {
|
|
|
|
net_info_ratelimited("%s: NULL packet received from peer %u\n",
|
|
|
|
netdev_name(peer->ovpn->dev),
|
|
|
|
peer->id);
|
|
|
|
goto drop;
|
|
|
|
}
|
|
|
|
|
2025-04-15 13:17:33 +02:00
|
|
|
if (ovpn_is_keepalive(skb)) {
|
|
|
|
net_dbg_ratelimited("%s: ping received from peer %u\n",
|
|
|
|
netdev_name(peer->ovpn->dev),
|
|
|
|
peer->id);
|
|
|
|
/* we drop the packet, but this is not a failure */
|
|
|
|
consume_skb(skb);
|
|
|
|
goto drop_nocount;
|
|
|
|
}
|
|
|
|
|
2025-04-15 13:17:26 +02:00
|
|
|
net_info_ratelimited("%s: unsupported protocol received from peer %u\n",
|
|
|
|
netdev_name(peer->ovpn->dev), peer->id);
|
|
|
|
goto drop;
|
|
|
|
}
|
|
|
|
skb->protocol = proto;
|
|
|
|
|
|
|
|
/* perform Reverse Path Filtering (RPF) */
|
|
|
|
if (unlikely(!ovpn_peer_check_by_src(peer->ovpn, skb, peer))) {
|
|
|
|
if (skb->protocol == htons(ETH_P_IPV6))
|
|
|
|
net_dbg_ratelimited("%s: RPF dropped packet from peer %u, src: %pI6c\n",
|
|
|
|
netdev_name(peer->ovpn->dev),
|
|
|
|
peer->id, &ipv6_hdr(skb)->saddr);
|
|
|
|
else
|
|
|
|
net_dbg_ratelimited("%s: RPF dropped packet from peer %u, src: %pI4\n",
|
|
|
|
netdev_name(peer->ovpn->dev),
|
|
|
|
peer->id, &ip_hdr(skb)->saddr);
|
|
|
|
goto drop;
|
|
|
|
}
|
|
|
|
|
2025-04-15 13:17:25 +02:00
|
|
|
ovpn_netdev_write(peer, skb);
|
|
|
|
/* skb is passed to upper layer - don't free it */
|
|
|
|
skb = NULL;
|
|
|
|
drop:
|
|
|
|
if (unlikely(skb))
|
|
|
|
dev_dstats_rx_dropped(peer->ovpn->dev);
|
2025-04-15 13:17:33 +02:00
|
|
|
kfree_skb(skb);
|
|
|
|
drop_nocount:
|
2025-04-15 13:17:26 +02:00
|
|
|
if (likely(peer))
|
|
|
|
ovpn_peer_put(peer);
|
|
|
|
if (likely(ks))
|
|
|
|
ovpn_crypto_key_slot_put(ks);
|
2025-04-15 13:17:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* RX path entry point: decrypt packet and forward it to the device */
|
|
|
|
void ovpn_recv(struct ovpn_peer *peer, struct sk_buff *skb)
|
|
|
|
{
|
2025-04-15 13:17:26 +02:00
|
|
|
struct ovpn_crypto_key_slot *ks;
|
|
|
|
u8 key_id;
|
|
|
|
|
2025-04-15 13:17:27 +02:00
|
|
|
ovpn_peer_stats_increment_rx(&peer->link_stats, skb->len);
|
|
|
|
|
2025-04-15 13:17:26 +02:00
|
|
|
/* get the key slot matching the key ID in the received packet */
|
|
|
|
key_id = ovpn_key_id_from_skb(skb);
|
|
|
|
ks = ovpn_crypto_key_id_to_slot(&peer->crypto, key_id);
|
|
|
|
if (unlikely(!ks)) {
|
|
|
|
net_info_ratelimited("%s: no available key for peer %u, key-id: %u\n",
|
|
|
|
netdev_name(peer->ovpn->dev), peer->id,
|
|
|
|
key_id);
|
|
|
|
dev_dstats_rx_dropped(peer->ovpn->dev);
|
|
|
|
kfree_skb(skb);
|
|
|
|
ovpn_peer_put(peer);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(ovpn_skb_cb(skb), 0, sizeof(struct ovpn_cb));
|
|
|
|
ovpn_decrypt_post(skb, ovpn_aead_decrypt(peer, ks, skb));
|
2025-04-15 13:17:25 +02:00
|
|
|
}
|
|
|
|
|
2025-04-15 13:17:26 +02:00
|
|
|
void ovpn_encrypt_post(void *data, int ret)
|
2025-04-15 13:17:24 +02:00
|
|
|
{
|
2025-04-15 13:17:26 +02:00
|
|
|
struct ovpn_crypto_key_slot *ks;
|
|
|
|
struct sk_buff *skb = data;
|
2025-04-15 13:17:24 +02:00
|
|
|
struct ovpn_socket *sock;
|
2025-04-15 13:17:26 +02:00
|
|
|
struct ovpn_peer *peer;
|
2025-04-15 13:17:27 +02:00
|
|
|
unsigned int orig_len;
|
2025-04-15 13:17:26 +02:00
|
|
|
|
|
|
|
/* encryption is happening asynchronously. This function will be
|
|
|
|
* called later by the crypto callback with a proper return value
|
|
|
|
*/
|
|
|
|
if (unlikely(ret == -EINPROGRESS))
|
|
|
|
return;
|
|
|
|
|
|
|
|
ks = ovpn_skb_cb(skb)->ks;
|
|
|
|
peer = ovpn_skb_cb(skb)->peer;
|
|
|
|
|
|
|
|
/* crypto is done, cleanup skb CB and its members */
|
|
|
|
kfree(ovpn_skb_cb(skb)->iv);
|
|
|
|
kfree(ovpn_skb_cb(skb)->sg);
|
|
|
|
aead_request_free(ovpn_skb_cb(skb)->req);
|
2025-04-15 13:17:24 +02:00
|
|
|
|
2025-04-15 13:17:37 +02:00
|
|
|
if (unlikely(ret == -ERANGE)) {
|
|
|
|
/* we ran out of IVs and we must kill the key as it can't be
|
|
|
|
* use anymore
|
|
|
|
*/
|
|
|
|
netdev_warn(peer->ovpn->dev,
|
|
|
|
"killing key %u for peer %u\n", ks->key_id,
|
|
|
|
peer->id);
|
|
|
|
if (ovpn_crypto_kill_key(&peer->crypto, ks->key_id))
|
|
|
|
/* let userspace know so that a new key must be negotiated */
|
|
|
|
ovpn_nl_key_swap_notify(peer, ks->key_id);
|
|
|
|
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2025-04-15 13:17:24 +02:00
|
|
|
if (unlikely(ret < 0))
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
skb_mark_not_on_list(skb);
|
2025-04-15 13:17:27 +02:00
|
|
|
orig_len = skb->len;
|
2025-04-15 13:17:24 +02:00
|
|
|
|
|
|
|
rcu_read_lock();
|
|
|
|
sock = rcu_dereference(peer->sock);
|
|
|
|
if (unlikely(!sock))
|
|
|
|
goto err_unlock;
|
|
|
|
|
ovpn: ensure sk is still valid during cleanup
Removing a peer while userspace attempts to close its transport
socket triggers a race condition resulting in the following
crash:
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000077: 0000 [#1] SMP KASAN
KASAN: null-ptr-deref in range [0x00000000000003b8-0x00000000000003bf]
CPU: 12 UID: 0 PID: 162 Comm: kworker/12:1 Tainted: G O 6.15.0-rc2-00635-g521139ac3840 #272 PREEMPT(full)
Tainted: [O]=OOT_MODULE
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-20240910_120124-localhost 04/01/2014
Workqueue: events ovpn_peer_keepalive_work [ovpn]
RIP: 0010:ovpn_socket_release+0x23c/0x500 [ovpn]
Code: ea 03 80 3c 02 00 0f 85 71 02 00 00 48 b8 00 00 00 00 00 fc ff df 4d 8b 64 24 18 49 8d bc 24 be 03 00 00 48 89 fa 48 c1 ea 03 <0f> b6 14 02 48 89 f8 83 e0 07 83 c0 01 38 d0 7c 08 84 d2 0f 85 30
RSP: 0018:ffffc90000c9fb18 EFLAGS: 00010217
RAX: dffffc0000000000 RBX: ffff8881148d7940 RCX: ffffffff817787bb
RDX: 0000000000000077 RSI: 0000000000000008 RDI: 00000000000003be
RBP: ffffc90000c9fb30 R08: 0000000000000000 R09: fffffbfff0d3e840
R10: ffffffff869f4207 R11: 0000000000000000 R12: 0000000000000000
R13: ffff888115eb9300 R14: ffffc90000c9fbc8 R15: 000000000000000c
FS: 0000000000000000(0000) GS:ffff8882b0151000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f37266b6114 CR3: 00000000054a8000 CR4: 0000000000750ef0
PKRU: 55555554
Call Trace:
<TASK>
unlock_ovpn+0x8b/0xe0 [ovpn]
ovpn_peer_keepalive_work+0xe3/0x540 [ovpn]
? ovpn_peers_free+0x780/0x780 [ovpn]
? lock_acquire+0x56/0x70
? process_one_work+0x888/0x1740
process_one_work+0x933/0x1740
? pwq_dec_nr_in_flight+0x10b0/0x10b0
? move_linked_works+0x12d/0x2c0
? assign_work+0x163/0x270
worker_thread+0x4d6/0xd90
? preempt_count_sub+0x4c/0x70
? process_one_work+0x1740/0x1740
kthread+0x36c/0x710
? trace_preempt_on+0x8c/0x1e0
? kthread_is_per_cpu+0xc0/0xc0
? preempt_count_sub+0x4c/0x70
? _raw_spin_unlock_irq+0x36/0x60
? calculate_sigpending+0x7b/0xa0
? kthread_is_per_cpu+0xc0/0xc0
ret_from_fork+0x3a/0x80
? kthread_is_per_cpu+0xc0/0xc0
ret_from_fork_asm+0x11/0x20
</TASK>
Modules linked in: ovpn(O)
This happens because the peer deletion operation reaches
ovpn_socket_release() while ovpn_sock->sock (struct socket *)
and its sk member (struct sock *) are still both valid.
Here synchronize_rcu() is invoked, after which ovpn_sock->sock->sk
becomes NULL, due to the concurrent socket closing triggered
from userspace.
After having invoked synchronize_rcu(), ovpn_socket_release() will
attempt dereferencing ovpn_sock->sock->sk, triggering the crash
reported above.
The reason for accessing sk is that we need to retrieve its
protocol and continue the cleanup routine accordingly.
This crash can be easily produced by running openvpn userspace in
client mode with `--keepalive 10 20`, while entirely omitting this
option on the server side.
After 20 seconds ovpn will assume the peer (server) to be dead,
will start removing it and will notify userspace. The latter will
receive the notification and close the transport socket, thus
triggering the crash.
To fix the race condition for good, we need to refactor struct ovpn_socket.
Since ovpn is always only interested in the sock->sk member (struct sock *)
we can directly hold a reference to it, raher than accessing it via
its struct socket container.
This means changing "struct socket *ovpn_socket->sock" to
"struct sock *ovpn_socket->sk".
While acquiring a reference to sk, we can increase its refcounter
without affecting the socket close()/destroy() notification
(which we rely on when userspace closes a socket we are using).
By increasing sk's refcounter we know we can dereference it
in ovpn_socket_release() without incurring in any race condition
anymore.
ovpn_socket_release() will ultimately decrease the reference
counter.
Cc: Oleksandr Natalenko <oleksandr@natalenko.name>
Fixes: 11851cbd60ea ("ovpn: implement TCP transport")
Reported-by: Qingfang Deng <dqfext@gmail.com>
Closes: https://github.com/OpenVPN/ovpn-net-next/issues/1
Tested-by: Gert Doering <gert@greenie.muc.de>
Link: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31575.html
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2025-04-30 02:26:49 +02:00
|
|
|
switch (sock->sk->sk_protocol) {
|
2025-04-15 13:17:24 +02:00
|
|
|
case IPPROTO_UDP:
|
ovpn: ensure sk is still valid during cleanup
Removing a peer while userspace attempts to close its transport
socket triggers a race condition resulting in the following
crash:
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000077: 0000 [#1] SMP KASAN
KASAN: null-ptr-deref in range [0x00000000000003b8-0x00000000000003bf]
CPU: 12 UID: 0 PID: 162 Comm: kworker/12:1 Tainted: G O 6.15.0-rc2-00635-g521139ac3840 #272 PREEMPT(full)
Tainted: [O]=OOT_MODULE
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-20240910_120124-localhost 04/01/2014
Workqueue: events ovpn_peer_keepalive_work [ovpn]
RIP: 0010:ovpn_socket_release+0x23c/0x500 [ovpn]
Code: ea 03 80 3c 02 00 0f 85 71 02 00 00 48 b8 00 00 00 00 00 fc ff df 4d 8b 64 24 18 49 8d bc 24 be 03 00 00 48 89 fa 48 c1 ea 03 <0f> b6 14 02 48 89 f8 83 e0 07 83 c0 01 38 d0 7c 08 84 d2 0f 85 30
RSP: 0018:ffffc90000c9fb18 EFLAGS: 00010217
RAX: dffffc0000000000 RBX: ffff8881148d7940 RCX: ffffffff817787bb
RDX: 0000000000000077 RSI: 0000000000000008 RDI: 00000000000003be
RBP: ffffc90000c9fb30 R08: 0000000000000000 R09: fffffbfff0d3e840
R10: ffffffff869f4207 R11: 0000000000000000 R12: 0000000000000000
R13: ffff888115eb9300 R14: ffffc90000c9fbc8 R15: 000000000000000c
FS: 0000000000000000(0000) GS:ffff8882b0151000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f37266b6114 CR3: 00000000054a8000 CR4: 0000000000750ef0
PKRU: 55555554
Call Trace:
<TASK>
unlock_ovpn+0x8b/0xe0 [ovpn]
ovpn_peer_keepalive_work+0xe3/0x540 [ovpn]
? ovpn_peers_free+0x780/0x780 [ovpn]
? lock_acquire+0x56/0x70
? process_one_work+0x888/0x1740
process_one_work+0x933/0x1740
? pwq_dec_nr_in_flight+0x10b0/0x10b0
? move_linked_works+0x12d/0x2c0
? assign_work+0x163/0x270
worker_thread+0x4d6/0xd90
? preempt_count_sub+0x4c/0x70
? process_one_work+0x1740/0x1740
kthread+0x36c/0x710
? trace_preempt_on+0x8c/0x1e0
? kthread_is_per_cpu+0xc0/0xc0
? preempt_count_sub+0x4c/0x70
? _raw_spin_unlock_irq+0x36/0x60
? calculate_sigpending+0x7b/0xa0
? kthread_is_per_cpu+0xc0/0xc0
ret_from_fork+0x3a/0x80
? kthread_is_per_cpu+0xc0/0xc0
ret_from_fork_asm+0x11/0x20
</TASK>
Modules linked in: ovpn(O)
This happens because the peer deletion operation reaches
ovpn_socket_release() while ovpn_sock->sock (struct socket *)
and its sk member (struct sock *) are still both valid.
Here synchronize_rcu() is invoked, after which ovpn_sock->sock->sk
becomes NULL, due to the concurrent socket closing triggered
from userspace.
After having invoked synchronize_rcu(), ovpn_socket_release() will
attempt dereferencing ovpn_sock->sock->sk, triggering the crash
reported above.
The reason for accessing sk is that we need to retrieve its
protocol and continue the cleanup routine accordingly.
This crash can be easily produced by running openvpn userspace in
client mode with `--keepalive 10 20`, while entirely omitting this
option on the server side.
After 20 seconds ovpn will assume the peer (server) to be dead,
will start removing it and will notify userspace. The latter will
receive the notification and close the transport socket, thus
triggering the crash.
To fix the race condition for good, we need to refactor struct ovpn_socket.
Since ovpn is always only interested in the sock->sk member (struct sock *)
we can directly hold a reference to it, raher than accessing it via
its struct socket container.
This means changing "struct socket *ovpn_socket->sock" to
"struct sock *ovpn_socket->sk".
While acquiring a reference to sk, we can increase its refcounter
without affecting the socket close()/destroy() notification
(which we rely on when userspace closes a socket we are using).
By increasing sk's refcounter we know we can dereference it
in ovpn_socket_release() without incurring in any race condition
anymore.
ovpn_socket_release() will ultimately decrease the reference
counter.
Cc: Oleksandr Natalenko <oleksandr@natalenko.name>
Fixes: 11851cbd60ea ("ovpn: implement TCP transport")
Reported-by: Qingfang Deng <dqfext@gmail.com>
Closes: https://github.com/OpenVPN/ovpn-net-next/issues/1
Tested-by: Gert Doering <gert@greenie.muc.de>
Link: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31575.html
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2025-04-30 02:26:49 +02:00
|
|
|
ovpn_udp_send_skb(peer, sock->sk, skb);
|
2025-04-15 13:17:24 +02:00
|
|
|
break;
|
2025-04-15 13:17:28 +02:00
|
|
|
case IPPROTO_TCP:
|
ovpn: ensure sk is still valid during cleanup
Removing a peer while userspace attempts to close its transport
socket triggers a race condition resulting in the following
crash:
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000077: 0000 [#1] SMP KASAN
KASAN: null-ptr-deref in range [0x00000000000003b8-0x00000000000003bf]
CPU: 12 UID: 0 PID: 162 Comm: kworker/12:1 Tainted: G O 6.15.0-rc2-00635-g521139ac3840 #272 PREEMPT(full)
Tainted: [O]=OOT_MODULE
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-20240910_120124-localhost 04/01/2014
Workqueue: events ovpn_peer_keepalive_work [ovpn]
RIP: 0010:ovpn_socket_release+0x23c/0x500 [ovpn]
Code: ea 03 80 3c 02 00 0f 85 71 02 00 00 48 b8 00 00 00 00 00 fc ff df 4d 8b 64 24 18 49 8d bc 24 be 03 00 00 48 89 fa 48 c1 ea 03 <0f> b6 14 02 48 89 f8 83 e0 07 83 c0 01 38 d0 7c 08 84 d2 0f 85 30
RSP: 0018:ffffc90000c9fb18 EFLAGS: 00010217
RAX: dffffc0000000000 RBX: ffff8881148d7940 RCX: ffffffff817787bb
RDX: 0000000000000077 RSI: 0000000000000008 RDI: 00000000000003be
RBP: ffffc90000c9fb30 R08: 0000000000000000 R09: fffffbfff0d3e840
R10: ffffffff869f4207 R11: 0000000000000000 R12: 0000000000000000
R13: ffff888115eb9300 R14: ffffc90000c9fbc8 R15: 000000000000000c
FS: 0000000000000000(0000) GS:ffff8882b0151000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f37266b6114 CR3: 00000000054a8000 CR4: 0000000000750ef0
PKRU: 55555554
Call Trace:
<TASK>
unlock_ovpn+0x8b/0xe0 [ovpn]
ovpn_peer_keepalive_work+0xe3/0x540 [ovpn]
? ovpn_peers_free+0x780/0x780 [ovpn]
? lock_acquire+0x56/0x70
? process_one_work+0x888/0x1740
process_one_work+0x933/0x1740
? pwq_dec_nr_in_flight+0x10b0/0x10b0
? move_linked_works+0x12d/0x2c0
? assign_work+0x163/0x270
worker_thread+0x4d6/0xd90
? preempt_count_sub+0x4c/0x70
? process_one_work+0x1740/0x1740
kthread+0x36c/0x710
? trace_preempt_on+0x8c/0x1e0
? kthread_is_per_cpu+0xc0/0xc0
? preempt_count_sub+0x4c/0x70
? _raw_spin_unlock_irq+0x36/0x60
? calculate_sigpending+0x7b/0xa0
? kthread_is_per_cpu+0xc0/0xc0
ret_from_fork+0x3a/0x80
? kthread_is_per_cpu+0xc0/0xc0
ret_from_fork_asm+0x11/0x20
</TASK>
Modules linked in: ovpn(O)
This happens because the peer deletion operation reaches
ovpn_socket_release() while ovpn_sock->sock (struct socket *)
and its sk member (struct sock *) are still both valid.
Here synchronize_rcu() is invoked, after which ovpn_sock->sock->sk
becomes NULL, due to the concurrent socket closing triggered
from userspace.
After having invoked synchronize_rcu(), ovpn_socket_release() will
attempt dereferencing ovpn_sock->sock->sk, triggering the crash
reported above.
The reason for accessing sk is that we need to retrieve its
protocol and continue the cleanup routine accordingly.
This crash can be easily produced by running openvpn userspace in
client mode with `--keepalive 10 20`, while entirely omitting this
option on the server side.
After 20 seconds ovpn will assume the peer (server) to be dead,
will start removing it and will notify userspace. The latter will
receive the notification and close the transport socket, thus
triggering the crash.
To fix the race condition for good, we need to refactor struct ovpn_socket.
Since ovpn is always only interested in the sock->sk member (struct sock *)
we can directly hold a reference to it, raher than accessing it via
its struct socket container.
This means changing "struct socket *ovpn_socket->sock" to
"struct sock *ovpn_socket->sk".
While acquiring a reference to sk, we can increase its refcounter
without affecting the socket close()/destroy() notification
(which we rely on when userspace closes a socket we are using).
By increasing sk's refcounter we know we can dereference it
in ovpn_socket_release() without incurring in any race condition
anymore.
ovpn_socket_release() will ultimately decrease the reference
counter.
Cc: Oleksandr Natalenko <oleksandr@natalenko.name>
Fixes: 11851cbd60ea ("ovpn: implement TCP transport")
Reported-by: Qingfang Deng <dqfext@gmail.com>
Closes: https://github.com/OpenVPN/ovpn-net-next/issues/1
Tested-by: Gert Doering <gert@greenie.muc.de>
Link: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31575.html
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2025-04-30 02:26:49 +02:00
|
|
|
ovpn_tcp_send_skb(peer, sock->sk, skb);
|
2025-04-15 13:17:28 +02:00
|
|
|
break;
|
2025-04-15 13:17:24 +02:00
|
|
|
default:
|
|
|
|
/* no transport configured yet */
|
|
|
|
goto err_unlock;
|
|
|
|
}
|
2025-04-15 13:17:27 +02:00
|
|
|
|
|
|
|
ovpn_peer_stats_increment_tx(&peer->link_stats, orig_len);
|
2025-04-15 13:17:33 +02:00
|
|
|
/* keep track of last sent packet for keepalive */
|
|
|
|
WRITE_ONCE(peer->last_sent, ktime_get_real_seconds());
|
2025-04-15 13:17:24 +02:00
|
|
|
/* skb passed down the stack - don't free it */
|
|
|
|
skb = NULL;
|
|
|
|
err_unlock:
|
|
|
|
rcu_read_unlock();
|
|
|
|
err:
|
|
|
|
if (unlikely(skb))
|
|
|
|
dev_dstats_tx_dropped(peer->ovpn->dev);
|
2025-04-15 13:17:26 +02:00
|
|
|
if (likely(peer))
|
|
|
|
ovpn_peer_put(peer);
|
|
|
|
if (likely(ks))
|
|
|
|
ovpn_crypto_key_slot_put(ks);
|
2025-04-15 13:17:24 +02:00
|
|
|
kfree_skb(skb);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool ovpn_encrypt_one(struct ovpn_peer *peer, struct sk_buff *skb)
|
|
|
|
{
|
2025-04-15 13:17:26 +02:00
|
|
|
struct ovpn_crypto_key_slot *ks;
|
|
|
|
|
|
|
|
/* get primary key to be used for encrypting data */
|
|
|
|
ks = ovpn_crypto_key_slot_primary(&peer->crypto);
|
|
|
|
if (unlikely(!ks))
|
|
|
|
return false;
|
2025-04-15 13:17:24 +02:00
|
|
|
|
|
|
|
/* take a reference to the peer because the crypto code may run async.
|
|
|
|
* ovpn_encrypt_post() will release it upon completion
|
|
|
|
*/
|
|
|
|
if (unlikely(!ovpn_peer_hold(peer))) {
|
|
|
|
DEBUG_NET_WARN_ON_ONCE(1);
|
2025-04-15 13:17:26 +02:00
|
|
|
ovpn_crypto_key_slot_put(ks);
|
2025-04-15 13:17:24 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2025-04-15 13:17:26 +02:00
|
|
|
memset(ovpn_skb_cb(skb), 0, sizeof(struct ovpn_cb));
|
|
|
|
ovpn_encrypt_post(skb, ovpn_aead_encrypt(peer, ks, skb));
|
2025-04-15 13:17:24 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* send skb to connected peer, if any */
|
|
|
|
static void ovpn_send(struct ovpn_priv *ovpn, struct sk_buff *skb,
|
|
|
|
struct ovpn_peer *peer)
|
|
|
|
{
|
|
|
|
struct sk_buff *curr, *next;
|
|
|
|
|
|
|
|
/* this might be a GSO-segmented skb list: process each skb
|
|
|
|
* independently
|
|
|
|
*/
|
|
|
|
skb_list_walk_safe(skb, curr, next) {
|
|
|
|
if (unlikely(!ovpn_encrypt_one(peer, curr))) {
|
|
|
|
dev_dstats_tx_dropped(ovpn->dev);
|
|
|
|
kfree_skb(curr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ovpn_peer_put(peer);
|
|
|
|
}
|
2025-04-15 13:17:20 +02:00
|
|
|
|
|
|
|
/* Send user data to the network
|
|
|
|
*/
|
|
|
|
netdev_tx_t ovpn_net_xmit(struct sk_buff *skb, struct net_device *dev)
|
|
|
|
{
|
2025-04-15 13:17:24 +02:00
|
|
|
struct ovpn_priv *ovpn = netdev_priv(dev);
|
|
|
|
struct sk_buff *segments, *curr, *next;
|
|
|
|
struct sk_buff_head skb_list;
|
|
|
|
struct ovpn_peer *peer;
|
|
|
|
__be16 proto;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* reset netfilter state */
|
|
|
|
nf_reset_ct(skb);
|
|
|
|
|
|
|
|
/* verify IP header size in network packet */
|
|
|
|
proto = ovpn_ip_check_protocol(skb);
|
|
|
|
if (unlikely(!proto || skb->protocol != proto))
|
|
|
|
goto drop;
|
|
|
|
|
|
|
|
if (skb_is_gso(skb)) {
|
|
|
|
segments = skb_gso_segment(skb, 0);
|
|
|
|
if (IS_ERR(segments)) {
|
|
|
|
ret = PTR_ERR(segments);
|
|
|
|
net_err_ratelimited("%s: cannot segment payload packet: %d\n",
|
|
|
|
netdev_name(dev), ret);
|
|
|
|
goto drop;
|
|
|
|
}
|
|
|
|
|
|
|
|
consume_skb(skb);
|
|
|
|
skb = segments;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* from this moment on, "skb" might be a list */
|
|
|
|
|
|
|
|
__skb_queue_head_init(&skb_list);
|
|
|
|
skb_list_walk_safe(skb, curr, next) {
|
|
|
|
skb_mark_not_on_list(curr);
|
|
|
|
|
|
|
|
curr = skb_share_check(curr, GFP_ATOMIC);
|
|
|
|
if (unlikely(!curr)) {
|
|
|
|
net_err_ratelimited("%s: skb_share_check failed for payload packet\n",
|
|
|
|
netdev_name(dev));
|
|
|
|
dev_dstats_tx_dropped(ovpn->dev);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
__skb_queue_tail(&skb_list, curr);
|
|
|
|
}
|
|
|
|
skb_list.prev->next = NULL;
|
|
|
|
|
|
|
|
/* retrieve peer serving the destination IP of this packet */
|
|
|
|
peer = ovpn_peer_get_by_dst(ovpn, skb);
|
|
|
|
if (unlikely(!peer)) {
|
2025-05-09 15:32:13 +02:00
|
|
|
switch (skb->protocol) {
|
|
|
|
case htons(ETH_P_IP):
|
|
|
|
net_dbg_ratelimited("%s: no peer to send data to dst=%pI4\n",
|
|
|
|
netdev_name(ovpn->dev),
|
|
|
|
&ip_hdr(skb)->daddr);
|
|
|
|
break;
|
|
|
|
case htons(ETH_P_IPV6):
|
|
|
|
net_dbg_ratelimited("%s: no peer to send data to dst=%pI6c\n",
|
|
|
|
netdev_name(ovpn->dev),
|
|
|
|
&ipv6_hdr(skb)->daddr);
|
|
|
|
break;
|
|
|
|
}
|
2025-04-15 13:17:24 +02:00
|
|
|
goto drop;
|
|
|
|
}
|
2025-05-07 09:58:31 +02:00
|
|
|
/* dst was needed for peer selection - it can now be dropped */
|
|
|
|
skb_dst_drop(skb);
|
2025-04-15 13:17:24 +02:00
|
|
|
|
2025-04-15 13:17:27 +02:00
|
|
|
ovpn_peer_stats_increment_tx(&peer->vpn_stats, skb->len);
|
2025-04-15 13:17:24 +02:00
|
|
|
ovpn_send(ovpn, skb_list.next, peer);
|
|
|
|
|
|
|
|
return NETDEV_TX_OK;
|
|
|
|
|
|
|
|
drop:
|
|
|
|
dev_dstats_tx_dropped(ovpn->dev);
|
2025-04-15 13:17:20 +02:00
|
|
|
skb_tx_error(skb);
|
2025-04-15 13:17:24 +02:00
|
|
|
kfree_skb_list(skb);
|
2025-05-07 14:26:30 +02:00
|
|
|
return NETDEV_TX_OK;
|
2025-04-15 13:17:20 +02:00
|
|
|
}
|
2025-04-15 13:17:33 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ovpn_xmit_special - encrypt and transmit an out-of-band message to peer
|
|
|
|
* @peer: peer to send the message to
|
|
|
|
* @data: message content
|
|
|
|
* @len: message length
|
|
|
|
*
|
|
|
|
* Assumes that caller holds a reference to peer, which will be
|
|
|
|
* passed to ovpn_send()
|
|
|
|
*/
|
|
|
|
void ovpn_xmit_special(struct ovpn_peer *peer, const void *data,
|
|
|
|
const unsigned int len)
|
|
|
|
{
|
|
|
|
struct ovpn_priv *ovpn;
|
|
|
|
struct sk_buff *skb;
|
|
|
|
|
|
|
|
ovpn = peer->ovpn;
|
|
|
|
if (unlikely(!ovpn)) {
|
|
|
|
ovpn_peer_put(peer);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
skb = alloc_skb(256 + len, GFP_ATOMIC);
|
|
|
|
if (unlikely(!skb)) {
|
|
|
|
ovpn_peer_put(peer);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
skb_reserve(skb, 128);
|
|
|
|
skb->priority = TC_PRIO_BESTEFFORT;
|
|
|
|
__skb_put_data(skb, data, len);
|
|
|
|
|
|
|
|
ovpn_send(ovpn, skb, peer);
|
|
|
|
}
|