From owner-dev-commits-src-branches@freebsd.org Fri Jul 30 00:33:19 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 570586579C1; Fri, 30 Jul 2021 00:33:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GbSzy6z8Mz4vgn; Fri, 30 Jul 2021 00:33:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D25F91B7CD; Fri, 30 Jul 2021 00:33:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 16U0XIg9043700; Fri, 30 Jul 2021 00:33:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 16U0XIdu043699; Fri, 30 Jul 2021 00:33:18 GMT (envelope-from git) Date: Fri, 30 Jul 2021 00:33:18 GMT Message-Id: <202107300033.16U0XIdu043699@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 9ac0aec3a32c - stable/13 - lio_listio: Don't post a completion notification if none was requested MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9ac0aec3a32c84599cfbcc9f70ca2e035a3ddc0b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Jul 2021 00:33:19 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=9ac0aec3a32c84599cfbcc9f70ca2e035a3ddc0b commit 9ac0aec3a32c84599cfbcc9f70ca2e035a3ddc0b Author: Mark Johnston AuthorDate: 2021-07-16 02:38:46 +0000 Commit: Mark Johnston 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);