From nobody Fri Mar 29 11:13:40 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515755606145721.3146644394177; Fri, 12 Jan 2018 03:13:26 -0800 (PST) Received: from localhost ([::1]:34134 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxH3-0007Gl-Al for importer@patchew.org; Fri, 12 Jan 2018 06:13:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35222) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxFZ-0006LM-W3 for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:11:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxFX-00041k-Mj for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:11:53 -0500 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:39332) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxFX-00040s-HI for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:11:51 -0500 Received: by mail-wm0-x244.google.com with SMTP id i11so11014852wmf.4 for ; Fri, 12 Jan 2018 03:11:51 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id p128sm2153033wmb.23.2018.01.12.03.11.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:11:49 -0800 (PST) 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=RkTDzWsKlcrKfP+CUxajoAbxxsVmxIg6cat/n7nl61E=; b=tNY6WOQh0Y9/q0SLp4SB+tpchmvl6NNZ56+qegvxxbbrZH8wSJ58Rrin3U3qq+lsxN 2PmZzHnEwiO/Rpb9isuWQNtn42A6LSRorFNZ13V8TMmeFXUyWkcV+5Mn5TfXZFnYAlPR qlweNfk/5HtBvNA8FoyHWTwXUWlHVPGYwbAcPG+nZzrrsD1JMZfMGcZggaIFR9lutGkP +rhqp0a0Aq/rRtwHYRb/X//kEJQrTIgrhEOQasNReGVwl1xL7ikBtOWfTHmaeNx+pCki ALHJXtcs39yYBRA4MK3NlhF+zuWi224CSOaRR5swg3jrca+qRnZ2hyOD9JkYeB9mdKMV bVFg== 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=RkTDzWsKlcrKfP+CUxajoAbxxsVmxIg6cat/n7nl61E=; b=PLVPRboHT9Oci+Zy58ph6WGiJzZjsBw6AbsTH8oqu/3BzRaLujj/kXmYGwPCthCamJ OWCoZtcd/J99VXQZDQIz9asHp71yt/yDLh+ZeLvFH2Gz8zB6mFfPIjFdnLTGj54vsrv0 FJCHaUCB5s2kTAeYjGntST1uHDbz9hAwto9qGn8OiSowKvqJdLQH2E/0Mn+4B8PPGcDx Iwx5mMlMXOFcX+oX150ZrRy8PpKuwyejtP/XP0Ogb7Tl0CjwJxPqnnkZGRgXzGqnWH19 omfanK4xRH0dTSW5QD4s+Mi37tkBKBvYCE3WNB7I7LvrTXYFJ1pUbEfbqYEpcK25lOjB ZBbg== X-Gm-Message-State: AKwxyteHlPncCOZkOfch4mPDGxfTRHU9b8kYUPn+MxHwczC7pBuZPTEW Io+JO6myd8ta4f9z9tHKJs68ZaLy X-Google-Smtp-Source: ACJfBotuNNvhk6iJwH1joAZM95UVJTmLJrb6PyFoakDzUx/cL17pwj15meHTHCYyr6b8E7nC1uP0yg== X-Received: by 10.28.101.196 with SMTP id z187mr970570wmb.29.1515755510216; Fri, 12 Jan 2018 03:11:50 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:11:44 +0100 Message-Id: <1515755504-21341-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::244 Subject: [Qemu-devel] [PATCH] virtio/vhost: 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: Jason Wang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: 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 Signed-off-by: Paolo Bonzini Reviewed-by: Eric Blake --- hw/char/virtio-serial-bus.c | 6 +++--- hw/virtio/vhost-user.c | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index 9470bd7..2d236b3 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -664,9 +664,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; diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 093675e..3c17207 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -638,8 +638,11 @@ static void slave_read(void *opaque) =20 switch (msg.request) { case VHOST_USER_SLAVE_IOTLB_MSG: - ret =3D vhost_backend_handle_iotlb_msg(dev, &msg.payload.iotlb); - break; + { + struct vhost_iotlb_msg iotlb =3D msg.payload.iotlb; + ret =3D vhost_backend_handle_iotlb_msg(dev, &iotlb); + break; + } default: error_report("Received unexpected msg type."); ret =3D -EINVAL; --=20 1.8.3.1