Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp51901pxb; Tue, 2 Mar 2021 18:50:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJxTpA8NCsf+KUpnxrniq/qa9tTC1OZCT57CDvJcWwv+1oP8iT98jPGfbs92REnl53LiA/w5 X-Received: by 2002:a50:c00b:: with SMTP id r11mr23760882edb.35.1614739816913; Tue, 02 Mar 2021 18:50:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614739816; cv=none; d=google.com; s=arc-20160816; b=mMwPQwHcgNE4mFc9aAcv2yZP6a0x9iteMfOPGkm4g8WngcmKx6ioQqI9kgq7Jdvv88 jqULNtavTKEAwIBxBT9wsP9LVOiKIjJBGwMUk9HyJdvwmo1l/Vt2yX9sy654jvJIWxn2 WAMR0hJww93Viiu+4jdNJJg32ehWmjOp/PbWUuwIJhkRW0ZSWnu7DpWYvHlf+vEXI881 KOvVmUB+RyX7vau6LiHL2Be4yvPG0Z0Ibo0vdfMSTV7oZpJBtNzDNN8D2SMh2HNGIUVm 7McmRAOeMnqjHiyloVLoRDJ/CWRkIVAGFoU49dNcsJEXlt7YtFGccoB2zSe7/wVTcTaO 58ug== 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=5rEM9f8djQYO132lJL6Ttj/AyIJ3fpzXQPAAWfpNd7I=; b=Ic0144OexwBD7glC2GuvHWHJqOIdaVRVoMHQV594Ip3jlfDp6U0GO5G+hOJwkN3MF3 P297+q21233vieChULTqRWCnzahXIymoaf2FnZfTKhwhsuEQ5ujyIMwZl/4R/cTdtj6x 9iE84cTqhWRhNoylAE7yk4TRddS3oF5m4VTu6A6D+7i4IZWWWtZ4PJBS/hAMBeHiIkMz C8nOBviZ/b3xL24EYZyPaxyyDN7A2zDWkWocnYkLmTU35GBYbK86k456FMOJx6JqitpH 36Q+29BqaruEDKWiIH93Fk9vUGfGGMYejc8ynRks4dJclafSWl6VCCOyIddN8ZxjzJsW tgtg== 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 jg20si15707202ejc.125.2021.03.02.18.49.53; Tue, 02 Mar 2021 18:50:16 -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 S233089AbhCAMJs (ORCPT + 99 others); Mon, 1 Mar 2021 07:09:48 -0500 Received: from mail-m121143.qiye.163.com ([115.236.121.143]:39082 "EHLO mail-m121143.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233061AbhCAMJq (ORCPT ); Mon, 1 Mar 2021 07:09:46 -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 E18C854023A; Mon, 1 Mar 2021 20:08:57 +0800 (CST) From: Wang Qing To: Tony Krowiak , Pierre Morel , Halil Pasic , Harald Freudenberger , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Wang Qing Subject: [PATCH] s390: crypto: Return -EFAULT if copy_to_user() fails Date: Mon, 1 Mar 2021 20:08:21 +0800 Message-Id: <1614600502-16714-1-git-send-email-wangqing@vivo.com> X-Mailer: git-send-email 2.7.4 X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZS1VLWVdZKFlBSE83V1ktWUFJV1kPCR oVCBIfWUFZQ0tLHk9CHkhOT0sfVkpNSk9NS0tOSENITkpVEwETFhoSFyQUDg9ZV1kWGg8SFR0UWU FZT0tIVUpKS0hNSlVLWQY+ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6Kxw6KAw4Qz8TORA4HhoTE08B FT5PFDxVSlVKTUpPTUtLTkhDTUJKVTMWGhIXVQwaFRwKEhUcOw0SDRRVGBQWRVlXWRILWUFZTkNV SU5KVUxPVUlISllXWQgBWUFJS0pPNwY+ X-HM-Tid: 0a77edb1089bb038kuuue18c854023a 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/crypto/vfio_ap_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c index 41fc2e413..1ffdd41 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -1286,7 +1286,7 @@ static int vfio_ap_mdev_get_device_info(unsigned long arg) info.num_regions = 0; info.num_irqs = 0; - return copy_to_user((void __user *)arg, &info, minsz); + return copy_to_user((void __user *)arg, &info, minsz) ? -EFAULT : 0; } static ssize_t vfio_ap_mdev_ioctl(struct mdev_device *mdev, -- 2.7.4