From patchwork Mon Apr 6 10:12:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 185215 Delivered-To: patch@linaro.org Received: by 2002:a92:de47:0:0:0:0:0 with SMTP id e7csp3483947ilr; Mon, 6 Apr 2020 03:24:14 -0700 (PDT) X-Google-Smtp-Source: APiQypIrMcu52E6w6uAyFlEgMHI7oP2zBi7fjOof7tNUnrS9lhkGx3vFywTZddpJ4oOOEWGpks9s X-Received: by 2002:a37:6456:: with SMTP id y83mr13330825qkb.122.1586168654876; Mon, 06 Apr 2020 03:24:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586168654; cv=none; d=google.com; s=arc-20160816; b=tZ2REsr888h1MCX8T/qscLb8O8FYhp/qN73j1+4HlK7n8RNIeFMVB8zhyZyu5QdqTE IflQV3cIYpjvpxVVst8XBnXJeVs73YIf8hJPlRX3n/iK9Z7qH5SMTWEdrAuQQHCx/Lfy UyI4L1hOrj61vNodCuXrE51IWOCk8udCs7xbriVSd0ePauV/mabr+XVhXBlzE+PNciDs 3Jbds0z2ZClmgt2GTj6JErz9LxczRhnvtzWlyvrCRicOo4TU1lYLzvr6iZUlHM7fqPvd 0uo/r2ByYqcHshNo12pqKHmvnAmX6eZRBbVN2k2uUZmnEzLXTkDYBpPCnwsORKKg3BAz PvDg== 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:to:from :dkim-signature; bh=sVStBWBB/nYKZSZLm9qzTwRd2BAPghRDv9sMPC8uICQ=; b=mE2oE0zUIHf7nVo9XKeVsvXn612WD1itc4i+ke6+XYAh015rFnaOSq555Ida6SWm5K SgO2s6ENIKWLHbpDzaQll1EiI963GJ6bkUSeO0H7iJlCr9yZxCI7htcJ1EluyxJ5NEX2 YsdRLmFycHzXS1lB91XVEXhnRW0uZkkRwhUG4p9yj67M/JJljmdqYW2yUmCScuDaFXjf w0cRq/bG6TWTsVmqxEVJXpFG7s/2qrVVmtejfMDehO6oorcm8+n7+BCuRmB8uUDqv8qL H6dYgojaFnWtDygC5SDPVbyuZDAVP+YMRV/Q9aVo89O7edse6luu33/Dx4WPJOQWPDCV u39w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zM+xSxNe; 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 t126si10390688qkb.344.2020.04.06.03.24.14 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Apr 2020 03:24:14 -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=zM+xSxNe; 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]:58289 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOvO-0000z1-Dz for patch@linaro.org; Mon, 06 Apr 2020 06:24:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50113) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOjo-0006jC-Ef for qemu-devel@nongnu.org; Mon, 06 Apr 2020 06:12:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOjn-0002ok-DN for qemu-devel@nongnu.org; Mon, 06 Apr 2020 06:12:16 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:44265) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jLOjn-0002mA-7M for qemu-devel@nongnu.org; Mon, 06 Apr 2020 06:12:15 -0400 Received: by mail-wr1-x42e.google.com with SMTP id c15so801031wro.11 for ; Mon, 06 Apr 2020 03:12:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=sVStBWBB/nYKZSZLm9qzTwRd2BAPghRDv9sMPC8uICQ=; b=zM+xSxNeCpi6cl/P7qydRzmwD2hcWmp//lyl2LYNTfcwsp9wjtLXgqnOSNNvLjy7Rp HiK7Gj4Ye1pVS3VZycGGWcbxUDZYealw2QgecFUTt81WE+jZyCGJTK4Th9UdhRzIMfm8 nY79NhT8kgXaSJ2hFvl8C2xpCEql3ar4S17wMZsMDwaHlsOvBVIWyhk5kXe4OX4Yk480 IHEUjcyqnZ1ySg/w9yZDmtIalEMQz6R+oVbMKQ6KqQU9Zcr6tREozKm+KRbKVv9OBgrj 8H84yWoHaLpYheWziEvyCxLTR8yLxjwzDgpa4tCksNkJKB/kNjnZMn1xfrI5Kdmu/3HC DCCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sVStBWBB/nYKZSZLm9qzTwRd2BAPghRDv9sMPC8uICQ=; b=GU43TvJJkb7M0qcZOYUshOlQ1k5o/uvWrmDHUdddu1TRfDTjs/zNgyU5i/7CFB0lv7 TSEw7A1F5UtZERRFpA07Si0cKi8opEfpyqtc6vBEih37oLMwPB+S7/90/37llbY5liSc YBNnGzYesMFymfJXI0IDu9+olVD87LqUsVc2S6YqW2oe+bY8jWGrJlfZ/sZvSxaLL8dF chcgtIbzRYWbwtreq5qAPYk/OriQsMC1riafV9HOhF0pFMQzaCajqVFFfHWMGUs/jXnm 4V64u19xMFKou1A9nac7R56E3DOAvXS9hg1V7Smemw0wD7oLACDhfJ9R3xib+YiaYA5c oEkw== X-Gm-Message-State: AGi0PuZxtZUx447bHVbAOtxjCkZhUpr6ckZxLMQxyDOQ4RiZ6r78YwAk PHJqSoIxHdhJjNywBiig2Am2226YJDIB4A== X-Received: by 2002:adf:e6ce:: with SMTP id y14mr5634343wrm.45.1586167933729; Mon, 06 Apr 2020 03:12:13 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id f187sm25163765wme.9.2020.04.06.03.12.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Apr 2020 03:12:13 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 06/11] dump: Fix writing of ELF section Date: Mon, 6 Apr 2020 11:12:00 +0100 Message-Id: <20200406101205.23027-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200406101205.23027-1-peter.maydell@linaro.org> References: <20200406101205.23027-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42e 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" In write_elf_section() we set the 'shdr' pointer to point to local structures shdr32 or shdr64, which we fill in to be written out to the ELF dump. Unfortunately the address we pass to fd_write_vmcore() has a spurious '&' operator, so instead of writing out the section header we write out the literal pointer value followed by whatever is on the stack after the 'shdr' local variable. Pass the correct address into fd_write_vmcore(). Spotted by Coverity: CID 1421970. Cc: qemu-stable@nongnu.org Signed-off-by: Peter Maydell Reviewed-by: Marc-André Lureau Reviewed-by: Philippe Mathieu-Daudé Message-id: 20200324173630.12221-1-peter.maydell@linaro.org --- dump/dump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 diff --git a/dump/dump.c b/dump/dump.c index 6fb6e1245ad..22ed1d3b0d4 100644 --- a/dump/dump.c +++ b/dump/dump.c @@ -364,7 +364,7 @@ static void write_elf_section(DumpState *s, int type, Error **errp) shdr = &shdr64; } - ret = fd_write_vmcore(&shdr, shdr_size, s); + ret = fd_write_vmcore(shdr, shdr_size, s); if (ret < 0) { error_setg_errno(errp, -ret, "dump: failed to write section header table");