From nobody Fri May 10 01:09:30 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=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1585071443; cv=none; d=zohomail.com; s=zohoarc; b=Kd2tdEL28qzhPivPkztb92iTQ8wSpHm7so0bfhwv1hDPWuDEVPD9lgKT5TQ1cRFsXoALDsvFh4+Rti+No9SKvmHr/ltVKfOBJtPBXD2SHoGItIm6hkqGFdK6BogD2B84Ta+GCE1QZgxbcZp8O8OXjDKJiRfL1wWSNMxGMfl2Or4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585071443; 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=yiqNo48ag7gzDCzI0XyjUFiLj55QYsYhRpvFKm1CEWI=; b=WB6/Zh5ngKpU619U3TwdqfAUSb4I6Ma0gcMqspPmtgT3c7JVp0t92+ODJLrAYVVG4lhxeumUBesVZiDYX9T7dVKku9fSxNJS+RiDExgIO2IKDpbg+1TL5nM1aAOOq7KkCn3YcjBiG6nzcv4YmoEZv0uYEwPI0Soqcm6qsXoYvTU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass 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 1585071442958880.8514470537704; Tue, 24 Mar 2020 10:37:22 -0700 (PDT) Received: from localhost ([::1]:52758 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jGnUP-0008GG-Ed for importer@patchew.org; Tue, 24 Mar 2020 13:37:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57842) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jGnTg-0007qE-D1 for qemu-devel@nongnu.org; Tue, 24 Mar 2020 13:36:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jGnTf-0005ni-1j for qemu-devel@nongnu.org; Tue, 24 Mar 2020 13:36:35 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:33517) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jGnTe-0005na-RD for qemu-devel@nongnu.org; Tue, 24 Mar 2020 13:36:34 -0400 Received: by mail-wr1-x444.google.com with SMTP id a25so22625924wrd.0 for ; Tue, 24 Mar 2020 10:36:34 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id g14sm5468763wme.32.2020.03.24.10.36.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Mar 2020 10:36:32 -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=yiqNo48ag7gzDCzI0XyjUFiLj55QYsYhRpvFKm1CEWI=; b=o0DjZkk+hhuxUjCN5yOV2VvmcxJFxwxbgGf9+I18llUP4ooOHqXF7TlBwNrg8+jeul OXvOjBfaTX+aXVthTCf3+Tqwyq6/qR+6jRTRtSIo/Z2wJuF7NVg6oTWFgvo7sYtjJT7K 9CdNomLIeXTdJGbnJeEJpnOIAfJrk493cjCc6XHvUx2DfUl5rtvJv5sOyA//MkFycFAx 4d+toq95EwzjOngTbzQGh+pyP0ioKJu+3I8EGZdTMlZaEiDO51btzUl2/vVu09DM3bjy wPSPrMfHWGIKNPd9GeZR822AFRbkicQ6niFySjokQ2He0GKJVaue7ACO8vqCsr11t//1 oUxA== 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=yiqNo48ag7gzDCzI0XyjUFiLj55QYsYhRpvFKm1CEWI=; b=CStZgKES4cJXa2VCZDPJEccNVtGipBTzsyngyPXLKasGTqE4RUEmt72/A5pkXtYtny kWLNk2LBAhFBOMJNs1SIN/TS2UpDomgdkCktfVnTIs3afahUDEclMr74UCKTYJzqE9DR N+pY5Tv7XxLrcBw/St1016wfosJkwibc/2w+krgIVGOUfVBe91Hs3gn2nXYbzllu1x/x WbJ21LpuwfeTbi8KgEOXn/1dbYk3Pz/qsEFBH/Iw+7Pvlkvp17sFi4AKVKQOioAUAFgz 8EdB+wT5o6mK6wxbIk9AMVnK0LfpOXko3JUaFFytylpzqKLr5izLq99QkGZP7mycLqkG w0Ng== X-Gm-Message-State: ANhLgQ0yUk2vJbO2MlBaA/v8mFAYU3jY0V8WXZ98pcWemYsEEnQgFZox SUZT6fYm3Bevhw7Leg3u72xBs4Zy45iANw== X-Google-Smtp-Source: ADFU+vsnen3VePkGEMtI9wONTAb9l4lyYVTFRMuAcpuHauIckFrhaVz0aJTSTSaSurfWz28YYjILHg== X-Received: by 2002:a5d:5286:: with SMTP id c6mr37564240wrv.418.1585071393075; Tue, 24 Mar 2020 10:36:33 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH for-5.0] dump: Fix writing of ELF section Date: Tue, 24 Mar 2020 17:36:30 +0000 Message-Id: <20200324173630.12221-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::444 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" 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(). Signed-off-by: Peter Maydell Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- I have not tested this because I can't reproduce the conditions under which we try to actually use write_elf_section() (they must be rare, because currently we produce a bogus ELF file for this code path). In dump_init() s->list.num must be at least UINT16_MAX-1, which I think means it has to be a paging-enabled dump and the guest's page table must be extremely fragmented ? --- dump/dump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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, E= rror **errp) shdr =3D &shdr64; } =20 - ret =3D fd_write_vmcore(&shdr, shdr_size, s); + ret =3D fd_write_vmcore(shdr, shdr_size, s); if (ret < 0) { error_setg_errno(errp, -ret, "dump: failed to write section header table"); --=20 2.20.1