Bart Van Assche 337b543e27 fs/aio: Restrict kiocb_set_cancel_fn() to I/O submitted via libaio
commit b820de741ae48ccf50dd95e297889c286ff4f760 upstream.

If kiocb_set_cancel_fn() is called for I/O submitted via io_uring, the
following kernel warning appears:

WARNING: CPU: 3 PID: 368 at fs/aio.c:598 kiocb_set_cancel_fn+0x9c/0xa8
Call trace:
 kiocb_set_cancel_fn+0x9c/0xa8
 ffs_epfile_read_iter+0x144/0x1d0
 io_read+0x19c/0x498
 io_issue_sqe+0x118/0x27c
 io_submit_sqes+0x25c/0x5fc
 __arm64_sys_io_uring_enter+0x104/0xab0
 invoke_syscall+0x58/0x11c
 el0_svc_common+0xb4/0xf4
 do_el0_svc+0x2c/0xb0
 el0_svc+0x2c/0xa4
 el0t_64_sync_handler+0x68/0xb4
 el0t_64_sync+0x1a4/0x1a8

Fix this by setting the IOCB_AIO_RW flag for read and write I/O that is
submitted by libaio.

Suggested-by: Jens Axboe <axboe@kernel.dk>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Avi Kivity <avi@scylladb.com>
Cc: Sandeep Dhavale <dhavale@google.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Kent Overstreet <kent.overstreet@linux.dev>
Cc: stable@vger.kernel.org
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20240215204739.2677806-2-bvanassche@acm.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-03-01 13:06:11 +01:00
..
2019-12-13 08:51:18 +01:00
2018-08-18 15:55:59 -07:00
2018-08-23 13:44:43 -07:00
2024-02-23 08:12:39 +01:00
2022-10-26 13:19:32 +02:00
2019-10-05 13:10:03 +02:00
2019-07-03 13:14:48 +02:00
2023-08-08 19:49:17 +02:00
2018-08-22 10:52:48 -07:00
2023-12-20 15:38:01 +01:00
2018-08-25 13:40:38 -07:00
2019-11-24 08:19:14 +01:00
2021-12-08 08:50:13 +01:00
2021-01-30 13:32:12 +01:00
2019-10-17 13:45:42 -07:00
2021-05-22 10:59:50 +02:00
2018-08-08 11:06:20 +02:00
2022-10-26 13:19:35 +02:00
2019-12-13 08:52:43 +01:00
2021-03-04 09:39:44 +01:00
2022-08-25 11:15:23 +02:00
2018-08-18 11:44:53 -07:00
2021-02-07 14:48:38 +01:00
2019-12-31 16:35:38 +01:00
2023-09-23 10:47:59 +02:00
2021-06-30 08:48:18 -04:00
2023-11-20 10:29:17 +01:00
2023-06-21 15:39:57 +02:00
2018-08-23 16:03:58 -07:00
2024-02-23 08:12:49 +01:00
2023-09-23 10:48:05 +02:00
2023-02-22 12:47:17 +01:00
2019-06-11 12:20:52 +02:00
2023-11-28 16:46:33 +00:00
2023-10-25 11:16:20 +02:00
2023-10-25 11:16:20 +02:00
2021-12-14 10:18:04 +01:00
2020-04-02 15:28:22 +02:00
2018-08-16 12:14:42 -07:00
2018-11-13 11:08:51 -08:00
2024-02-23 08:12:39 +01:00
2020-04-02 15:28:23 +02:00
2021-12-14 10:18:06 +01:00