Date: Fri, 30 Jul 2021 00:33:18 GMT From: Mark Johnston <markj@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 9ac0aec3a32c - stable/13 - lio_listio: Don't post a completion notification if none was requested Message-ID: <202107300033.16U0XIdu043699@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=9ac0aec3a32c84599cfbcc9f70ca2e035a3ddc0b commit 9ac0aec3a32c84599cfbcc9f70ca2e035a3ddc0b Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2021-07-16 02:38:46 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2021-07-30 00:32:58 +0000 lio_listio: Don't post a completion notification if none was requested One is allowed to use LIO_NOWAIT without specifying a sigevent. In this case, lj->lioj_signal is left uninitialized, but several code paths examine liov_signal.sigev_notify to figure out which notification to post. Unconditionally initialize that field to SIGEV_NONE. Add a dumb test case which triggers the bug. Reported by: KMSAN+syzkaller Reviewed by: asomers Sponsored by: The FreeBSD Foundation (cherry picked from commit 2e5f6152952e4cfbaab3d96368c3dc4218786632) --- sys/kern/vfs_aio.c | 1 + tests/sys/aio/lio_test.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/sys/kern/vfs_aio.c b/sys/kern/vfs_aio.c index 640e82b6f0ff..7d4d9ac3e94b 100644 --- a/sys/kern/vfs_aio.c +++ b/sys/kern/vfs_aio.c @@ -2246,6 +2246,7 @@ kern_lio_listio(struct thread *td, int mode, struct aiocb * const *uacb_list, lj->lioj_flags = 0; lj->lioj_count = 0; lj->lioj_finished_count = 0; + lj->lioj_signal.sigev_notify = SIGEV_NONE; knlist_init_mtx(&lj->klist, AIO_MTX(ki)); ksiginfo_init(&lj->lioj_ksi); diff --git a/tests/sys/aio/lio_test.c b/tests/sys/aio/lio_test.c index fb519aac978d..a4f5a6a38632 100644 --- a/tests/sys/aio/lio_test.c +++ b/tests/sys/aio/lio_test.c @@ -133,6 +133,15 @@ ATF_TC_BODY(lio_listio_empty_wait, tc) ATF_REQUIRE_EQ(0, lio_listio(LIO_WAIT, &list, 0, NULL)); } +/* With LIO_NOWAIT, an empty lio_listio should return immediately */ +ATF_TC_WITHOUT_HEAD(lio_listio_empty_nowait); +ATF_TC_BODY(lio_listio_empty_nowait, tc) +{ + struct aiocb *list = NULL; + + ATF_REQUIRE_EQ(0, lio_listio(LIO_NOWAIT, &list, 0, NULL)); +} + /* * With LIO_NOWAIT, an empty lio_listio should send completion notification * immediately @@ -253,6 +262,7 @@ ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, lio_listio_eagain_kevent); + ATF_TP_ADD_TC(tp, lio_listio_empty_nowait); ATF_TP_ADD_TC(tp, lio_listio_empty_nowait_kevent); ATF_TP_ADD_TC(tp, lio_listio_empty_nowait_signal); ATF_TP_ADD_TC(tp, lio_listio_empty_nowait_thread);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202107300033.16U0XIdu043699>