Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3512034pxf; Mon, 15 Mar 2021 11:10:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAmtvtyP0+DriNERBNkRXXcICggUig4Q48M+PwZmB3SWte/u52aLH2SB8+nT+6yHpeY/0F X-Received: by 2002:a17:906:2612:: with SMTP id h18mr24882550ejc.309.1615831827941; Mon, 15 Mar 2021 11:10:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615831827; cv=none; d=google.com; s=arc-20160816; b=xChhaqyzljVV6yPzotHdMV9o7FzfPx0kpOgK/l0VXmDil8DIV86vTOUDFFTR8tnLxT F5xQXXz4k8OyHMaJdQ78oB97FmESb11f/S3QWcEtSwcU8WaF4CL7ux3vyedU4VT3eOCR 8zitWuCm8utEYo7+2n5Js5SCwigV5u2npLyr/Vm+mMKfuT1jSeVk1nu+NXG4+SBsZFG1 ZcF0YVknE4femSzYqVuxtv8mpNzYEqpc63jGlcaIKwwpFFCu2tuExP1/KkN83lnsu4Tk XSPLKIw9g4Geq1pFYBX2FWH2/p96jKLEPNgBuSBpO0JKO+Ka061xCn1id0X3IioPwqVW aCIw== 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=wi5SV1IN6D0qZaf7l0R0iFRsB0hrjr41a/N8XqwAXCw=; b=ZbhNOo9DSfndaMJis40GPt72Z6OPgjASCJj6g18KouGNnQW8ZmY25eIj4ru+i8QY24 rFPRvZ98rMAi6zayP6oCeb18uInSDpMNnxlsYMHTii+jyQFe4AFkKy0SD+3y9a1KjLfG 38DXoIqlVIT94QQGMrDtJWqXrrZ5uW85oYGL74ggRltNCI9OTAdzxVACUGOJLpLwTpbM /jvhDebSaqwxfaVDyP8d4xCTkyAtA7hcQ0I+UYuvvE8mIMEmSQtyBQQGUfTHpF+QcPJM v5Fj4TQMvexDELmkjnlODoFfeucYfpsc6Qs8O9zCIEDBCnUpk25dJ8aBDQi7WRDEXs4F pGUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QKJdbUEy; 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 gz11si11558637ejc.745.2021.03.15.11.10.01; Mon, 15 Mar 2021 11:10:27 -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=QKJdbUEy; 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 S234378AbhCOOJw (ORCPT + 99 others); Mon, 15 Mar 2021 10:09:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:36764 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231389AbhCON6P (ORCPT ); Mon, 15 Mar 2021 09:58:15 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E7A4564F25; Mon, 15 Mar 2021 13:58:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816684; bh=B8WaSJQP8D3v8jff7tVS8ve4pFzL3lhLCiqoGtwqr/M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QKJdbUEyqRxgUHeVeWU7VZZEQJB2Gg8Xp3aMRMHOKQca83ee1wIto0XpeecDq3NIl +Jcj2WuW6l4kk75J2WrLCdXO1aS0GXNa7ZHLyyBC5gZcx+3Jqmg9utJrHb4x2Ca873 eTfRoSpSQ9greD20nZsPYPC+2Bu8e3q4ilbE0xKE= 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.4 045/168] s390/cio: return -EFAULT if copy_to_user() fails again Date: Mon, 15 Mar 2021 14:54:37 +0100 Message-Id: <20210315135551.842626008@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135550.333963635@linuxfoundation.org> References: <20210315135550.333963635@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 @@ -506,7 +506,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: { @@ -524,7 +524,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: {