From nobody Sat May 18 23:23:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1537996911492988.5324512334884; Wed, 26 Sep 2018 14:21:51 -0700 (PDT) Received: from localhost ([::1]:60722 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5HFg-0001CO-6y for importer@patchew.org; Wed, 26 Sep 2018 17:21:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42013) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5HEg-0000BJ-TR for qemu-devel@nongnu.org; Wed, 26 Sep 2018 17:20:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5HEc-0003Et-6H for qemu-devel@nongnu.org; Wed, 26 Sep 2018 17:20:42 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:37397) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g5HEb-0003EW-Ui; Wed, 26 Sep 2018 17:20:38 -0400 Received: by mail-wm1-x344.google.com with SMTP id y26-v6so3234412wma.2; Wed, 26 Sep 2018 14:20:37 -0700 (PDT) Received: from localhost.localdomain (lns-bzn-25-82-254-139-7.adsl.proxad.net. [82.254.139.7]) by smtp.gmail.com with ESMTPSA id 185-v6sm730930wmy.38.2018.09.26.14.20.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Sep 2018 14:20:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=QdHcmN+nkV92e5J/y0LKqNZp2Vaegz2c0toAVJYTlMM=; b=X8N8265nva6r85Ss0cu5aFF5BvDqwcF8rVjdgozKOGEfsiTsftRMtSDNslOCbaFBtp 0FpVlhHlUsa2o4dHSxMBZcfbRLdngvIiNnXe4ext5GVy4uR/rnGO4GNbgmXTK4RU2mh0 yzbz2sTmK1MXjjEsQOFiH3qdnOKXJSJj41yzf6nhm/yO7PA/r+25goIs/z6h4Bb1f0s5 8d3qAHsbjnsl+hjcj/Qp3pkte0b9NE5an9/34bqBY/UpaDiAH85dBvFnqhjsR+fBLi4H PInS6xv8MDw9QB94Ih3t8ESyT0vyxtCjfZ7B9zSjF4jF9qmrZbsCU6+ltAiJpy5DeHW8 I9/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=QdHcmN+nkV92e5J/y0LKqNZp2Vaegz2c0toAVJYTlMM=; b=m55K+lyWcXjv2tM+c1Ht8oVJewY57e//QQ6puQ0WghN3Vf27Pz70izGITxluo8Et9+ lcbkOZhCB+G+26SiE7z/nKlKemwlsrBYsdRFGfJSRDvGGzBMczm5y9wduTvxxDxpFdOV cChR+opFf9REwLxVCWUvVm71nU5TH/1/ykjM/FaOGjNrDWBqy9jFaFExr0IIHk4IrsJW 8V1sboTAcXm3tILYx6a/THudqCEHTfW7Aipv8P1xGYdERUoWnP+UR2xdmki6kwb+w66v q5MW/1leMnF+p4ZpJlmkbLA79oBZjMieMSCSpg1EDDE9EukE49j11Jv7cELsWLLtEcS3 w45w== X-Gm-Message-State: ABuFfog7uay3ERaMCLB6YoRUOtrNOpDM7M23XOaeoRa2hI8O16mPUeNi MD2NmSkY1ubhwzdTrTcK0U+BFUMOvic= X-Google-Smtp-Source: ACcGV60aV/KEuK3SzI2KRIuX056AHCpVBL4Yl03Do6pPei+L9oq/oxdxS6d56CkKrrrr0GB1rLMRtw== X-Received: by 2002:a1c:b709:: with SMTP id h9-v6mr5547149wmf.130.1537996836316; Wed, 26 Sep 2018 14:20:36 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 26 Sep 2018 23:20:33 +0200 Message-Id: <20180926212033.25026-1-pbonzini@redhat.com> X-Mailer: git-send-email 2.17.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::344 Subject: [Qemu-devel] [PATCH] virtio: do not take address of packed members X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jason Wang , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The address of a packed member is not packed, which may cause accesses to unaligned pointers. Avoid this by reading the packed value before passing it to another function. Cc: Jason Wang Cc: Peter Maydell Reviewed-by: Eric Blake Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini Acked-by: Jason Wang Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- Resubmission of the patch at https://patchwork.kernel.org/patch/101= 60229/ The vhost part has since been fixed independently (commit 69aff03064, "vhost-user: fix misaligned access to payload", 2018-01-18). hw/char/virtio-serial-bus.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index d2dd8ab502..04e3ebe352 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -667,9 +667,9 @@ static void virtio_serial_save_device(VirtIODevice *vde= v, QEMUFile *f) =20 /* The config space (ignored on the far end in current versions) */ get_config(vdev, (uint8_t *)&config); - qemu_put_be16s(f, &config.cols); - qemu_put_be16s(f, &config.rows); - qemu_put_be32s(f, &config.max_nr_ports); + qemu_put_be16(f, config.cols); + qemu_put_be16(f, config.rows); + qemu_put_be32(f, config.max_nr_ports); =20 /* The ports map */ max_nr_ports =3D s->serial.max_virtserial_ports; --=20 2.17.1