Compare commits

...

10 Commits

Author SHA1 Message Date
Benoît Ganne
08ff7a9857 ipsec: fix AES CBC IV generation (CVE-2022-46397)
For AES-CBC, the IV must be unpredictable (see NIST SP800-38a Appendix
C). Chaining IVs like is done by ipsecmb and native backends for the
VNET_CRYPTO_OP_FLAG_INIT_IV is fully predictable.
Encrypt a counter as part of the message, making the (predictable)
counter-generated IV unpredictable.

Fixes: VPP-2037
Type: fix

Change-Id: If4f192d62bf97dda553e7573331c75efa11822ae
Signed-off-by: Benoît Ganne <bganne@cisco.com>
2023-02-03 21:05:21 -05:00
Dave Wallace
0a485f517d build: Remove boost dependencies from VOM
- VOM was deprecated in VPP 21.06, but the boost library
  dependencies did not get cleaned up.

Type: make

Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
Change-Id: I0fb860a7a37676c1a1a0981c91f383882d9a820a
(cherry picked from commit bfcd23968246086b5b884f7df1e78adb1a059724)
Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
(cherry picked from commit 90e6edf15cc6a96d41abb304d3f4fafd6797b6d8)
2021-11-30 22:45:54 +00:00
Benoît Ganne
189383ddcc rdma: fix rdma-core install
We should not install symlinks to local build directory.

Type: fix

Change-Id: I81e624dd5775ec9c5dd8c58f578ee51c5acfef73
Signed-off-by: Benoît Ganne <bganne@cisco.com>
(cherry picked from commit 521a9f8eb9d35d2d8783175b89821c6a157237ca)
2021-11-30 14:11:52 +00:00
Andrew Yourtchenko
0385458a56 misc: 21.10.1 Release Notes
Type: docs
Change-Id: I4c9474f78c1226608e11ed4822b7fe091cb70c3e
Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
2021-11-17 13:45:25 +01:00
Matthew Smith
895a0a1fed ip6: set local flag on outbound echo reply
Type: fix

When VPP generates an ICMP echo reply in response to an incoming
echo request to a local address, set VNET_BUFFER_F_LOCALLY_ORIGINATED
on the buffer. It will prevent ip6-rewrite from decrementing the hop
limit.

Outbound IPv4 echo replies also get this flag set.

Change-Id: Iaa229294eb158edb58cf1bf1b7a90da281321406
Signed-off-by: Matthew Smith <mgsmith@netgate.com>
(cherry picked from commit af50b4f727f6d9d85c722c39b459941e01a34217)
2021-11-16 15:43:45 +00:00
Benoît Ganne
48797d204f build: add missing fib headers in packages
Type: fix
Fixes: d6953332db225d5355f50348ef3b09f0525d5282

Change-Id: Ib85fee40e71ebe5bc2b84c62e37298b5e390d520
Signed-off-by: Benoît Ganne <bganne@cisco.com>
(cherry picked from commit d9fc708ee0c8c42fa09dda5d29e9cb0f985558dc)
2021-11-03 16:40:12 +00:00
Andrew Yourtchenko
0e0384cde9 misc: 21.10 Release Notes
Change-Id: I7aa0708d54156166f2dcdc8359e2450a3c4bf9af
Type: docs
Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
2021-10-27 12:39:32 +00:00
Joshua Roys
9298a7ec0c nat: fix static mapping segv
Adding a nat44 static mapping during startup on a DHCP interface leads
to a segv via this path:
- dhcp_client_acquire_address
- ip4_add_del_interface_address
- ip4_add_del_interface_address_internal
- nat44_ed_add_del_interface_address_cb
- nat44_ed_add_static_mapping
- ip4_interface_first_address

Type: fix

