From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AFA3B41EAF for ; Thu, 16 Mar 2023 11:36:15 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AA52442D2C; Thu, 16 Mar 2023 11:36:15 +0100 (CET) Received: from mail-yw1-f171.google.com (mail-yw1-f171.google.com [209.85.128.171]) by mails.dpdk.org (Postfix) with ESMTP id 4B2B340DF6 for ; Thu, 16 Mar 2023 11:36:14 +0100 (CET) Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-53d277c1834so22096627b3.10 for ; Thu, 16 Mar 2023 03:36:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678962973; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=b3y/64rVdoOeEc65GgrBai6cLKRZYKpFt85Skx55PKk=; b=e6Bc0+N68xi7npBvOG6nazo3+8ZIotbSBtPbQqOLpfndsXEFE+gUUk3FJ7wQNw1uEB mcRthbnPiiUyIw3CDwyTUxau/a1JP8MpgSbbc5ZmhyRSamfY3g7un87UTfaOl1X6XYOO J5apC5dNry/nUWR/W0VQTGbM26dulB/SnY8X5XeK2Lsf9yaMzRlnc1e8CovoI3pekD/e KA+0CD3QID9e6c/LTMdEGZ+eqiMXaZTRRem0BFsoOIEVOb3f/hYtgtsJ3dCon2LKMDB+ HFlJFXRdTbC7nAQNXE9LF4qMUK9xpxz27IYqyGT611dHt/Q5JITlDllurmG05H6VetVi qFkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678962973; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=b3y/64rVdoOeEc65GgrBai6cLKRZYKpFt85Skx55PKk=; b=0MwdLcNghcBQM58GCdGEkiKsLzNDnhIAlYFrSxQzMIOMyONkriYEly+oYYncJNLXEV vsnYqXDWd07ZePCHbb3Ef6GnC+fOkTLm46K/Op/h8vN/kvjRY61pHki/wEGKoMWP4R5e 3I7ubM+ymYZpY2k8wByjwCNn0CeJZYKrpy2bPzYSJScFGpLdsmexOIxhq3Iu+FpRUDzj 3ToNnDFVvq4VI8el/UqKsIbN+c5BYO+A+4e0oiz3oiq95lAK7QgoIHlmLm0LhWe2zKjP qKth7FgliEucMEdh6zKsvCicW/wRSU7vVNb4iJD3pSJAv8XeBscaxVymTXr1xhbgE2wy cxOA== X-Gm-Message-State: AO0yUKXRq4pX4p5BIKSnYbXCHW9zmvHntX4lYwpbHC5hoIzksXxy8OmB xCKyRX1brskgZrkjmB5rDZfpjgiADPHMCgnIiBk= X-Google-Smtp-Source: AK7set9FvVk/cQdl973YeDxCzRFXS7rCj5mb3SXtKEw4btkhXAzpGfnYX0hbE22uZfhzwoZAmTY4zL/SDDR5o+V2kNU= X-Received: by 2002:a81:4fd7:0:b0:542:927b:1c79 with SMTP id d206-20020a814fd7000000b00542927b1c79mr2216116ywb.3.1678962973401; Thu, 16 Mar 2023 03:36:13 -0700 (PDT) MIME-Version: 1.0 References: <20230223093715.3926893-71-luca.boccassi@gmail.com> <20230315224631.1025649-1-luca.boccassi@gmail.com> <20230315224631.1025649-6-luca.boccassi@gmail.com> <750ee800-dbc3-80dc-775c-dc6d39ccdc7a@redhat.com> In-Reply-To: <750ee800-dbc3-80dc-775c-dc6d39ccdc7a@redhat.com> From: Luca Boccassi Date: Thu, 16 Mar 2023 10:36:02 +0000 Message-ID: Subject: Re: patch 'vhost: fix OOB access for invalid vhost ID' has been queued to stable release 20.11.8 To: Kevin Traynor Cc: David Marchand , Maxime Coquelin , dpdk stable Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org On Thu, 16 Mar 2023 at 10:30, Kevin Traynor wrote: > > On 16/03/2023 09:56, David Marchand wrote: > > On Thu, Mar 16, 2023 at 10:27=E2=80=AFAM Luca Boccassi wrote: > >> > >> On Wed, 15 Mar 2023 at 22:46, wrote: > >>> > >>> Hi, > >>> > >>> FYI, your patch has been queued to stable release 20.11.8 > >>> > >>> Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. > >>> It will be pushed if I get no objections before 03/17/23. So please > >>> shout if anyone has objections. > >>> > >>> Also note that after the patch there's a diff of the upstream commit = vs the > >>> patch applied to the branch. This will indicate if there was any reba= sing > >>> needed to apply to the stable branch. If there were code changes for = rebasing > >>> (ie: not only metadata diffs), please double check that the rebase wa= s > >>> correctly done. > >>> > >>> Queued patches are on a temporary branch at: > >>> https://github.com/bluca/dpdk-stable > >>> > >>> This queued commit can be viewed at: > >>> https://github.com/bluca/dpdk-stable/commit/145ffdbb7ea750f4d3b17446b= de22a805957ad71 > >>> > >>> Thanks. > >>> > >>> Luca Boccassi > >>> > >>> --- > >>> From 145ffdbb7ea750f4d3b17446bde22a805957ad71 Mon Sep 17 00:00:00 20= 01 > >>> From: David Marchand > >>> Date: Mon, 27 Feb 2023 11:59:27 +0100 > >>> Subject: [PATCH] vhost: fix OOB access for invalid vhost ID > >>> > >>> [ upstream commit 1c80a404fd82b816d5c3ebb7cd9e89804ac63984 ] > >>> > >>> The net/vhost pmd currently provides a -1 vid when disabling interrup= t > >>> after a virtio port got disconnected. > >>> > >>> This can be caught when running with ASan. > >>> > >>> First, start dpdk-l3fwd-power in interrupt mode with a net/vhost port= . > >>> > >>> $ ./build-clang/examples/dpdk-l3fwd-power -l0,1 --in-memory \ > >>> -a 0000:00:00.0 \ > >>> --vdev net_vhost0,iface=3Dplop.sock,client=3D1\ > >>> -- \ > >>> -p 0x1 \ > >>> --interrupt-only \ > >>> --config '(0,0,1)' \ > >>> --parse-ptype 0 > >>> > >>> Then start testpmd with virtio-user. > >>> > >>> $ ./build-clang/app/dpdk-testpmd -l0,2 --single-file-segment --in-mem= ory \ > >>> -a 0000:00:00.0 \ > >>> --vdev net_virtio_user0,path=3Dplop.sock,server=3D1 \ > >>> -- \ > >>> -i > >>> > >>> Finally stop testpmd. > >>> ASan then splats in dpdk-l3fwd-power: > >>> > >>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > >>> =3D=3D3641005=3D=3DERROR: AddressSanitizer: global-buffer-overflow on= address > >>> 0x000005ed0778 at pc 0x000001270f81 bp 0x7fddbd2eee20 > >>> sp 0x7fddbd2eee18 > >>> READ of size 8 at 0x000005ed0778 thread T2 > >>> #0 0x1270f80 in get_device .../lib/vhost/vhost.h:801:27 > >>> #1 0x1270f80 in rte_vhost_get_vhost_vring .../lib/vhost/vhost.c:= 951:8 > >>> #2 0x3ac95cb in eth_rxq_intr_disable > >>> .../drivers/net/vhost/rte_eth_vhost.c:647:8 > >>> #3 0x170e0bf in rte_eth_dev_rx_intr_disable > >>> .../lib/ethdev/rte_ethdev.c:5443:25 > >>> #4 0xf72ba7 in turn_on_off_intr .../examples/l3fwd-power/main.c:= 881:4 > >>> #5 0xf71045 in main_intr_loop .../examples/l3fwd-power/main.c:10= 61:6 > >>> #6 0x17f9292 in eal_thread_loop > >>> .../lib/eal/common/eal_common_thread.c:210:9 > >>> #7 0x18373f5 in eal_worker_thread_loop .../lib/eal/linux/eal.c:9= 15:2 > >>> #8 0x7fddc16ae12c in start_thread (/lib64/libc.so.6+0x8b12c) > >>> (BuildId: 81daba31ee66dbd63efdc4252a872949d874d136) > >>> #9 0x7fddc172fbbf in __GI___clone3 (/lib64/libc.so.6+0x10cbbf) > >>> (BuildId: 81daba31ee66dbd63efdc4252a872949d874d136) > >>> > >>> 0x000005ed0778 is located 8 bytes to the left of global variable > >>> 'vhost_devices' defined in '.../lib/vhost/vhost.c:24' > >>> (0x5ed0780) of size 8192 > >>> 0x000005ed0778 is located 20 bytes to the right of global variable > >>> 'vhost_config_log_level' defined in '.../lib/vhost/vhost.c:2= 174' > >>> (0x5ed0760) of size 4 > >>> SUMMARY: AddressSanitizer: global-buffer-overflow > >>> .../lib/vhost/vhost.h:801:27 in get_device > >>> Shadow bytes around the buggy address: > >>> 0x000080bd2090: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 > >>> 0x000080bd20a0: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 > >>> 0x000080bd20b0: f9 f9 f9 f9 00 f9 f9 f9 00 f9 f9 f9 00 f9 f9 f9 > >>> 0x000080bd20c0: 00 00 00 00 00 00 00 f9 f9 f9 f9 f9 04 f9 f9 f9 > >>> 0x000080bd20d0: 00 00 00 00 00 f9 f9 f9 f9 f9 f9 f9 00 00 00 00 > >>> =3D>0x000080bd20e0: 00 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9 04 f9 f9[f9] > >>> 0x000080bd20f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > >>> 0x000080bd2100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > >>> 0x000080bd2110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > >>> 0x000080bd2120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > >>> 0x000080bd2130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > >>> Shadow byte legend (one shadow byte represents 8 application bytes): > >>> Addressable: 00 > >>> Partially addressable: 01 02 03 04 05 06 07 > >>> Heap left redzone: fa > >>> Freed heap region: fd > >>> Stack left redzone: f1 > >>> Stack mid redzone: f2 > >>> Stack right redzone: f3 > >>> Stack after return: f5 > >>> Stack use after scope: f8 > >>> Global redzone: f9 > >>> Global init order: f6 > >>> Poisoned by user: f7 > >>> Container overflow: fc > >>> Array cookie: ac > >>> Intra object redzone: bb > >>> ASan internal: fe > >>> Left alloca redzone: ca > >>> Right alloca redzone: cb > >>> Thread T2 created by T0 here: > >>> #0 0xe98996 in __interceptor_pthread_create > >>> (.examples/dpdk-l3fwd-power+0xe98996) > >>> (BuildId: d0b984a3b0287b9e0f301b73426fa921aeecca3a) > >>> #1 0x1836767 in eal_worker_thread_create .../lib/eal/linux/eal.c= :952:6 > >>> #2 0x1834b83 in rte_eal_init .../lib/eal/linux/eal.c:1257:9 > >>> #3 0xf68902 in main .../examples/l3fwd-power/main.c:2496:8 > >>> #4 0x7fddc164a50f in __libc_start_call_main (/lib64/libc.so.6+0x= 2750f) > >>> (BuildId: 81daba31ee66dbd63efdc4252a872949d874d136) > >>> > >>> =3D=3D3641005=3D=3DABORTING > >>> > >>> More generally, any application passing an incorrect vid would trigge= r > >>> such an OOB access. > >>> > >>> Fixes: 4796ad63ba1f ("examples/vhost: import userspace vhost applicat= ion") > >>> > >>> Signed-off-by: David Marchand > >>> Reviewed-by: Maxime Coquelin > >>> --- > >>> lib/librte_vhost/vhost.h | 5 ++++- > >>> 1 file changed, 4 insertions(+), 1 deletion(-) > >>> > >>> diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h > >>> index 92b67a2c6f..ee4e5317d0 100644 > >>> --- a/lib/librte_vhost/vhost.h > >>> +++ b/lib/librte_vhost/vhost.h > >>> @@ -663,7 +663,10 @@ hva_to_gpa(struct virtio_net *dev, uint64_t vva,= uint64_t len) > >>> static __rte_always_inline struct virtio_net * > >>> get_device(int vid) > >>> { > >>> - struct virtio_net *dev =3D vhost_devices[vid]; > >>> + struct virtio_net *dev =3D NULL; > >>> + > >>> + if (likely(vid >=3D 0 && vid < RTE_MAX_VHOST_DEVICE)) > >>> + dev =3D vhost_devices[vid]; > >>> > >>> if (unlikely(!dev)) { > >>> VHOST_LOG_CONFIG(ERR, > >>> -- > >>> 2.39.2 > >>> > >>> --- > >>> Diff of the applied patch vs upstream commit (please double-check = if non-empty: > >>> --- > >>> --- - 2023-03-15 22:44:50.000737881 +0000 > >>> +++ 0006-vhost-fix-OOB-access-for-invalid-vhost-ID.patch 2023-= 03-15 22:44:49.507848667 +0000 > >>> @@ -1 +1 @@ > >>> -From 1c80a404fd82b816d5c3ebb7cd9e89804ac63984 Mon Sep 17 00:00:00 20= 01 > >>> +From 145ffdbb7ea750f4d3b17446bde22a805957ad71 Mon Sep 17 00:00:00 20= 01 > >>> @@ -5,0 +6,2 @@ > >>> +[ upstream commit 1c80a404fd82b816d5c3ebb7cd9e89804ac63984 ] > >>> + > >>> @@ -109 +110,0 @@ > >>> -Cc: stable@dpdk.org > >>> @@ -114 +115 @@ > >>> - lib/vhost/vhost.h | 5 ++++- > >>> + lib/librte_vhost/vhost.h | 5 ++++- > >>> @@ -117,5 +118,5 @@ > >>> -diff --git a/lib/vhost/vhost.h b/lib/vhost/vhost.h > >>> -index 5750f0c005..954c0ac197 100644 > >>> ---- a/lib/vhost/vhost.h > >>> -+++ b/lib/vhost/vhost.h > >>> -@@ -798,7 +798,10 @@ hva_to_gpa(struct virtio_net *dev, uint64_t vva= , uint64_t len) > >>> +diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h > >>> +index 92b67a2c6f..ee4e5317d0 100644 > >>> +--- a/lib/librte_vhost/vhost.h > >>> ++++ b/lib/librte_vhost/vhost.h > >>> +@@ -663,7 +663,10 @@ hva_to_gpa(struct virtio_net *dev, uint64_t vva= , uint64_t len) > >>> @@ -132 +133 @@ > >>> - VHOST_LOG_CONFIG("device", ERR, "(%d) device not foun= d.\n", vid); > >>> + VHOST_LOG_CONFIG(ERR, > >> > >> I actually had to drop this as it doesn't build (forgot to drop this > >> and the revert) > > > > MAX_VHOST_DEVICE has been renamed as RTE_MAX_VHOST_DEVICE. > > So I guess the build issue comes from using RTE_MAX_VHOST_DEVICE. > > > > Can you have a try? > > > > > > You can cherry-pick from > https://git.dpdk.org/dpdk-stable/commit/?h=3D21.11-staging&id=3D7a4cda6e2= 0f9a6e27b015aad864685440a70af84 Thanks, this works, I was dead sure I had checked if there was a simple rename, probably fat-fingered it.