Received: by 10.192.165.148 with SMTP id m20csp2811566imm; Mon, 7 May 2018 01:21:53 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqlUOq14rEQLZ5dvMZB8LY9bqmuNfhM9zcvle8oA85fI7xHIX2DO6yQPQWd5zAO2oIWWCI5 X-Received: by 2002:a17:902:6006:: with SMTP id r6-v6mr36427742plj.70.1525681313414; Mon, 07 May 2018 01:21:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525681313; cv=none; d=google.com; s=arc-20160816; b=D+RQ7JI/LE+8iGzioH0ihgLHCXPHSNcjtUunzErJUzeB/dq03dp+bFR1IRMWrm7F+V 2wmKoWa1zBeCgelRdO7cFOof+ENfle01zww3f8mRNAz80jNux48BggNsD3K+ZhPbyxil OsQUgKJmWDEMPbA+2FvyuvvuEvEy6et79VX7L+wqxi6N3C02AvbGUl2QnXwDtAZZVHsx fSB9dZPZjq3hzEZ/poHkWDic/mSjtXs0JK8civx4AxrT9iEyC4FNJezWXo6ZQ5Lu6OLt o8G+9srz1i38FQxZQnnDj/NhD0flLaVeGETzjPNsJil5Itl7c+EhtsfyVWmIPX8XcI7E omUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=zaKfSZy6t/Zyw7AuRBrwicvBnUQ/4uG9MRkSTNZ5qaY=; b=hW+51KKQtjO6wkCgxrF7ZGyWmDdGgzGeAKDAnK5jQb8njB3PS/hexBsEnsFX/YNeAy MKZOwCCcmxYk2Iu55bn44sPSP2ScMKgd1v1RmxZO7vcoasa7SNR/ehr5kfdGnfDCzHC7 rG48qui6Y4m3b8p6T931Mt/dVbADHcuZicCGEDcI6fnXKD1ts5XFPAE98NyNDE/lDdqW 8NioOO+inNvHZGgVJwiLOjpNVCFODLdXoytWTDWFWsQmFsZOSsjKgUH61ZsGh0Corha+ F4NKHAm4rxTvnRdiIpS6y2zw7Vo6ZMvf6u6KgfFZW6/qb5S8CdYNxO4a/tgZaUPYuzUu f6oA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b77si21702730pfc.320.2018.05.07.01.21.39; Mon, 07 May 2018 01:21:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752049AbeEGIV0 (ORCPT + 99 others); Mon, 7 May 2018 04:21:26 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:53440 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751988AbeEGIVQ (ORCPT ); Mon, 7 May 2018 04:21:16 -0400 Received: by mail-wm0-f68.google.com with SMTP id a67so11908388wmf.3 for ; Mon, 07 May 2018 01:21:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zaKfSZy6t/Zyw7AuRBrwicvBnUQ/4uG9MRkSTNZ5qaY=; b=BXv6m0BmoDcxVE4HZAvrz/sKdZh+4inCp3fjr3LGG64Gm/mxLr9YeM4wbSCjiAzklc PJTHYohrc3T3IEb7aJm51cF/niGI8N1SIN85UnLk8JNN/LbaUiA1HVNyfjKeVhikzgMR Xhlr2gS9txD3Y22fWRqTroeY6PHWUn+PJYUXky95xOBHIn66dRI7HDkjHZ/IDyTRaRVH CXZRzDgBB+uIP4PeqcGIK3bOmewYSsm0S+2teMth/kTguhh1GxFR5cZYmvIwvA4bCraP 2jNQ014WiulLjLiymFfl2QTo2Th0QAGZZVPrG9N1CNfd0QLVPmZ8SmoPxOqmKUiooqkp d46Q== X-Gm-Message-State: ALQs6tBKeDsLpEJ4FfSSdpdOH5kyrGBJ9RcU9Q8wCumi35OY0fsMiO6F c3L1FhMQqJbisYa8gMj/QTqyGw== X-Received: by 10.28.134.17 with SMTP id i17mr118895wmd.107.1525681274914; Mon, 07 May 2018 01:21:14 -0700 (PDT) Received: from veci.piliscsaba.redhat.com (C2B0E321.catv.pool.telekom.hu. [194.176.227.33]) by smtp.gmail.com with ESMTPSA id w6-v6sm26991776wra.16.2018.05.07.01.21.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 May 2018 01:21:14 -0700 (PDT) From: Miklos Szeredi To: Al Viro Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Amir Goldstein Subject: [PATCH 1/3] vfs: dedpue: return s64 Date: Mon, 7 May 2018 10:21:06 +0200 Message-Id: <20180507082108.28186-2-mszeredi@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180507082108.28186-1-mszeredi@redhat.com> References: <20180507082108.28186-1-mszeredi@redhat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org f_op->dedupe_file_range() gets a u64 length to dedup and returns an ssize_t actual length deduped. This breaks badly on 32bit archs since the returned length will be truncated and possibly overflow into the sign bit (xfs and ocfs2 are affected, btrfs limits actual length to 16MiB). Returning s64 should be good, since clone_verify_area() makes sure that the supplied length doesn't overflow. Signed-off-by: Miklos Szeredi --- fs/btrfs/ctree.h | 4 ++-- fs/btrfs/ioctl.c | 6 +++--- fs/ocfs2/file.c | 10 +++++----- fs/read_write.c | 2 +- fs/xfs/xfs_file.c | 2 +- include/linux/fs.h | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 2771cc56a622..019a25962ac8 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -3269,8 +3269,8 @@ void btrfs_get_block_group_info(struct list_head *groups_list, struct btrfs_ioctl_space_info *space); void update_ioctl_balance_args(struct btrfs_fs_info *fs_info, int lock, struct btrfs_ioctl_balance_args *bargs); -ssize_t btrfs_dedupe_file_range(struct file *src_file, u64 loff, u64 olen, - struct file *dst_file, u64 dst_loff); +s64 btrfs_dedupe_file_range(struct file *src_file, u64 loff, u64 olen, + struct file *dst_file, u64 dst_loff); /* file.c */ int __init btrfs_auto_defrag_init(void); diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 632e26d6f7ce..b6a1df6bb895 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -3194,13 +3194,13 @@ static int btrfs_extent_same(struct inode *src, u64 loff, u64 olen, #define BTRFS_MAX_DEDUPE_LEN SZ_16M -ssize_t btrfs_dedupe_file_range(struct file *src_file, u64 loff, u64 olen, - struct file *dst_file, u64 dst_loff) +s64 btrfs_dedupe_file_range(struct file *src_file, u64 loff, u64 olen, + struct file *dst_file, u64 dst_loff) { struct inode *src = file_inode(src_file); struct inode *dst = file_inode(dst_file); u64 bs = BTRFS_I(src)->root->fs_info->sb->s_blocksize; - ssize_t res; + int res; if (olen > BTRFS_MAX_DEDUPE_LEN) olen = BTRFS_MAX_DEDUPE_LEN; diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 6ee94bc23f5b..cf3732df4c2e 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -2537,11 +2537,11 @@ static int ocfs2_file_clone_range(struct file *file_in, len, false); } -static ssize_t ocfs2_file_dedupe_range(struct file *src_file, - u64 loff, - u64 len, - struct file *dst_file, - u64 dst_loff) +static s64 ocfs2_file_dedupe_range(struct file *src_file, + u64 loff, + u64 len, + struct file *dst_file, + u64 dst_loff) { int error; diff --git a/fs/read_write.c b/fs/read_write.c index c4eabbfc90df..6a79c7ec2bb2 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1976,7 +1976,7 @@ int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same) u16 count = same->dest_count; struct file *dst_file; loff_t dst_off; - ssize_t deduped; + s64 deduped; if (!(file->f_mode & FMODE_READ)) return -EINVAL; diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 299aee4b7b0b..d06dd1557d0e 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -868,7 +868,7 @@ xfs_file_clone_range( len, false); } -STATIC ssize_t +STATIC s64 xfs_file_dedupe_range( struct file *src_file, u64 loff, diff --git a/include/linux/fs.h b/include/linux/fs.h index 760d8da1b6c7..6feb121ae48c 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1738,7 +1738,7 @@ struct file_operations { loff_t, size_t, unsigned int); int (*clone_file_range)(struct file *, loff_t, struct file *, loff_t, u64); - ssize_t (*dedupe_file_range)(struct file *, u64, u64, struct file *, + s64 (*dedupe_file_range)(struct file *, u64, u64, struct file *, u64); } __randomize_layout; -- 2.14.3