Darrick J. Wong
bd9ca962ee
xfs: prevent creating negative-sized file via INSERT_RANGE
...
commit 7d83fb1425 upstream.
During the "insert range" fallocate operation, i_size grows by the
specified 'len' bytes. XFS verifies that i_size + len < s_maxbytes, as
it should. But this comparison is done using the signed 'loff_t', and
'i_size + len' can wrap around to a negative value, causing the check to
incorrectly pass, resulting in an inode with "negative" i_size. This is
possible on 64-bit platforms, where XFS sets s_maxbytes = LLONG_MAX.
ext4 and f2fs don't run into this because they set a smaller s_maxbytes.
Fix it by using subtraction instead.
Reproducer:
xfs_io -f file -c "truncate $(((1<<63)-1))" -c "finsert 0 4096"
Fixes: a904b1ca57 ("xfs: Add support FALLOC_FL_INSERT_RANGE for fallocate")
Cc: <stable@vger.kernel.org > # v4.1+
Originally-From: Eric Biggers <ebiggers@google.com >
Signed-off-by: Eric Biggers <ebiggers@google.com >
Reviewed-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com >
[darrick: fix signed integer addition overflow too]
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com >
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2018-05-09 09:51:52 +02:00
..
2017-11-30 08:40:49 +00:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-03-03 10:24:32 +01:00
2018-04-24 09:36:39 +02:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-04-26 11:02:09 +02:00
2017-11-02 11:10:55 +01:00
2018-04-08 14:26:27 +02:00
2018-04-26 11:02:18 +02:00
2017-11-24 08:37:05 +01:00
2017-06-12 13:20:20 +02:00
2017-11-02 11:10:55 +01:00
2017-11-30 08:40:44 +00:00
2017-07-15 12:00:42 -07:00
2018-02-16 20:23:11 +01:00
2017-11-02 11:10:55 +01:00
2017-11-30 08:40:45 +00:00
2017-07-11 06:09:21 -04:00
2017-11-02 11:10:55 +01:00
2017-09-07 11:59:42 -07:00
2017-03-03 11:38:56 -08:00
2017-11-02 11:10:55 +01:00
2018-05-01 12:58:07 -07:00
2018-04-26 11:02:09 +02:00
2017-12-05 11:26:29 +01:00
2016-06-13 10:20:39 +02:00
2017-11-02 11:10:55 +01:00
2017-10-25 16:34:27 +02:00
2017-12-20 10:10:29 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-04-19 08:56:21 +02:00
2017-11-30 08:40:45 +00:00
2018-05-01 12:58:06 -07:00
2018-04-26 11:02:12 +02:00
2017-11-02 11:10:55 +01:00
2018-02-16 20:22:59 +01:00
2018-02-03 17:39:08 +01:00
2017-11-02 11:10:55 +01:00
2018-03-28 18:24:43 +02:00
2018-04-26 11:02:08 +02:00
2018-02-03 17:39:08 +01:00
2018-04-19 08:56:21 +02:00
2017-11-30 08:40:44 +00:00
2017-11-02 11:10:55 +01:00
2018-04-24 09:36:38 +02:00
2017-11-02 11:10:55 +01:00
2018-04-26 11:02:14 +02:00
2017-11-02 11:10:55 +01:00
2016-12-24 11:46:01 -08:00
2018-04-24 09:36:38 +02:00
2018-04-19 08:56:21 +02:00
2018-04-26 11:02:20 +02:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-02-03 17:39:11 +01:00
2017-09-06 17:27:26 -07:00
2018-04-24 09:36:22 +02:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-03-31 18:10:38 +02:00
2017-11-02 11:10:55 +01:00
2017-07-06 03:31:46 -04:00
2018-04-26 11:02:07 +02:00
2018-04-24 09:36:38 +02:00
2017-11-02 11:10:55 +01:00
2018-05-09 09:51:52 +02:00
2018-03-21 12:06:43 +01:00
2016-12-24 11:46:01 -08:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-09-04 19:05:15 -04:00
2017-09-14 18:13:32 -07:00
2017-09-14 18:13:32 -07:00
2016-08-02 19:35:15 -04:00
2017-11-02 11:10:55 +01:00
2017-10-13 16:18:33 -07:00
2017-10-03 17:54:25 -07:00
2017-10-13 16:18:33 -07:00
2017-11-30 08:40:45 +00:00
2017-11-02 11:10:55 +01:00
2017-02-01 09:13:51 +01:00
2017-11-02 11:10:55 +01:00
2017-04-17 12:52:27 -04:00
2017-11-02 11:10:55 +01:00
2018-04-26 11:02:14 +02:00
2018-04-12 12:32:13 +02:00
2016-12-24 11:46:01 -08:00
2018-03-08 22:41:06 -08:00
2017-11-02 11:10:55 +01:00
2017-07-03 21:13:25 -07:00
2017-09-08 18:26:49 -07:00
2018-03-03 10:24:21 +01:00
2017-12-17 15:07:59 +01:00
2017-11-02 11:10:55 +01:00
2017-08-28 00:50:23 -04:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-03-02 08:42:35 +01:00
2018-04-24 09:36:39 +02:00
2017-09-13 09:11:44 -07:00
2017-09-13 09:11:44 -07:00
2017-11-02 11:10:55 +01:00
2017-10-16 12:11:56 -07:00
2017-07-12 16:26:00 -07:00
2016-10-24 08:12:35 -02:00
2017-07-06 07:02:29 -04:00
2017-07-21 13:57:31 -04:00
2017-11-02 11:10:55 +01:00
2018-02-22 15:42:25 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-04-19 08:56:19 +02:00
2018-04-24 09:36:39 +02:00
2017-11-02 11:10:55 +01:00
2017-09-05 12:53:12 +02:00
2018-02-16 20:23:05 +01:00
2017-05-23 08:41:17 -05:00
2017-02-04 00:01:06 +13:00
2017-03-02 08:42:31 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-02-22 15:42:28 +01:00
2017-11-02 11:10:55 +01:00
2017-09-04 19:05:15 -04:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-03-03 10:24:24 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-01-10 09:31:17 +01:00
2017-11-02 11:10:55 +01:00
2017-10-04 18:03:15 +11:00