Signed-off-by: Joshua Roys <roysjosh@gmail.com>
Change-Id: I38dac8a096b052550f2b87b4e13a950d2cd868b0
(cherry picked from commit f9074fc51544d1849a2df06713c1ccf6cb2eb908)
2021-10-25 19:53:58 +00:00
Florin Coras
c1931b2f09 vcl: grab wrk create lock sooner
Type: fix

Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I0faeef20c57486564122e39f01f31c8c45f38014
(cherry picked from commit 94fef3e67662c6a92e32164d8db6fcf4bc83e79e)
2021-09-24 16:37:13 +00:00
Andrew Yourtchenko
fd9d936b3c misc: Initial changes for stable/2110 branch
Change-Id: Ib3bf8f46a987324be4c7f016b96027558e9d58ef
Type: docs
Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
2021-09-23 14:52:28 +02:00
12 changed files with 573 additions and 40 deletions

View File

@ -2,3 +2,4 @@
host=gerrit.fd.io
port=29418
project=vpp
defaultbranch=stable/2110

File diff suppressed because it is too large Load Diff

View File

@ -42,12 +42,12 @@ endef
define rdma-core_install_cmds
mkdir -p $(rdma-core_install_dir)/lib/pkgconfig
cp -av $(rdma-core_build_dir)/include $(rdma-core_install_dir) > $(rdma-core_install_log)
cp -v $(rdma-core_build_dir)/lib/pkgconfig/libibverbs.pc \
cp -avL $(rdma-core_build_dir)/include $(rdma-core_install_dir) > $(rdma-core_install_log)
cp -avL $(rdma-core_build_dir)/lib/pkgconfig/libibverbs.pc \
$(rdma-core_build_dir)/lib/pkgconfig/libmlx5.pc \
$(rdma-core_build_dir)/lib/pkgconfig/libmlx4.pc \
$(rdma-core_install_dir)/lib/pkgconfig >> $(rdma-core_install_log)
cp -v $(rdma-core_build_dir)/lib/statics/libibverbs.a \
cp -avL $(rdma-core_build_dir)/lib/statics/libibverbs.a \
$(rdma-core_build_dir)/lib/statics/libmlx5.a \
$(rdma-core_build_dir)/lib/statics/libmlx4.a \
$(rdma-core_build_dir)/util/librdma_util.a \

View File

@ -41,7 +41,7 @@ BuildRequires: mbedtls-devel mbedtls
%if 0%{?fedora}
Requires: vpp-lib = %{_version}-%{_release}, vpp-selinux-policy = %{_version}-%{_release}, net-tools, pciutils
Requires: compat-openssl10
Requires: boost-filesystem mbedtls libffi-devel
Requires: mbedtls libffi-devel
BuildRequires: subunit, subunit-devel
BuildRequires: compat-openssl10-devel
BuildRequires: python, python-devel, python-virtualenv, python-ply
@ -50,7 +50,7 @@ BuildRequires: cmake
%else
%if 0%{rhel} >= 7
Requires: vpp-lib = %{_version}-%{_release}, vpp-selinux-policy = %{_version}-%{_release}, net-tools, pciutils, python36
Requires: boost-filesystem mbedtls libffi-devel
Requires: mbedtls libffi-devel
BuildRequires: epel-release
BuildRequires: mbedtls-devel mbedtls
BuildREquires: openssl-devel
@ -70,7 +70,6 @@ BuildRequires: redhat-lsb
BuildRequires: apr-devel
BuildRequires: numactl-devel
BuildRequires: autoconf automake libtool byacc bison flex
BuildRequires: boost boost-devel
BuildRequires: selinux-policy selinux-policy-devel
Source: %{name}-%{_version}-%{_release}.tar.xz

View File

