Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1241083pxa; Thu, 20 Aug 2020 06:32:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznQSvoBukaFE5rsjXwp+g97K+IkHsLhd6obpNeJD9KWfYeAps+QQ0z+ZemIO5+2Ge4/jw6 X-Received: by 2002:a05:6402:b09:: with SMTP id bm9mr3014765edb.9.1597930332941; Thu, 20 Aug 2020 06:32:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597930332; cv=none; d=google.com; s=arc-20160816; b=ptk6RbR6hCXS0bZMq9uP7HtQvnPyKQgCEjmDHFnUpmt4RiwdCRiMpPrXBS0EwiB8c2 iN/38HABXLYqnexMdj7b1jFtTlA8wXmiiMZSPg2Wn314G3clIlh9C4E7f4F1gidoQh9J 59gcPLQGaTnGb+5YZL/ZF10ACMLnonhNQEdGPJFDxOXutNdQZS5+lG7IEAgKOYwU3aUT vvNLlfrqHsUNz5yOm5qB1oAyIY158ddDdxtNcjoSyFtjov/vE9YejAYiRODrhmt0cj2f cQsbd8ViCQJLLSS+Vs2XTOj2C8RqAzR/2yALFOpszYytE5ziuYvlfCHOiiYueHoY/0Us E2qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tjYZfZXwQ7jgnTkCPJ7miOgLdnSIi5vSU1NT/hjEsHU=; b=ItcJrJmAUNv836ZWLRr0b2OYGlbyCKwuw3p398UUMgo7lhwTNgXcrCEzyAcMj47RD5 uMQaevL1eJhoYn4NrOgiMZ+FNzchMR8HPgeKeAa4iZ4F9aVDg6aXEqKdBqS5Ma8yjWwC +tRpniA8He4Ed+pJzcb6Mnd64iMGwnD+x/yTCBiKFu/TKbhyopySfh465lVDo8GsEo0R chv2fOzMAVN2Qmb3FQw6CQR6gmFy9mWHzsLl+he38PFzdLy59GspWaTIxWIsItxBLwdG nZEkCbiQ3/bFeCFJEeJOVh06491D2EiuSEP3U1moQK3iU4TArk3cZpPfUPGvXaIaAS5B IjxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="XsHq/N6I"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d24si1369113edz.145.2020.08.20.06.31.48; Thu, 20 Aug 2020 06:32:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="XsHq/N6I"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728498AbgHTNbN (ORCPT + 99 others); Thu, 20 Aug 2020 09:31:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:45210 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727067AbgHTJcp (ORCPT ); Thu, 20 Aug 2020 05:32:45 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8B8F522B3F; Thu, 20 Aug 2020 09:32:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597915965; bh=aTkfAVIahRMmhZXljbsWvSDq4bZNkxIkqqnsC9HJsng=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XsHq/N6IjQDyobib+0S/OuiriVT6Tf8rwPH5pPhCxV3D8UqWmOVpaDMLjhRKzKYhn 9sjEqllxSnb6vgXfSxwSEJVolPyATHrvwjx1sWK5t34vSO16XBLAB0+uOUknmnNkmk TZROIg6l8z6P1KM9UIPasW/xVBayFVeWqvP2CXOE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , "Michael S. Tsirkin" , Jason Wang , Sasha Levin Subject: [PATCH 5.8 197/232] vdpa: Fix pointer math bug in vdpasim_get_config() Date: Thu, 20 Aug 2020 11:20:48 +0200 Message-Id: <20200820091622.334300890@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820091612.692383444@linuxfoundation.org> References: <20200820091612.692383444@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Carpenter [ Upstream commit cf16fe9243bfa2863491026fc727618c7c593c84 ] If "offset" is non-zero then we end up copying from beyond the end of the config because of pointer math. We can fix this by casting the struct to a u8 pointer. Fixes: 2c53d0f64c06 ("vdpasim: vDPA device simulator") Signed-off-by: Dan Carpenter Link: https://lore.kernel.org/r/20200406144552.GF68494@mwanda Signed-off-by: Michael S. Tsirkin Acked-by: Jason Wang Signed-off-by: Sasha Levin --- drivers/vdpa/vdpa_sim/vdpa_sim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c index 412fa85ba3653..67956db75013f 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c @@ -522,7 +522,7 @@ static void vdpasim_get_config(struct vdpa_device *vdpa, unsigned int offset, struct vdpasim *vdpasim = vdpa_to_sim(vdpa); if (offset + len < sizeof(struct virtio_net_config)) - memcpy(buf, &vdpasim->config + offset, len); + memcpy(buf, (u8 *)&vdpasim->config + offset, len); } static void vdpasim_set_config(struct vdpa_device *vdpa, unsigned int offset, -- 2.25.1