From nobody Fri Apr 26 02:32:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1585220082; cv=none; d=zohomail.com; s=zohoarc; b=dw0PobpmTDiLdKAV15B4AT8+4s+tRUfbgt/HNezVbBmKFabDyu2ymuaMGBMcua5MXH+ChKKVh9vagQ+wrjqAwHf2DVJdl82rDUb/NBMkrvgJvNcZv4mYGxu0EmwItE4+/eWN4Mlkax2UpgvzOBMS+UO3sPKuwaN/pwlvkhuP1PA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585220082; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=DVJOfw7eQi6NV3rlU7rRKdmfQ7n+eT2ZHzUHZHDEz8Q=; b=ATZnfLoYWTMa6Sg64t26AXzaigLDLDmYCvAfd/4oO5aVPIin4FWgmCi7FEhSTdVSplJiPI26YmTuQ+W8Gui5qtDymh7OLql10GGmoBtUQFNBHSsSey9t70xAlc20zU0fMd8VVsQpLMmZDTU8w6hmlHifUyiFFpWQ86vOXxS+aQQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1585220081958287.5812024755312; Thu, 26 Mar 2020 03:54:41 -0700 (PDT) Received: from localhost ([::1]:49302 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHQ9o-0000K6-Pd for importer@patchew.org; Thu, 26 Mar 2020 06:54:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57258) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHQ97-0008HL-2d for qemu-devel@nongnu.org; Thu, 26 Mar 2020 06:53:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jHQ95-00082Q-MF for qemu-devel@nongnu.org; Thu, 26 Mar 2020 06:53:56 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:33267) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jHQ95-00081y-GX for qemu-devel@nongnu.org; Thu, 26 Mar 2020 06:53:55 -0400 Received: by mail-wr1-x441.google.com with SMTP id a25so7208846wrd.0 for ; Thu, 26 Mar 2020 03:53:55 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id m19sm3019626wml.48.2020.03.26.03.53.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2020 03:53:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DVJOfw7eQi6NV3rlU7rRKdmfQ7n+eT2ZHzUHZHDEz8Q=; b=BQQDaNvIyCBovGlXf8NnL7xZrygmWPkqhj/HnqijrUiN3n7ToWQN/tic6kW3QCdPPN pJ+up30CDjXOT3b6bZdyjMyg0KPQ/u4Tea1/WL7yzt3z2FVEQOOJilzK8J1dCgXSPAhx CkGb5muw2POvK3vK47d+2UZlXipk/eb0XaRZsyPrqK0/K1Y/2XyQeBKFeJnEroUw6UNK FR4AaytsOIJir4A07K7FtRdyFJ+2KmnA5tUyHXuOVOXTSFxGo/1Xp9YAQvYGK8qvdWHO o16N3k+H2gaR17cyzOQEbLoLbZCjH0D4jWbR9EdWR+poTsWGbDUqdhaQXmVM1MbLZ2t9 veNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DVJOfw7eQi6NV3rlU7rRKdmfQ7n+eT2ZHzUHZHDEz8Q=; b=jhz/6Id/oihsQ1U9ThZqlpVQ1/A4skgg8GNYl8PJ4e7LhzsEV+lFGz82gj6P/8QU2Q OxFXFesMmG+CCts0J0n91zwIO3MVeiAapk188fR385tZo9EoYo+oyPHaZBU8PNjb6SXB JWkG/93klZjsxAG4F/I9TlsigB32ItyrKOcoK/zHDVAziTYE/69JIMwvbEu107tJ3Brz W+OnM5Kpsa646kmliWmd1vnXMIgWqRfqQiReEKrQxSifUd+XKLYhfHJ7dX7MdnQtZAdq 93pzqU2hlDAPs33mVx8R2jKRMeK6FJDZekwKHhxNzsPC8fV9VQUxIlV0iCt8e0nNwjsI WS3Q== X-Gm-Message-State: ANhLgQ3BpFvg+tLw7ErlugJnR/Hd8FuTnsji1/31ow2F2ccFV1O6V+El 2UC4k+ww7StU4QCwrI8ZrnRa8RT2pTktKA== X-Google-Smtp-Source: ADFU+vvrALYNzcs+Q/9UFUtGoriXmkjHM7WJS7DGWxRwKabpNTItg4MSVo4q253hjIttgvdGwhhReg== X-Received: by 2002:adf:9cca:: with SMTP id h10mr8505034wre.167.1585220033489; Thu, 26 Mar 2020 03:53:53 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH for-5.0] hw/i386/amd_iommu.c: Fix corruption of log events passed to guest Date: Thu, 26 Mar 2020 10:53:49 +0000 Message-Id: <20200326105349.24588-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Eduardo Habkost , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" In the function amdvi_log_event(), we write an event log buffer entry into guest ram, whose contents are passed to the function via the "uint64_t *evt" argument. Unfortunately, a spurious '&' in the call to dma_memory_write() meant that instead of writing the event to the guest we would write the literal value of the pointer, plus whatever was in the following 8 bytes on the stack. This error was spotted by Coverity. Fix the bug by removing the '&'. Fixes: CID 1421945 Cc: qemu-stable@nongnu.org Signed-off-by: Peter Maydell --- Disclaimer: only tested with 'make check' and 'make check-acceptance' which probably don't exercise this corner of the code. --- hw/i386/amd_iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index b1175e52c7d..fd75cae0243 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -181,7 +181,7 @@ static void amdvi_log_event(AMDVIState *s, uint64_t *ev= t) } =20 if (dma_memory_write(&address_space_memory, s->evtlog + s->evtlog_tail, - &evt, AMDVI_EVENT_LEN)) { + evt, AMDVI_EVENT_LEN)) { trace_amdvi_evntlog_fail(s->evtlog, s->evtlog_tail); } =20 --=20 2.20.1