From patchwork Wed Apr 10 09:13:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 787489 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp597963wrs; Wed, 10 Apr 2024 02:14:54 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUn5597Hv9Xh2GMpWCEr3PPiUTcNo1Hvl58eG/xas8DyMfQicP/vnx8pTT99RO9P/gbfJaJ6nxFSyEqXr/rO9gp X-Google-Smtp-Source: AGHT+IGqznET7U5ROO0aqtcJvtojYIeRD47eWylvu08uMAgU/uhCaoEc9mrKt7ZXTPMSqj0k1bk2 X-Received: by 2002:a05:620a:1233:b0:78d:67c0:35eb with SMTP id v19-20020a05620a123300b0078d67c035ebmr2082924qkj.77.1712740494117; Wed, 10 Apr 2024 02:14:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712740494; cv=none; d=google.com; s=arc-20160816; b=DD0x6jXsvrKpAzGMwir3m7UgH2TX540XR5rZpmXNVbg+M/oZvF9/P7isBPplKe1+mb NpDciPq0AHhMxdb8dUs7deH+xgGWWqGfCA7Bo9ltwI/d/FMRulSV4MV0ZCt9a8H5jaOT DdgpVDW94esNISlRjWmQLeeJossNmUMFh4xCP3P4+zrKnbkAmpM3Rmk6dBWsxmNDrpRi RJKMOa5hyoZJ7UX+cPJ5d23RdVMtR/fR98i7iYF2ntntL+2SVzoqmWEr8RwqIhlpTmgg 7usbabe7qG3KT2bFrSbMf6ArZJ0x0JT1EFtKEuP+zwHHjI/EnaIdd+CxNghBLzXvDUr0 Zm3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aTtiohc8j0973gwMd1zGGgj7zIH/1fbKuICF0OE6WHs=; fh=XeS+bdK9atd166cxysAu3FxFNrWLxATPlJjlevimXP4=; b=ZI39rM4of6Yq6mvpCL4fMcOyV/5XTkv7c1rM/6phX7vSsqrZUyaMCJuxHnDW1IeGlO 5cNkgW8a6wF19NLXEwtVW45v90EBhvSvZRonZjBiji8r+IeullRQnYyEkyAindXfH5gN kdcMnwguUn45WY5X6EZ4MHuzPB/iNuDV431w/BtBOxT1M9y/4nHxTWB4CQit8YsmkK7h fO9vbyt4NsmGOlIkPnAu9KMVNGmScjRqlr+u/+MAWBQYpT+lxeoNFKei0anb3kGDG9RE tUjFeUr7IpwtrhlDwKO+GW4HIi4+isRkxU/Vc0GnkbaS//pthZ+SNMmt+M9eH/HgHj7T IlkQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ydX0ENs1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id xz15-20020a05620a5e0f00b0078d69eb61fasi4463828qkn.591.2024.04.10.02.14.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Apr 2024 02:14:54 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ydX0ENs1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ruU1f-0005n0-6K; Wed, 10 Apr 2024 05:13:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ruU1a-0005kH-Rc for qemu-devel@nongnu.org; Wed, 10 Apr 2024 05:13:48 -0400 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruU1U-0005YU-Sg for qemu-devel@nongnu.org; Wed, 10 Apr 2024 05:13:46 -0400 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-516dbc36918so5072070e87.0 for ; Wed, 10 Apr 2024 02:13:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712740418; x=1713345218; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aTtiohc8j0973gwMd1zGGgj7zIH/1fbKuICF0OE6WHs=; b=ydX0ENs1cakZyPrHx8g4P8bHfcRva96W5wA/HKkE0GIBKudortLT5HO9cBeI8G/hk6 q8CdSOby++kdAnXYfc7Th+qsfngRgEE3ptINN12+7a9KgRvXwnxPKN7jrwyHgjMYCLzp WaSOZ2MVB4eGInfC6pNM1K4VWbAE0lyEj0Xdwq3lwtw8dzu65iSoANDYPPI6/vHoTZVl UsQ/4KRr1nYsniraaAv8eCfTHJ7/qe9KRKtr8Jyt1Fzb2nBJLxmtGXjwArROuZcGlTtZ /RBfCySBiaFUSKf4RqxdCfA8Di33tDpRWGQPPlBTTtyxpFdbketZ6H5LSfAE6P0MUbRQ 2PHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712740418; x=1713345218; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aTtiohc8j0973gwMd1zGGgj7zIH/1fbKuICF0OE6WHs=; b=az4lh1W2C7cl2NSDgCr3+dqUTQrJ4mETlcMV0lAk6iP1YIIOWbFz56SlfEnbdHSV49 uPc2ItPvFEXgacWArsiRRanrrCK3n82l/N+Ux8vBApZIopZMfNGR5FtkVukLjqoTCq5m UIb6Vda+SldyBqMRO69b6DvMUzxlh8DktDxFbv1gtIFZ7RSHYxBBPTymrQ9F3SvZ8/qL 9Qc+QMXkRZRMjSuXSxO7U7JtPqVcv5MOTCES5itoXx0/A2SrBnb3tvAIv0xuOBlxKgWC 80tQKVs2eTf/y9giOI0eM7K0S3XmKkFFccbcGEHt5ud52gavTNigPxR4GvY8LgglQYYD r2jA== X-Gm-Message-State: AOJu0YyCgrBRYgSwqrhuovDgvK3gINMJz/bCfF4smsBblMEqVjSxVTtV AcMS+ww8QvkCRMzIyhkngug3T2WsPlz2vsgx3S6buARzzpG0L1P67z/D5QqAX9n06/mW9cdxWBn F X-Received: by 2002:a05:6512:3b26:b0:517:64ec:1251 with SMTP id f38-20020a0565123b2600b0051764ec1251mr1427777lfv.15.1712740418030; Wed, 10 Apr 2024 02:13:38 -0700 (PDT) Received: from m1x-phil.lan (arl95-h02-176-184-34-173.dsl.sta.abo.bbox.fr. [176.184.34.173]) by smtp.gmail.com with ESMTPSA id ao11-20020a170907358b00b00a51aa517076sm6349767ejc.74.2024.04.10.02.13.36 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 10 Apr 2024 02:13:37 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-stable@nongnu.org, Alexander Bulekov , Gerd Hoffmann , "Michael S . Tsirkin" , Laurent Vivier , Amit Shah , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini Subject: [PULL 03/16] hw/char/virtio-serial-bus: Protect from DMA re-entrancy bugs Date: Wed, 10 Apr 2024 11:13:02 +0200 Message-ID: <20240410091315.57241-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240410091315.57241-1-philmd@linaro.org> References: <20240410091315.57241-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::129; envelope-from=philmd@linaro.org; helo=mail-lf1-x129.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Replace qemu_bh_new_guarded() by virtio_bh_new_guarded() so the bus and device use the same guard. Otherwise the DMA-reentrancy protection can be bypassed. Fixes: CVE-2024-3446 Cc: qemu-stable@nongnu.org Suggested-by: Alexander Bulekov Reviewed-by: Gerd Hoffmann Acked-by: Michael S. Tsirkin Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Michael S. Tsirkin Message-Id: <20240409105537.18308-4-philmd@linaro.org> --- hw/char/virtio-serial-bus.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index 016aba6374..2094d213cd 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -985,8 +985,7 @@ static void virtser_port_device_realize(DeviceState *dev, Error **errp) return; } - port->bh = qemu_bh_new_guarded(flush_queued_data_bh, port, - &dev->mem_reentrancy_guard); + port->bh = virtio_bh_new_guarded(dev, flush_queued_data_bh, port); port->elem = NULL; }