Arnd Bergmann f531d4bc6c ftruncate: pass a signed offset
commit 4b8e88e563b5f666446d002ad0dc1e6e8e7102b0 upstream.

The old ftruncate() syscall, using the 32-bit off_t misses a sign
extension when called in compat mode on 64-bit architectures.  As a
result, passing a negative length accidentally succeeds in truncating
to file size between 2GiB and 4GiB.

Changing the type of the compat syscall to the signed compat_off_t
changes the behavior so it instead returns -EINVAL.

The native entry point, the truncate() syscall and the corresponding
loff_t based variants are all correct already and do not suffer
from this mistake.

Fixes: 3f6d078d4acc ("fix compat truncate/ftruncate")
Reviewed-by: Christian Brauner <brauner@kernel.org>
Cc: stable@vger.kernel.org
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-07-05 09:08:31 +02:00
..
2019-09-17 10:27:46 -07:00
2020-02-19 19:53:09 +01:00
2024-02-23 08:24:48 +01:00
2022-10-26 13:22:39 +02:00
2019-08-28 21:17:12 -06:00
2024-07-05 09:08:31 +02:00
2023-08-08 19:56:33 +02:00
2019-09-17 19:15:14 -07:00
2023-12-20 15:41:18 +01:00
2024-04-13 12:51:35 +02:00
2020-03-25 08:25:58 +01:00
2019-09-05 11:40:54 +02:00
2019-10-02 06:36:50 -07:00
2023-10-25 11:53:22 +02:00
2022-10-26 13:22:46 +02:00
2022-04-15 14:18:32 +02:00
2023-08-11 11:53:43 +02:00
2019-12-13 08:42:53 +01:00
2021-03-04 10:26:29 +01:00
2022-08-25 11:18:04 +02:00
2021-02-07 15:35:49 +01:00
2022-10-07 09:16:54 +02:00
2019-09-29 10:33:41 -07:00
2019-12-13 08:43:18 +01:00
2023-09-23 10:59:40 +02:00
2023-11-20 10:30:10 +01:00
2023-06-21 15:44:10 +02:00
2024-02-23 08:25:01 +01:00
2020-03-18 07:17:46 +01:00
2023-11-28 16:50:16 +00:00
2023-10-25 11:53:18 +02:00
2023-10-25 11:53:18 +02:00
2020-04-02 15:11:00 +02:00
2021-03-07 12:20:49 +01:00
2024-07-05 09:08:31 +02:00
2024-02-23 08:24:47 +01:00
2020-04-02 15:11:00 +02:00
2021-06-10 13:37:14 +02:00