From patchwork Wed Sep 30 09:03:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 11808505 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1B8E492C for ; Wed, 30 Sep 2020 09:07:27 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C2D8820719 for ; Wed, 30 Sep 2020 09:07:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="dq6Jf2IS"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="0dI77ddL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C2D8820719 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:To:From:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=khOZTEDbz773x3xW5Y3icAckEpfxzQzg2cgcABQJxFQ=; b=dq6Jf2ISy9ymTgu9vtiuirZW6S 0ISK+qoLjn1u1s7flzfUkEgD+10H7O0OfjKAfm0kq47lSIesBy5kY2a9qlWr+4mBSId160r6NGX5f LtbX5ezF/gThKB/wKBgXDndI9f6xw/+xva3sys2uxFh6trWYo8O/tnH3T7/AB2jiH7ndyXgWVnvOW cD5YcfLJ88cLC8OiKJeGG0kgDHc1kNJr9cKFsdCx6pUagdp23ePQKTkvIt0QKLl5o5odNO/gSsu5N LLOMIT6grWuXqz4AgUGJ8zVmBgVx35xNdy5kBShvH0+sswfJ/rx5eUJHsZO7qgdz+1IX+1Q+ly7bi dMe8SKiw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNY3i-00068N-6m; Wed, 30 Sep 2020 09:05:58 +0000 Received: from userp2120.oracle.com ([156.151.31.85]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNY3d-00067A-Hx for linux-arm-kernel@lists.infradead.org; Wed, 30 Sep 2020 09:05:56 +0000 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 08U955UQ067425; Wed, 30 Sep 2020 09:05:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2020-01-29; bh=FoZz65iP5Iq/vDCXSnQLuQn1743Y/uvJf3efBhGPlJs=; b=0dI77ddL9IOsy23JZj3xlrPmXBM8XCAD343R7KxNzLWOgJdpMjlCXIaKb1kF2XuJjhyY Gs8KdXEZ3oJf+p5VehWzUvUl50CHz3u4zj/7BKQetAZgikTXX5Tomb30DgI9gBWwDyNj lI6TOo74g24TZBNrWCDUuyq81AD5bfmBC73+jYaaEsovHwRltRNZWeA0Yf9gT1P0mlvP N0sZjNUjmdZWJZFZLaCiVoh8rVsqFRvf1IqNzWJ1JWixoDruTqajF0MbAqb85sEznBcu 9iuPgUJQnLKs90dT/6k1jIMAmQKT0siP4/VV0FC7TSQF+bxZKA/SXKI+7/b0N9os7gHG Yg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 33sx9n7bub-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 30 Sep 2020 09:05:47 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 08U90ttu055613; Wed, 30 Sep 2020 09:03:47 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 33uv2f2nyv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Sep 2020 09:03:47 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 08U93eFI022378; Wed, 30 Sep 2020 09:03:40 GMT Received: from mwanda (/41.57.98.10) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 30 Sep 2020 02:03:40 -0700 Date: Wed, 30 Sep 2020 12:03:34 +0300 From: Dan Carpenter To: Eddie James Subject: [PATCH] soc: aspeed: xdma: Return -EFAULT if copy_from_user() fails Message-ID: <20200930090334.GB621698@mwanda> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9759 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 adultscore=0 suspectscore=0 malwarescore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009300072 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9759 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 suspectscore=0 phishscore=0 mlxscore=0 lowpriorityscore=0 adultscore=0 clxscore=1011 spamscore=0 impostorscore=0 malwarescore=0 bulkscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009300073 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200930_050553_757288_50D35E0B X-CRM114-Status: GOOD ( 20.61 ) X-Spam-Score: -3.3 (---) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-3.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [156.151.31.85 listed in list.dnswl.org] -0.4 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [156.151.31.85 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines -0.5 DKIMWL_WL_HIGH DKIMwl.org - High trust sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Jeffery , kernel-janitors@vger.kernel.org, Joel Stanley , linux-aspeed@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The copy_from_user() function returns the number of bytes remaining which we weren't able to copy. This should return -EFAULT to the user. Fixes: 86609baa4217 ("soc: aspeed: xdma: Add user interface") Signed-off-by: Dan Carpenter Reviewed-by: Eddie James --- drivers/soc/aspeed/aspeed-xdma.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/soc/aspeed/aspeed-xdma.c b/drivers/soc/aspeed/aspeed-xdma.c index 91b51a3de8df..e6b4744bda64 100644 --- a/drivers/soc/aspeed/aspeed-xdma.c +++ b/drivers/soc/aspeed/aspeed-xdma.c @@ -569,9 +569,8 @@ static ssize_t aspeed_xdma_write(struct file *file, const char __user *buf, if (len != sizeof(op)) return -EINVAL; - rc = copy_from_user(&op, buf, len); - if (rc) - return rc; + if (copy_from_user(&op, buf, len)) + return -EFAULT; if (!op.len || op.len > client->size || op.direction > ASPEED_XDMA_DIRECTION_UPSTREAM)