Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3190761pxb; Mon, 1 Mar 2021 04:05:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJzZx1IwXHCNW1C1ljt/hcr1cp5g2Dyk3ei8kBslkJPf1sD3U3hej6jNK9Wuh+ajDAcTgoxd X-Received: by 2002:a05:6402:1691:: with SMTP id a17mr15470895edv.336.1614600340155; Mon, 01 Mar 2021 04:05:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614600340; cv=none; d=google.com; s=arc-20160816; b=ClBfea4rGYzeBfenRDEYHbNM5uDEzviBs+WZCaRwP5F/5HW6UUmHWQN4dNIhvSBzTk azzNgWKA1EaEl3Nr0jgn07ERS0Zpk0noRnCVNnWjiZOHAzS48mweakqjo0miP2dPgu9w bhVE2JOM2uIDoaMAF+JLtXbd4JofNHrlDTzIR3dxhIbOkzFi3ov5rbHQrZhdZn5W22Qh L+ZObM3R1bLd8ZDc/CRjBsLxjHiSlcEdTp65Zzc3ZIYFD5RIO4odbroNLi0VfYgz/DCA oK8Hh1tK7VfLcI/dXDowsNpNXkeCAHn8k6OELmys6dzh7u3qDsq1IZ1RIbcQuRAmQO5w ol0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=RysBBomvQCWlgOHSbl9/0CkswSUz8rqSOCax5yB0C1E=; b=dlzJOO+/++RBon6h4ssRrxOoDDtApIqp71xtHW84+GgbUHgZ77J30LZmRf8zAqXcfV zcIKFMVbXa5BbrjhHVv1XnhtrtvpeBt7dHyfYxUaSSAOWfpJFwq0DUoAbAykVyP+HeXK 7UTOSRXz8U77MZmf9XLzQmlX544cU54JpzOxIuFYEOp0559Yu9wBFHK7P2+LNiFFl5Ip DpXX1p+I7jXfTXWhwSc7iKUpxqR3iDqNEqaw9le2w0a6vunzmNZ+7g+WESqzDnK+DlgJ 9ldV3dUSiNezvl0uu8s1fckh3Fw3GAKZlF1U3bR+vF2DPBJ89NBdOXn5y1AXozvfr7wF jjEA== ARC-Authentication-Results: i=1; mx.google.com; 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=vivo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m19si9150638eds.451.2021.03.01.04.05.16; Mon, 01 Mar 2021 04:05:40 -0800 (PST) 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; 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=vivo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234952AbhCAMDJ (ORCPT + 99 others); Mon, 1 Mar 2021 07:03:09 -0500 Received: from mail-m121143.qiye.163.com ([115.236.121.143]:52588 "EHLO mail-m121143.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234947AbhCAMDI (ORCPT ); Mon, 1 Mar 2021 07:03:08 -0500 Received: from vivo-HP-ProDesk-680-G4-PCI-MT.vivo.xyz (unknown [58.251.74.231]) by mail-m121143.qiye.163.com (Hmail) with ESMTPA id 0EDF654031F; Mon, 1 Mar 2021 20:01:43 +0800 (CST) From: Wang Qing To: Cornelia Huck , Eric Farman , Halil Pasic , Vineeth Vijayan , Peter Oberparleiter , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , linux-s390@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Wang Qing Subject: [PATCH] s390: cio: Return -EFAULT if copy_to_user() fails Date: Mon, 1 Mar 2021 20:01:33 +0800 Message-Id: <1614600093-13992-1-git-send-email-wangqing@vivo.com> X-Mailer: git-send-email 2.7.4 X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZS1VLWVdZKFlBSE83V1ktWUFJV1kPCR oVCBIfWUFZHU4fSxhOSEhKGktJVkpNSk9NS0tKS0hOTkNVEwETFhoSFyQUDg9ZV1kWGg8SFR0UWU FZT0tIVUpKS0hNSlVLWQY+ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6Ngg6EAw6Nj8XMRAUQxoBHBg# Kk4aC0pVSlVKTUpPTUtLSktPSklLVTMWGhIXVQwaFRwKEhUcOw0SDRRVGBQWRVlXWRILWUFZTkNV SU5KVUxPVUlISllXWQgBWUFJSExJNwY+ X-HM-Tid: 0a77edaa6635b038kuuu0edf654031f Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Wang Qing --- drivers/s390/cio/vfio_ccw_ops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/s390/cio/vfio_ccw_ops.c b/drivers/s390/cio/vfio_ccw_ops.c index 68106be..557d0b8 --- 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(struct mdev_device *mdev, 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(struct mdev_device *mdev, 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: { -- 2.7.4