From nobody Fri Jul 24 21:52:32 2026 Received: from list.codeweavrs.com (list.codeweavers.com [4.36.192.163]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9DBEA3E49D0; Thu, 23 Jul 2026 20:13:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=4.36.192.163 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784837601; cv=none; b=RggCkS4f/PUjFmlikX8sC6uHWiF7+Zgtoo8ucEuQQIsa7OYsvQBhYmmO1PKfIk0mdBKTqC01Lp50QyUHYEPXd9tbJHMt2WKKum5wrMjech/V1iwaJZ5cLHgwGQwA6XEPnrdVF0OpAQIMLcN+f2eRa2j5dFZ/5osJ1ei5Bqlkm+8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784837601; c=relaxed/simple; bh=BbUNTYM56/ulELyMb/+QTJintb3w3cqQTEBM2+tC2vg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=q2MLy9KaTA+FWLXA0KBRRy6DcCIVP+5Q/vyjX7abKNZSCt/YWLvXDhfZ5KIn7doi3ScfkPxW2eCWl5yJ/78Z6eIMK19jSS92hKE6l5lo1f9i0+6qNxdCcNwyxaF7D+s/ZrwpgVEvfJMatl6pQxtlkxmt3W8NC/XsKBvC8t37Yh4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=codeweavers.com; spf=pass smtp.mailfrom=codeweavers.com; dkim=pass (2048-bit key) header.d=list.codeweavers.com header.i=@list.codeweavers.com header.b=cQ9jmLMA; arc=none smtp.client-ip=4.36.192.163 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=codeweavers.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=codeweavers.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=list.codeweavers.com header.i=@list.codeweavers.com header.b="cQ9jmLMA" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=list.codeweavers.com; s=list; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=lfHZg+u8ne+vOi+IymxWIYACUEM7LNtzyJvvMTkgCrU=; b=cQ9jmLMAiUbmDlNpRvh2/rqjQD a2ic/5egOdZJT6JzYEioLZXcBqvS7R3ibXrLXX7HoQGYiuKe6+M52jB4t7l93KUNtN5AMfzzLxFvL MnTM8b1GsMs/ZoNt8q9J6ZVIG7DCUfTzlx8UHRiK9B2Cpk3yK8WwtQv5DmdniUM005gjNR97gE40X 1z/NNVYlD+AXowq85Wr6E6tQqWdRPo6DjFBuS0/YoboCcPfqR31PtQQw02j8TOzWu4wTfisCi2+4U w92C4I8d+sShpNmPJH5bzeQH7Pt+Me0qh0KuvMhPLOko3MAYJrT7342YuvRse35oa2X9ExTWtgYAf BYDtNpKw==; Received: from cw137ip160.mn.codeweavers.com ([10.69.137.160] helo=camazotz.mn.codeweavers.com) by list.codeweavrs.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wmzn6-00AV4U-1b; Thu, 23 Jul 2026 15:13:12 -0500 From: Elizabeth Figura To: Arnd Bergmann , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, wine-devel@list.winehq.org, linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org, =?UTF-8?q?Iv=C3=A1n=20Ezequiel=20Rodriguez?= , Elizabeth Figura Subject: [PATCH v2 1/5] selftests: ntsync: fix wake_all CREATE_EVENT fd expectation Date: Thu, 23 Jul 2026 15:12:57 -0500 Message-ID: <20260723201301.11826-2-zfigura@codeweavers.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260723201301.11826-1-zfigura@codeweavers.com> References: <20260723201301.11826-1-zfigura@codeweavers.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Iv=C3=A1n Ezequiel Rodriguez wake_all used EXPECT_EQ(0, objs[3]) after NTSYNC_IOC_CREATE_EVENT. The ioctl returns a non-negative file descriptor on success; check EXPECT_LE(0, objs[3]) like the other CREATE_* paths. The incorrect expectation was noted on list (Mar 2025) but is still present in mainline. Signed-off-by: Iv=C3=A1n Ezequiel Rodriguez Reviewed-by: Elizabeth Figura Signed-off-by: Elizabeth Figura --- tools/testing/selftests/drivers/ntsync/ntsync.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testin= g/selftests/drivers/ntsync/ntsync.c index e6a37214aa46..12b4b81edf7f 100644 --- a/tools/testing/selftests/drivers/ntsync/ntsync.c +++ b/tools/testing/selftests/drivers/ntsync/ntsync.c @@ -968,7 +968,7 @@ TEST(wake_all) auto_event_args.manual =3D false; auto_event_args.signaled =3D true; objs[3] =3D ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &auto_event_args); - EXPECT_EQ(0, objs[3]); + EXPECT_LE(0, objs[3]); =20 wait_args.timeout =3D get_abs_timeout(1000); wait_args.objs =3D (uintptr_t)objs; --=20 2.53.0 From nobody Fri Jul 24 21:52:32 2026 Received: from list.codeweavrs.com (list.codeweavers.com [4.36.192.163]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D89E3DAACF; Thu, 23 Jul 2026 20:13:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=4.36.192.163 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784837602; cv=none; b=Cbc/t3uEyS6uzzkILWj9FoEaqvo17GyULCZOeFMAkhZsK4tOFTOw4nqKqtW7WVGiizj0xvBpmTR37yCNnOBx6hJAkp7n/bq6Ww/hi9ZN5Q4ma8u15o/TqwRS8ai90fsyu5Iv/MvVeocUcUGXU2vD/xH/n7KIYESgBIOLoD9J4Qs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784837602; c=relaxed/simple; bh=0Wi9zUWSkOf738wjiEdsVU2AqpTcWywGE9XaO/v6oDA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VgsBiXmh9OuWjfXxIolWpBoh1S/kfkQSIrcW7HxWDoOUq4hogQk4pl302aPT84FHyD29XLFx13KTgkYvW0fB8k1sQAv1A2crvxs/6aofE1cF1Y4Db0fwQyoWPcS7ie5O3k2egymUAHuxo1bIb8xM5EkXeN6u71fC9E8yeCkTAiI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=codeweavers.com; spf=pass smtp.mailfrom=codeweavers.com; dkim=pass (2048-bit key) header.d=list.codeweavers.com header.i=@list.codeweavers.com header.b=Yo7bIOWX; arc=none smtp.client-ip=4.36.192.163 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=codeweavers.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=codeweavers.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=list.codeweavers.com header.i=@list.codeweavers.com header.b="Yo7bIOWX" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=list.codeweavers.com; s=list; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=q8rRzJ2qbHcAJCSBy7RH5XKBgV60ML6cOeYqsoe+SkA=; b=Yo7bIOWXwPpVndpuAQrHeCwgJB HMGYBDVD+nG493iWGI5Wo7b8ZAe44BRn1DdH/5DaPA5h7jC9ifH2024yLy2UsrfRjWUeckOjsot9m rw+m39KR0C9ioDxGex8PskR8u/+do66K1qQAwlVFqCnMgVxvVYfAribmGNV1QxrX+GFEj0SG7sO/R DnS0zjtehXZ2TUUcoR6tiWHNx2sD2TSQrs87izK8bcSS0nOwfvbj4jBfH2oeM1cW9scEdSj5ixxGV NB9dZVpArt8ymlV8ukgYDoX//xfk6pl+k65Wb8nuBOiYQiXDTrnCsJ9lpV0dmBUioMin5Ar1DBV8H XZYFrCVQ==; Received: from cw137ip160.mn.codeweavers.com ([10.69.137.160] helo=camazotz.mn.codeweavers.com) by list.codeweavrs.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wmzn6-00AV4U-1c; Thu, 23 Jul 2026 15:13:12 -0500 From: Elizabeth Figura To: Arnd Bergmann , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, wine-devel@list.winehq.org, linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org, =?UTF-8?q?Iv=C3=A1n=20Ezequiel=20Rodriguez?= , Elizabeth Figura Subject: [PATCH v2 2/5] selftests: ntsync: add wait argument validation tests Date: Thu, 23 Jul 2026 15:12:58 -0500 Message-ID: <20260723201301.11826-3-zfigura@codeweavers.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260723201301.11826-1-zfigura@codeweavers.com> References: <20260723201301.11826-1-zfigura@codeweavers.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Iv=C3=A1n Ezequiel Rodriguez Add coverage for documented EINVAL cases: zero owner on wait any/all, non-zero pad, and objects from a different /dev/ntsync instance. Signed-off-by: Iv=C3=A1n Ezequiel Rodriguez Reviewed-by: Elizabeth Figura Signed-off-by: Elizabeth Figura --- .../testing/selftests/drivers/ntsync/ntsync.c | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testin= g/selftests/drivers/ntsync/ntsync.c index 12b4b81edf7f..c9fe4d5987ec 100644 --- a/tools/testing/selftests/drivers/ntsync/ntsync.c +++ b/tools/testing/selftests/drivers/ntsync/ntsync.c @@ -1340,4 +1340,48 @@ TEST(stress_wait) close(stress_device); } =20 +TEST(wait_args_validation) +{ + struct ntsync_sem_args sem_args =3D { .count =3D 1, .max =3D 1 }; + struct ntsync_wait_args wait_args =3D {0}; + struct timespec timeout; + int fd, fd2, sem, ret; + __u32 index; + + fd =3D open("/dev/ntsync", O_CLOEXEC | O_RDONLY); + ASSERT_GE(fd, 0); + + fd2 =3D open("/dev/ntsync", O_CLOEXEC | O_RDONLY); + ASSERT_GE(fd2, 0); + + sem =3D ioctl(fd, NTSYNC_IOC_CREATE_SEM, &sem_args); + EXPECT_GE(sem, 0); + + ret =3D wait_any(fd, 1, &sem, 0, &index); + EXPECT_EQ(-1, ret); + EXPECT_EQ(EINVAL, errno); + + ret =3D wait_all(fd, 1, &sem, 0, &index); + EXPECT_EQ(-1, ret); + EXPECT_EQ(EINVAL, errno); + + clock_gettime(CLOCK_MONOTONIC, &timeout); + wait_args.timeout =3D timeout.tv_sec * 1000000000ULL + timeout.tv_nsec; + wait_args.count =3D 0; + wait_args.objs =3D 0; + wait_args.owner =3D 123; + wait_args.pad =3D 1; + ret =3D ioctl(fd, NTSYNC_IOC_WAIT_ANY, &wait_args); + EXPECT_EQ(-1, ret); + EXPECT_EQ(EINVAL, errno); + + ret =3D wait_any(fd2, 1, &sem, 123, &index); + EXPECT_EQ(-1, ret); + EXPECT_EQ(EINVAL, errno); + + close(sem); + close(fd2); + close(fd); +} + TEST_HARNESS_MAIN --=20 2.53.0 From nobody Fri Jul 24 21:52:32 2026 Received: from list.codeweavrs.com (list.codeweavers.com [4.36.192.163]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9DADC3E49C5; Thu, 23 Jul 2026 20:13:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=4.36.192.163 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784837602; cv=none; b=uSD0P7mrm4Aoe72DOuHo8Q3CUq58B8Ff3X/Z4kjnvC0w+Qn2BhPeMT70id8KlOqO0JwW0rL5ONxoNbz65vph9FnR7HqUvqSx0Hw2TTaNYFYb4bT8oF1rG+UpoxWY0I+ZDY5ALHNT1Hy+uiqGnHtgcCzvZPB3MwquH0eVoyGYNy4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784837602; c=relaxed/simple; bh=syfQgoDuHaZrDYKHpmrAqG01+IvjiRi6SEgNM2+X1oM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=n3TYDKDzkzY96jiY15feoLmHzrs9SNqpth1DhxhF1V/3V26wLTxVB4PNPcdUHZxoTWlw/vJZZg+KKLrNILnpmKu3H8ZyMERHfe6gG3TZSSPwgXHVu1Gg4vsXOIH6jW6BGRSauuOECAFJ8IjBzKNKlB7uxN8DlxlvqANC5vd3No0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=codeweavers.com; spf=pass smtp.mailfrom=codeweavers.com; dkim=pass (2048-bit key) header.d=list.codeweavers.com header.i=@list.codeweavers.com header.b=pS89HMA0; arc=none smtp.client-ip=4.36.192.163 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=codeweavers.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=codeweavers.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=list.codeweavers.com header.i=@list.codeweavers.com header.b="pS89HMA0" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=list.codeweavers.com; s=list; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=cGytKmpTZSgV/TsaLNwpn0WgDkhwBsVUwPMmrW//LJk=; b=pS89HMA0RB7fMwiwXVOMws+2nB 1U2Ib7m6jf8Msxhh0DyooJ1qT2W2I/MlKxdx5FTBem0YhgfQAlRhSC9ISi8E2kft1OXo4Poks4jT4 x538ckI6w89QGm3A4zy3LKz7bdBYJzKjCVB7J/xqwQFRbX6flFOmRw0BXZ3TUL46kqtBOpidAY0Df Zx+aRs6BAy/VtrSOAnViSFE0kkV/CSXBnkMWGr2SOWEsrmhDBIT2uaFSW6CSMLecYtydQ66dRBrPm V1Y2FyySp4I+L49FXWYxi8pdk1fxWPdCD/MpCOpIFg4fJhXEaxNNos6fUo2USNwEbxviaG3v2Ju1V YQL+BEZA==; Received: from cw137ip160.mn.codeweavers.com ([10.69.137.160] helo=camazotz.mn.codeweavers.com) by list.codeweavrs.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wmzn6-00AV4U-1e; Thu, 23 Jul 2026 15:13:12 -0500 From: Elizabeth Figura To: Arnd Bergmann , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, wine-devel@list.winehq.org, linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org, =?UTF-8?q?Iv=C3=A1n=20Ezequiel=20Rodriguez?= , Elizabeth Figura Subject: [PATCH v2 3/5] ntsync: reject wait ioctls with zero owner Date: Thu, 23 Jul 2026 15:12:59 -0500 Message-ID: <20260723201301.11826-4-zfigura@codeweavers.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260723201301.11826-1-zfigura@codeweavers.com> References: <20260723201301.11826-1-zfigura@codeweavers.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Iv=C3=A1n Ezequiel Rodriguez setup_wait() already validates pad and flags but not owner, while Documentation/userspace-api/ntsync.rst requires EINVAL when owner is zero. Reject early before queueing waiters. Signed-off-by: Iv=C3=A1n Ezequiel Rodriguez Reviewed-by: Elizabeth Figura Signed-off-by: Elizabeth Figura --- drivers/misc/ntsync.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c index 02c9d1192812..4a805919bb0c 100644 --- a/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c @@ -875,6 +875,9 @@ static int setup_wait(struct ntsync_device *dev, if (args->pad || (args->flags & ~NTSYNC_WAIT_REALTIME)) return -EINVAL; =20 + if (!args->owner) + return -EINVAL; + if (size >=3D sizeof(fds)) return -EINVAL; =20 --=20 2.53.0 From nobody Fri Jul 24 21:52:32 2026 Received: from list.codeweavrs.com (list.codeweavers.com [4.36.192.163]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9DA453E3DA8; Thu, 23 Jul 2026 20:13:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=4.36.192.163 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784837601; cv=none; b=I9tkGKiU5+JOeX0c7lxE9dCPRG4JBDnrW2ZjlK6fWoDDbw+RFXI5fzizuXqUMIFWejPpFeHSLudNlWbFXxgYLG14VQBmQ5O5acfj8jepYPJrNjKXgIICsPj4wlzu65vy+1eCcxrn7cfnpRfzrcJNCxIZSI3fl6OV/PJAQQMfLxw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784837601; c=relaxed/simple; bh=Xf7wAcoRtFZotd4VLVhITpCZt9cl7v4vEeMx2/JpWzU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Hp+6Ao65m3H0m1UKFEZ0SMfCk3XOkf0kg87VtzDxX5h7kGJCQxOpLP0ukhtJ0XcSpQwPMB0GqWhLj/aGBKJWu5YroLxoDV23KjBE4Ccy6/a5IEsb9Xkec6KqxMVTI4of4SYmLFv2LUa/y5knA7rqXEkhbygv4tLjJjx9dk94wzY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=codeweavers.com; spf=pass smtp.mailfrom=codeweavers.com; dkim=pass (2048-bit key) header.d=list.codeweavers.com header.i=@list.codeweavers.com header.b=D9VoTu5m; arc=none smtp.client-ip=4.36.192.163 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=codeweavers.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=codeweavers.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=list.codeweavers.com header.i=@list.codeweavers.com header.b="D9VoTu5m" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=list.codeweavers.com; s=list; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=UxuQK04fIAEZo/d2eQ1fm293Y0mtwcRrhlz+o59yJjk=; b=D9VoTu5m6TSRY3x6ZeOiYoX68c r/BSYPLo47MrCmvDEOT2A+xGhBZIyTuDwoRtmLtcK+RVQPiScqrKKMXYf1aBEHpwLzpHll+t8UmxK vC3Or86kdGEEKusHjswdoXtaEmU+JvYRGWRPj3PaeUBWDzjKlRNaTeXS7qeNSupRTQgphWTfdPjSq jiDiLPWPJGuHKyHSde1Z2utM9jK2UtV4bwtcWPTzBRS5OPnIMMYlHTlsR1DYg/gnbwGHWr3J9daEB wmSfX2OA2r4acFYSbwRr9Fu9EGIDUkgZVj23ZOa5Qi918Us8kiwoATOSlhkMX9Xl6kN5Hz8ACcfom QBNExonA==; Received: from cw137ip160.mn.codeweavers.com ([10.69.137.160] helo=camazotz.mn.codeweavers.com) by list.codeweavrs.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wmzn6-00AV4U-1f; Thu, 23 Jul 2026 15:13:12 -0500 From: Elizabeth Figura To: Arnd Bergmann , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, wine-devel@list.winehq.org, linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org, =?UTF-8?q?Iv=C3=A1n=20Ezequiel=20Rodriguez?= , Elizabeth Figura Subject: [PATCH v2 4/5] docs: ntsync: align ioctl names and struct layouts with uapi Date: Thu, 23 Jul 2026 15:13:00 -0500 Message-ID: <20260723201301.11826-5-zfigura@codeweavers.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260723201301.11826-1-zfigura@codeweavers.com> References: <20260723201301.11826-1-zfigura@codeweavers.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Iv=C3=A1n Ezequiel Rodriguez The uAPI documentation used outdated or conceptual ioctl macro names and listed ntsync_event_args / ntsync_wait_args fields in the wrong order. Match include/uapi/linux/ntsync.h and note that absolute MONOTONIC timeouts are interpreted in the caller's time namespace. Signed-off-by: Iv=C3=A1n Ezequiel Rodriguez Reviewed-by: Elizabeth Figura Signed-off-by: Elizabeth Figura --- Documentation/userspace-api/ntsync.rst | 33 +++++++++++++------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/Documentation/userspace-api/ntsync.rst b/Documentation/userspa= ce-api/ntsync.rst index 25e7c4aef968..a778016feb87 100644 --- a/Documentation/userspace-api/ntsync.rst +++ b/Documentation/userspace-api/ntsync.rst @@ -83,18 +83,18 @@ structures used in ioctl calls:: }; =20 struct ntsync_event_args { - __u32 signaled; __u32 manual; + __u32 signaled; }; =20 struct ntsync_wait_args { __u64 timeout; __u64 objs; __u32 count; - __u32 owner; __u32 index; - __u32 alert; __u32 flags; + __u32 owner; + __u32 alert; __u32 pad; }; =20 @@ -152,7 +152,7 @@ The ioctls on the device file are as follows: =20 The ioctls on the individual objects are as follows: =20 -.. c:macro:: NTSYNC_IOC_SEM_POST +.. c:macro:: NTSYNC_IOC_SEM_RELEASE =20 Post to a semaphore object. Takes a pointer to a 32-bit integer, which on input holds the count to be added to the semaphore, and on @@ -186,7 +186,7 @@ The ioctls on the individual objects are as follows: unowned and signaled, and eligible threads waiting on it will be woken as appropriate. =20 -.. c:macro:: NTSYNC_IOC_SET_EVENT +.. c:macro:: NTSYNC_IOC_EVENT_SET =20 Signal an event object. Takes a pointer to a 32-bit integer, which on output contains the previous state of the event. @@ -194,12 +194,12 @@ The ioctls on the individual objects are as follows: Eligible threads will be woken, and auto-reset events will be designaled appropriately. =20 -.. c:macro:: NTSYNC_IOC_RESET_EVENT +.. c:macro:: NTSYNC_IOC_EVENT_RESET =20 Designal an event object. Takes a pointer to a 32-bit integer, which on output contains the previous state of the event. =20 -.. c:macro:: NTSYNC_IOC_PULSE_EVENT +.. c:macro:: NTSYNC_IOC_EVENT_PULSE =20 Wake threads waiting on an event object while leaving it in an unsignaled state. Takes a pointer to a 32-bit integer, which on @@ -213,7 +213,7 @@ The ioctls on the individual objects are as follows: afterwards, and a simultaneous read operation will always report the event as unsignaled. =20 -.. c:macro:: NTSYNC_IOC_READ_SEM +.. c:macro:: NTSYNC_IOC_SEM_READ =20 Read the current state of a semaphore object. Takes a pointer to struct :c:type:`ntsync_sem_args`, which is used as follows: @@ -225,7 +225,7 @@ The ioctls on the individual objects are as follows: * - ``max`` - On output, contains the maximum count of the semaphore. =20 -.. c:macro:: NTSYNC_IOC_READ_MUTEX +.. c:macro:: NTSYNC_IOC_MUTEX_READ =20 Read the current state of a mutex object. Takes a pointer to struct :c:type:`ntsync_mutex_args`, which is used as follows: @@ -242,7 +242,7 @@ The ioctls on the individual objects are as follows: ``EOWNERDEAD``. In this case, ``count`` and ``owner`` are set to zero. =20 -.. c:macro:: NTSYNC_IOC_READ_EVENT +.. c:macro:: NTSYNC_IOC_EVENT_READ =20 Read the current state of an event object. Takes a pointer to struct :c:type:`ntsync_event_args`, which is used as follows: @@ -255,7 +255,7 @@ The ioctls on the individual objects are as follows: - On output, contains 1 if the event is a manual-reset event, and 0 otherwise. =20 -.. c:macro:: NTSYNC_IOC_KILL_OWNER +.. c:macro:: NTSYNC_IOC_MUTEX_KILL =20 Mark a mutex as unowned and abandoned if it is owned by the given owner. Takes an input-only pointer to a 32-bit integer denoting the @@ -276,11 +276,12 @@ The ioctls on the individual objects are as follows: * - ``timeout`` - Absolute timeout in nanoseconds. If ``NTSYNC_WAIT_REALTIME`` is set, the timeout is measured against the REALTIME clock; - otherwise it is measured against the MONOTONIC clock. If the - timeout is equal to or earlier than the current time, the - function returns immediately without sleeping. If ``timeout`` - is U64_MAX, the function will sleep until an object is - signaled, and will not fail with ``ETIMEDOUT``. + otherwise it is measured against the MONOTONIC clock in the + caller's time namespace. If the timeout is equal to or earlier + than the current time, the function returns immediately + without sleeping. If ``timeout`` is U64_MAX, the function will + sleep until an object is signaled, and will not fail with + ``ETIMEDOUT``. * - ``objs`` - Pointer to an array of ``count`` file descriptors (specified as an integer so that the structure has the same --=20 2.53.0 From nobody Fri Jul 24 21:52:32 2026 Received: from list.codeweavrs.com (list.codeweavers.com [4.36.192.163]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D93D3E3C53; Thu, 23 Jul 2026 20:13:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=4.36.192.163 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784837602; cv=none; b=fU3y6ZCLX0TKlif+Pp24hZaBpnd++rT8dCslWUlfoUDbEzvdFgu6EV9etpuJ42EW98yS36W4qonF0Sp0Fipx0Qo/kxtTwpVzeMYkb2QQ3NvXeHMVDYKYCpIib/HbYi0Rjz5Oe3wdg52bkKyxUbecgZJlNo1aC8UitkD3+4N7oOk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784837602; c=relaxed/simple; bh=rE5HbVqtofkngexVaaky72bibZgS/dEumsKq+/P38/g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fQ9JBVoEthIW2ZWMqpXv0MgjNNkWFyDATtQ8jspJkVZNi47V7z8pTlKNKOB2oj99s7H4YC/TlXBEopYQpojBdH6qZFmICrJoIP1q/Uk6OCmDxTtL/rm9Mb7lRxHRtopppMLKUCtk8VmLtyrOWdNUR/+3stYG8sOtKvZO7bk8BNs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=codeweavers.com; spf=pass smtp.mailfrom=codeweavers.com; dkim=pass (2048-bit key) header.d=list.codeweavers.com header.i=@list.codeweavers.com header.b=d/wc8GVv; arc=none smtp.client-ip=4.36.192.163 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=codeweavers.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=codeweavers.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=list.codeweavers.com header.i=@list.codeweavers.com header.b="d/wc8GVv" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=list.codeweavers.com; s=list; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=wd4ttW1UD6XVjsWmzADxCG/cukZBLY0mcKBMFwzC5Zw=; b=d/wc8GVvGfeh3ZVob9KfPCkIy+ Q/tbb0T5G94td60ZmY9KFjXT8sa5Zx+asvazYs0crQ1/S6JjYZdazykquJP5PrFGhXvNcoJG68K4d R+l+RIWQVp4jBj0EFa2fTgRuHB0IqkMNydjKWkvmamj0cLdIeITTjx2E3g46k7UpzwwhwTDXFfvRF UvtGspbj0QqS6Sse/32Kp24Jw3o/j6uHRlconh+LLcjx3b0Vwyah+AePKyVOSw41efBlL7NIycD92 DTIjFXH0SQ43ele188C5/tfgSHG7UaF8gw5jBrCmK2i+J51gczwcjBkRyKbtC6c25i/gK9YR4hQAF aSV5TbCA==; Received: from cw137ip160.mn.codeweavers.com ([10.69.137.160] helo=camazotz.mn.codeweavers.com) by list.codeweavrs.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wmzn6-00AV4U-1h; Thu, 23 Jul 2026 15:13:12 -0500 From: Elizabeth Figura To: Arnd Bergmann , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, wine-devel@list.winehq.org, linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org, =?UTF-8?q?Iv=C3=A1n=20Ezequiel=20Rodriguez?= , Maoyi Xie , Elizabeth Figura Subject: [PATCH v2 5/5] selftests: ntsync: test absolute MONOTONIC waits under time namespaces Date: Thu, 23 Jul 2026 15:13:01 -0500 Message-ID: <20260723201301.11826-6-zfigura@codeweavers.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260723201301.11826-1-zfigura@codeweavers.com> References: <20260723201301.11826-1-zfigura@codeweavers.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Iv=C3=A1n Ezequiel Rodriguez Cover the timens conversion in ntsync_schedule(): with a negative CLOCK_MONOTONIC offset, a 100 ms absolute wait must not return immediately against the host clock. Suggested-by: Maoyi Xie Signed-off-by: Iv=C3=A1n Ezequiel Rodriguez Reviewed-by: Elizabeth Figura Signed-off-by: Elizabeth Figura --- .../testing/selftests/drivers/ntsync/ntsync.c | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testin= g/selftests/drivers/ntsync/ntsync.c index c9fe4d5987ec..1f0dc43bb4c0 100644 --- a/tools/testing/selftests/drivers/ntsync/ntsync.c +++ b/tools/testing/selftests/drivers/ntsync/ntsync.c @@ -8,12 +8,18 @@ #define _GNU_SOURCE #include #include +#include #include +#include #include #include #include #include "kselftest_harness.h" =20 +#ifndef CLONE_NEWTIME +#define CLONE_NEWTIME 0x00000080 +#endif + static int read_sem_state(int sem, __u32 *count, __u32 *max) { struct ntsync_sem_args args; @@ -1384,4 +1390,85 @@ TEST(wait_args_validation) close(fd); } =20 +/* + * Absolute MONOTONIC timeouts must honour the caller's time namespace. + * With a negative monotonic offset, a 100 ms wait must still take ~100 ms + * of namespace time (not return immediately against the host clock). + */ +TEST(wait_any_monotonic_timens) +{ + struct ntsync_sem_args sem_args =3D {0}; + struct ntsync_wait_args wait_args =3D {0}; + struct timespec start, end; + char buf[64]; + __u64 elapsed_ns; + int fd, offset_fd, sem, ret, status, len; + pid_t pid; + + if (access("/proc/self/ns/time", F_OK)) + SKIP(return, "Time namespaces are not supported"); + + fd =3D open("/dev/ntsync", O_CLOEXEC | O_RDONLY); + if (fd < 0) + SKIP(return, "/dev/ntsync is not available"); + + ret =3D unshare(CLONE_NEWTIME); + if (ret) { + close(fd); + if (errno =3D=3D EPERM) + SKIP(return, "need CAP_SYS_ADMIN for CLONE_NEWTIME"); + ASSERT_EQ(0, ret); + } + + len =3D snprintf(buf, sizeof(buf), "%d %d 0", CLOCK_MONOTONIC, -10); + offset_fd =3D open("/proc/self/timens_offsets", O_WRONLY); + ASSERT_LE(0, offset_fd); + ASSERT_EQ(len, write(offset_fd, buf, len)); + close(offset_fd); + + pid =3D fork(); + ASSERT_LE(0, pid); + if (!pid) { + int obj; + + sem_args.count =3D 0; + sem_args.max =3D 1; + sem =3D ioctl(fd, NTSYNC_IOC_CREATE_SEM, &sem_args); + if (sem < 0) + _exit(1); + + obj =3D sem; + wait_args.timeout =3D get_abs_timeout(100); + wait_args.objs =3D (uintptr_t)&obj; + wait_args.count =3D 1; + wait_args.owner =3D 123; + wait_args.index =3D 0xdeadbeef; + + if (clock_gettime(CLOCK_MONOTONIC, &start)) + _exit(2); + ret =3D ioctl(fd, NTSYNC_IOC_WAIT_ANY, &wait_args); + if (clock_gettime(CLOCK_MONOTONIC, &end)) + _exit(2); + + if (ret !=3D -1 || errno !=3D ETIMEDOUT) + _exit(3); + + elapsed_ns =3D (end.tv_sec - start.tv_sec) * 1000000000ULL + + (end.tv_nsec - start.tv_nsec); + /* Without timens conversion this returns in ~0 ms. */ + if (elapsed_ns < 50 * 1000000ULL) + _exit(4); + if (elapsed_ns > 1000 * 1000000ULL) + _exit(5); + + _exit(0); + } + + ASSERT_EQ(pid, waitpid(pid, &status, 0)); + EXPECT_TRUE(WIFEXITED(status)); + EXPECT_EQ(0, WEXITSTATUS(status)); + + close(fd); +} + TEST_HARNESS_MAIN --=20 2.53.0