@ -3342,7 +3342,7 @@ nat44_ed_add_del_interface_address_cb (ip4_main_t *im, uword opaque,
{
rv = nat44_ed_add_static_mapping (
rp->l_addr, address[0], rp->l_port, rp->e_port, rp->proto,
rp->vrf_id, ~0, rp->flags, rp->pool_addr, rp->tag);
rp->vrf_id, sw_if_index, rp->flags, rp->pool_addr, rp->tag);
if (rv)
{
nat_elog_notice_X1 (sm, "add_static_mapping returned %d",

View File

@ -167,16 +167,19 @@ vcl_worker_alloc_and_init ()
if (vcl_get_worker_index () != ~0)
return 0;
/* Grab lock before selecting mem thread index */
clib_spinlock_lock (&vcm->workers_lock);
/* Use separate heap map entry for worker */
clib_mem_set_thread_index ();
if (pool_elts (vcm->workers) == vcm->cfg.max_workers)
{
VDBG (0, "max-workers %u limit reached", vcm->cfg.max_workers);
return 0;
wrk = 0;
goto done;
}
clib_spinlock_lock (&vcm->workers_lock);
wrk = vcl_worker_alloc ();
vcl_set_worker_index (wrk->wrk_index);
wrk->thread_id = pthread_self ();
@ -203,9 +206,9 @@ vcl_worker_alloc_and_init ()
vec_reset_length (wrk->mq_msg_vector);
vec_validate (wrk->unhandled_evts_vector, 128);
vec_reset_length (wrk->unhandled_evts_vector);
clib_spinlock_unlock (&vcm->workers_lock);
done:
clib_spinlock_unlock (&vcm->workers_lock);
return wrk;
}

View File

@ -1222,6 +1222,9 @@ list(APPEND VNET_HEADERS
fib/fib.h
fib/fib_api.h
fib/ip4_fib.h
fib/ip4_fib_8.h
fib/ip4_fib_16.h
fib/ip4_fib_hash.h
fib/ip6_fib.h
fib/fib_types.h
fib/fib_table.h

View File

@ -337,7 +337,7 @@ typedef struct
i16 crypto_start_offset; /* first buffer offset */
i16 integ_start_offset;
/* adj total_length for integ, e.g.4 bytes for IPSec ESN */
u16 integ_length_adj;
i16 integ_length_adj;
vnet_crypto_op_status_t status : 8;
u8 flags; /**< share same VNET_CRYPTO_OP_FLAG_* values */
} vnet_crypto_async_frame_elt_t;
@ -621,7 +621,7 @@ static_always_inline void
vnet_crypto_async_add_to_frame (vlib_main_t *vm, vnet_crypto_async_frame_t *f,
u32 key_index, u32 crypto_len,
i16 integ_len_adj, i16 crypto_start_offset,
u16 integ_start_offset, u32 buffer_index,
i16 integ_start_offset, u32 buffer_index,
u16 next_node, u8 *iv, u8 *tag, u8 *aad,
u8 flags)
{

View File

@ -351,6 +351,9 @@ ip6_icmp_echo_request (vlib_main_t * vm,
vnet_buffer (p1)->sw_if_index[VLIB_RX]);
vnet_buffer (p1)->sw_if_index[VLIB_TX] = fib_index1;
p0->flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
p1->flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
/* verify speculative enqueues, maybe switch current next frame */
/* if next0==next1==next_index then nothing special needs to be done */
vlib_validate_buffer_enqueue_x2 (vm, node, next_index,
@ -404,6 +407,7 @@ ip6_icmp_echo_request (vlib_main_t * vm,
vnet_buffer (p0)->sw_if_index[VLIB_RX]);
vnet_buffer (p0)->sw_if_index[VLIB_TX] = fib_index0;
p0->flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
/* Verify speculative enqueue, maybe switch current next frame */
vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
to_next, n_left_to_next,

View File

@ -236,6 +236,24 @@ esp_get_ip6_hdr_len (ip6_header_t * ip6, ip6_ext_header_t ** ext_hdr)
return len;
}
/* IPsec IV generation: IVs requirements differ depending of the
* encryption mode: IVs must be unpredictable for AES-CBC whereas it can
* be predictable but should never be reused with the same key material
* for CTR and GCM.
* We use a packet counter as the IV for CTR and GCM, and to ensure the
* IV is unpredictable for CBC, it is then encrypted using the same key
* as the message. You can refer to NIST SP800-38a and NIST SP800-38d
* for more details. */
static_always_inline void *
esp_generate_iv (ipsec_sa_t *sa, void *payload, int iv_sz)
{
ASSERT (iv_sz >= sizeof (u64));
u64 *iv = (u64 *) (payload - iv_sz);
clib_memset_u8 (iv, 0, iv_sz);
*iv = sa->iv_counter++;
return iv;
}
static_always_inline void
esp_process_chained_ops (vlib_main_t * vm, vlib_node_runtime_t * node,
vnet_crypto_op_t * ops, vlib_buffer_t * b[],
@ -389,27 +407,29 @@ esp_prepare_sync_op (vlib_main_t *vm, ipsec_per_thread_data_t *ptd,
vnet_crypto_op_t *op;
vec_add2_aligned (crypto_ops[0], op, 1, CLIB_CACHE_LINE_BYTES);
vnet_crypto_op_init (op, sa0->crypto_enc_op_id);
u8 *crypto_start = payload;
/* esp_add_footer_and_icv() in esp_encrypt_inline() makes sure we always
* have enough space for ESP header and footer which includes ICV */
ASSERT (payload_len > icv_sz);
u16 crypto_len = payload_len - icv_sz;
/* generate the IV in front of the payload */
void *pkt_iv = esp_generate_iv (sa0, payload, iv_sz);
op->src = op->dst = payload;
op->key_index = sa0->crypto_key_index;
op->len = payload_len - icv_sz;
op->user_data = bi;
if (ipsec_sa_is_set_IS_CTR (sa0))
{
ASSERT (sizeof (u64) == iv_sz);
/* construct nonce in a scratch space in front of the IP header */
esp_ctr_nonce_t *nonce =
(esp_ctr_nonce_t *) (payload - sizeof (u64) - hdr_len -
sizeof (*nonce));
u64 *pkt_iv = (u64 *) (payload - sizeof (u64));
(esp_ctr_nonce_t *) (pkt_iv - hdr_len - sizeof (*nonce));
if (ipsec_sa_is_set_IS_AEAD (sa0))
{
/* constuct aad in a scratch space in front of the nonce */
op->aad = (u8 *) nonce - sizeof (esp_aead_t);
op->aad_len = esp_aad_fill (op->aad, esp, sa0, seq_hi);
op->tag = payload + op->len;
op->tag = payload + crypto_len;
op->tag_len = 16;
}
else
@ -418,13 +438,17 @@ esp_prepare_sync_op (vlib_main_t *vm, ipsec_per_thread_data_t *ptd,
}
nonce->salt = sa0->salt;
nonce->iv = *pkt_iv = clib_host_to_net_u64 (sa0->ctr_iv_counter++);
nonce->iv = *(u64 *) pkt_iv;
op->iv = (u8 *) nonce;
}
else
{
op->iv = payload - iv_sz;
op->flags = VNET_CRYPTO_OP_FLAG_INIT_IV;
/* construct zero iv in front of the IP header */
op->iv = pkt_iv - hdr_len - iv_sz;
clib_memset_u8 (op->iv, 0, iv_sz);
/* include iv field in crypto */
crypto_start -= iv_sz;
crypto_len += iv_sz;
}
if (lb != b[0])
@ -433,8 +457,15 @@ esp_prepare_sync_op (vlib_main_t *vm, ipsec_per_thread_data_t *ptd,
op->flags |= VNET_CRYPTO_OP_FLAG_CHAINED_BUFFERS;
op->chunk_index = vec_len (ptd->chunks);
op->tag = vlib_buffer_get_tail (lb) - icv_sz;
esp_encrypt_chain_crypto (vm, ptd, sa0, b[0], lb, icv_sz, payload,
payload_len, &op->n_chunks);
esp_encrypt_chain_crypto (vm, ptd, sa0, b[0], lb, icv_sz,
crypto_start, crypto_len + icv_sz,
&op->n_chunks);
}
else
{
/* not chained */
op->src = op->dst = crypto_start;
op->len = crypto_len;
}
}
@ -484,26 +515,26 @@ esp_prepare_async_frame (vlib_main_t *vm, ipsec_per_thread_data_t *ptd,
u8 *tag, *iv, *aad = 0;
u8 flag = 0;
u32 key_index;
i16 crypto_start_offset, integ_start_offset = 0;
i16 crypto_start_offset, integ_start_offset;
u16 crypto_total_len, integ_total_len;
post->next_index = next;
/* crypto */
crypto_start_offset = payload - b->data;
crypto_start_offset = integ_start_offset = payload - b->data;
crypto_total_len = integ_total_len = payload_len - icv_sz;
tag = payload + crypto_total_len;
key_index = sa->linked_key_index;
/* generate the IV in front of the payload */
void *pkt_iv = esp_generate_iv (sa, payload, iv_sz);
if (ipsec_sa_is_set_IS_CTR (sa))
{
ASSERT (sizeof (u64) == iv_sz);
/* construct nonce in a scratch space in front of the IP header */
esp_ctr_nonce_t *nonce = (esp_ctr_nonce_t *) (payload - sizeof (u64) -
hdr_len - sizeof (*nonce));
u64 *pkt_iv = (u64 *) (payload - sizeof (u64));
esp_ctr_nonce_t *nonce =
(esp_ctr_nonce_t *) (pkt_iv - hdr_len - sizeof (*nonce));
if (ipsec_sa_is_set_IS_AEAD (sa))
{
/* constuct aad in a scratch space in front of the nonce */
@ -517,13 +548,17 @@ esp_prepare_async_frame (vlib_main_t *vm, ipsec_per_thread_data_t *ptd,
}
nonce->salt = sa->salt;
nonce->iv = *pkt_iv = clib_host_to_net_u64 (sa->ctr_iv_counter++);
nonce->iv = *(u64 *) pkt_iv;
iv = (u8 *) nonce;
}
else
{
iv = payload - iv_sz;
flag |= VNET_CRYPTO_OP_FLAG_INIT_IV;
/* construct zero iv in front of the IP header */
iv = pkt_iv - hdr_len - iv_sz;
clib_memset_u8 (iv, 0, iv_sz);
/* include iv field in crypto */
crypto_start_offset -= iv_sz;
crypto_total_len += iv_sz;
}
if (lb != b)
@ -531,13 +566,14 @@ esp_prepare_async_frame (vlib_main_t *vm, ipsec_per_thread_data_t *ptd,
/* chain */
flag |= VNET_CRYPTO_OP_FLAG_CHAINED_BUFFERS;
tag = vlib_buffer_get_tail (lb) - icv_sz;
crypto_total_len = esp_encrypt_chain_crypto (vm, ptd, sa, b, lb, icv_sz,
payload, payload_len, 0);
crypto_total_len = esp_encrypt_chain_crypto (
vm, ptd, sa, b, lb, icv_sz, b->data + crypto_start_offset,
crypto_total_len + icv_sz, 0);
}
if (sa->integ_op_id)
{
integ_start_offset = crypto_start_offset - iv_sz - sizeof (esp_header_t);
integ_start_offset -= iv_sz + sizeof (esp_header_t);
integ_total_len += iv_sz + sizeof (esp_header_t);
if (b != lb)

View File

@ -132,7 +132,7 @@ typedef struct
u32 seq;
u32 seq_hi;
u64 replay_window;
u64 ctr_iv_counter;
u64 iv_counter;
dpo_id_t dpo;
vnet_crypto_key_index_t crypto_key_index;

View File

@ -38,6 +38,12 @@ configure_file(
${CMAKE_CURRENT_BINARY_DIR}/vnet/config.h
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/vnet/config.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/vpp/vnet
COMPONENT vpp-dev
)
set(VPP_API_FILES
api/vpe_types.api
api/vpe.api