Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3517606pxf; Mon, 15 Mar 2021 11:18:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwChm8Sy2MCCVNHHbDOC1hLEGKRrxJ+PQfOt+jRtp97HkBvlr+46/w1ynxsFZAZB6zfUgwQ X-Received: by 2002:a05:6402:1613:: with SMTP id f19mr31941085edv.222.1615832305708; Mon, 15 Mar 2021 11:18:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832305; cv=none; d=google.com; s=arc-20160816; b=VYy0IvdI0x+eixlqC2cHidLJJtkXlu5kLkAtNdDdAa53vAdQAsxlAlGVV9xKuE7hZv JtD6+LVgWOAKWOEUGemiCff8nE4USO/CAturz8yjWIsl+BEuk82p5ZaU2RTk7VnbVsWA iisnp65CAZHUXGfy0kSU9kNm6B0CQwaspezXYQ6+sqwC1OSNHTJXydxSwyr1OyJTcUsm qgMCPbo4rGTXRXu1cUzbm3KNon5IodZVx22r1E6oSMNYTfDjMCcvJoasqD2UJ4A35C9k 6pjApZbb0StxX9QtcixqEB9lRPqtcj/nAP/CCv8UorMSBarTCOql5VAu8r3vcblmHnr+ dgyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ee3/WsGIH4L4sFuDljdJoEg0lETdQL/T7yvOq6rS77w=; b=lYoWMMtke+6+zjmozqW4hZEqTl1/p8VcrvyMq16zT4RK+bS2zoz8KiU1u71q55+jcZ wy+E/DKbpjhbIvFlCyt6SwSiK1ium2jQRmyCylslQGgxDEYiGeqoLP4Jw5AUmFPvvnDg 5KLrXmySo9l4sVdIh/aZS/naYJDpQxEp2CnsvqWnbk61oU+zjuvBgyuR/PTAuOBKwG/0 Sb6oCQuUBK25pAiSXuKDY2j1DnBJxrWgXDRCf4Fmyn/2x+jG81fmFBflpRtkldEm+dHY H4rfV7vLGZxkKFblJDgxrj/Nk7ELOSWLg92qQpHSyEnkEsoldAutR65grgcBrwd7osgP JmKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=udDVzIVT; 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=pass (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 z15si11866634ejr.694.2021.03.15.11.18.01; Mon, 15 Mar 2021 11:18:25 -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=@linuxfoundation.org header.s=korg header.b=udDVzIVT; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231674AbhCOOP4 (ORCPT + 99 others); Mon, 15 Mar 2021 10:15:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:34900 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232354AbhCON7P (ORCPT ); Mon, 15 Mar 2021 09:59:15 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 43F6064F21; Mon, 15 Mar 2021 13:58:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816734; bh=TStzguN8wu1qXZtmeffgcLVn5wkfZGDMBEcur1ttMCU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=udDVzIVT2YEdH68cWvBCe9iuQW04iCkPGHm+LbIJ/stHyITDKoWRXU6JEWSZNZMuV 2OXzmrlh5qGYpnhyJydbmvbyspx4XltnNU2PQ8HaybhnahPr0FM62DXTbhXlFZb4WX KA0iBtWGMXJMn0fkLgwovr4tZgBK7wmjcsF//NRA= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wang Qing , Heiko Carstens Subject: [PATCH 5.11 092/306] s390/cio: return -EFAULT if copy_to_user() fails again Date: Mon, 15 Mar 2021 14:52:35 +0100 Message-Id: <20210315135510.761333531@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135507.611436477@linuxfoundation.org> References: <20210315135507.611436477@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Wang Qing commit 51c44babdc19aaf882e1213325a0ba291573308f upstream. The copy_to_user() function returns the number of bytes remaining to be copied, but we want to return -EFAULT if the copy doesn't complete. Fixes: e01bcdd61320 ("vfio: ccw: realize VFIO_DEVICE_GET_REGION_INFO ioctl") Signed-off-by: Wang Qing Signed-off-by: Heiko Carstens Link: https://lore.kernel.org/r/1614600093-13992-1-git-send-email-wangqing@vivo.com Signed-off-by: Heiko Carstens Signed-off-by: Greg Kroah-Hartman --- drivers/s390/cio/vfio_ccw_ops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/s390/cio/vfio_ccw_ops.c +++ b/drivers/s390/cio/vfio_ccw_ops.c @@ -543,7 +543,7 @@ static ssize_t vfio_ccw_mdev_ioctl(struc if (ret) return ret; - return copy_to_user((void __user *)arg, &info, minsz); + return copy_to_user((void __user *)arg, &info, minsz) ? -EFAULT : 0; } case VFIO_DEVICE_GET_REGION_INFO: { @@ -561,7 +561,7 @@ static ssize_t vfio_ccw_mdev_ioctl(struc if (ret) return ret; - return copy_to_user((void __user *)arg, &info, minsz); + return copy_to_user((void __user *)arg, &info, minsz) ? -EFAULT : 0; } case VFIO_DEVICE_GET_IRQ_INFO: {