Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4114048pxb; Mon, 1 Feb 2021 12:50:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJzx1DH1cKnWMbFflmPFtAj3SQK4281o73qSJRH44fAhsNbiz6ZmfXHbJ3RwYa0IlyI3Ohno X-Received: by 2002:a05:6402:3552:: with SMTP id f18mr20629294edd.111.1612212631177; Mon, 01 Feb 2021 12:50:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612212631; cv=none; d=google.com; s=arc-20160816; b=wfjjV6J0lLCrrIgBl8ibbMbar/eH/ItswEY95TtR+gqvEVddSdKGCVhA0c/dQCj+XX O+wycBvt2uSCTGXh5oRFXWNvPyGtAdN7KHzsvCI9mvWqP5C4jNB+PZUXY61qpQbsRd8A aVdgc6YbBjG8VK7Fh18c1mv7RF7hNWg+REMT9fAanzrfrG2ZF4t3OvO5qAK1gw1vr6yL QBF5AodM+SrCdImist6S4rLfK3hyizDQJfrbE/+3sLqIVLEPouo2OtTL1o0zHKWgDTLx bvdUgPzc38g7d1zZGxp9NkfsvkVzXcMnZIALbqzESiQYJb2jP1OaY2I9Lb3MfFs3BPYK iBVg== 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 :message-id:date:subject:to:from:dkim-signature; bh=o2MixFdZlwlNEQ1EG+IsGg5dAo+aZ7N0IY5pU/zVYuQ=; b=wQpY3Y7ednM7jDug6JY4PgSr2I9zGHHiGR5t3z+y+uUQtyWs/NXP/TS7CAW4sDtwWF VnfNz2R+xWQo1dm+kJaihhxk3WGfioi36lfBUpOtj0BBLHu69kQncu1rZySQdEXpKQtn gsrDpc0vPsjeRUuWjqlGE3CdiIsowtqlNUOCV8WY9Cy2a3bX2oKirszfOtg1oDviv4UP ItMeLGt5VYB8luJ5gNMEPyA+GMLOq1xKAt1phLvLNVW82a+yJa8AHNqeuThxcensOcrM o7MOzquR3SGjVJHUyYfbUjh2I33/lEKZvrn+xCptJopfM0V+YU5dANs/Ns8Wh4LIGoxR wwOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=Qv8YGjMl; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a16si10762091ejt.459.2021.02.01.12.49.32; Mon, 01 Feb 2021 12:50:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-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=@oracle.com header.s=corp-2020-01-29 header.b=Qv8YGjMl; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230094AbhBAUso (ORCPT + 99 others); Mon, 1 Feb 2021 15:48:44 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:35542 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229959AbhBAUsn (ORCPT ); Mon, 1 Feb 2021 15:48:43 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 111KhTcH066273; Mon, 1 Feb 2021 20:48:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=o2MixFdZlwlNEQ1EG+IsGg5dAo+aZ7N0IY5pU/zVYuQ=; b=Qv8YGjMlcyeE2TSAKYGMF/0IMujceG7y2sb9YO78ernphXyizD4sC6PKyTjvEueVHLko HJ5CdOUDsdXn134MEySnG/+Rcbw/ISDZqSA2Ln+s/bAj9WMV9sHEhZ7GXKTqQ3y5u5aJ H8U3m+ZCScFX7H2VcddXhQ0GIwBCTdrYCPkRXo9Z58u6OovRcFMIBrqNdgdibL82QcUN ydou8Z0h3Ut/SWNmnSRDz11008tC3H0mis6OllZfvfau5fdvNC3UYieKfIW/z2xyMQJ8 ZgDiVwlcVdfcWfgjWZWokCtkkpeVnw2Sitx7nRPhPo3b5vNB99qsK0oPY0JhLiQBCNnm iQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2130.oracle.com with ESMTP id 36cvyaqqef-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 01 Feb 2021 20:48:01 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 111KeBfS005739; Mon, 1 Feb 2021 20:48:01 GMT Received: from pps.reinject (localhost [127.0.0.1]) by userp3020.oracle.com with ESMTP id 36dh7qav02-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 01 Feb 2021 20:48:01 +0000 Received: from userp3020.oracle.com (userp3020.oracle.com [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 111Km05N037603; Mon, 1 Feb 2021 20:48:00 GMT Received: from aserp3020.oracle.com (ksplice-shell2.us.oracle.com [10.152.118.36]) by userp3020.oracle.com with ESMTP id 36dh7qauy9-1; Mon, 01 Feb 2021 20:48:00 +0000 From: Dai Ngo To: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org Subject: [PATCH] vfs: generic_copy_file_checks should return EINVAL when source offset is beyond EOF Date: Mon, 1 Feb 2021 15:47:56 -0500 Message-Id: <20210201204756.74577-1-dai.ngo@oracle.com> X-Mailer: git-send-email 2.20.1.1226.g1595ea5.dirty MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9882 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1011 impostorscore=0 mlxscore=0 spamscore=0 bulkscore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102010113 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Fix by returning -EINVAL instead of 0, per man page of copy_file_range, when the requested range extends beyond the end of the source file. Probem was discovered by subtest inter11 of nfstest_ssc. Signed-off-by: Dai Ngo --- fs/read_write.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/read_write.c b/fs/read_write.c index 75f764b43418..438c00910716 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1445,7 +1445,7 @@ static int generic_copy_file_checks(struct file *file_in, loff_t pos_in, /* Shorten the copy to EOF */ size_in = i_size_read(inode_in); if (pos_in >= size_in) - count = 0; + count = -EINVAL; else count = min(count, size_in - (uint64_t)pos_in); -- 2.9.5