ntsync: Introduce NTSYNC_IOC_CREATE_MUTEX.

This corresponds to the NT syscall NtCreateMutant().

An NT mutex is recursive, with a 32-bit recursion counter. When acquired via
NtWaitForMultipleObjects(), the recursion counter is incremented by one. The OS
records the thread which acquired it.

The OS records the thread which acquired it. However, in order to keep this
driver self-contained, the owning thread ID is managed by user-space, and passed
as a parameter to all relevant ioctls.

The initial owner and recursion count, if any, are specified when the mutex is
created.

Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
Link: https://lore.kernel.org/r/20241213193511.457338-6-zfigura@codeweavers.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Elizabeth Figura
2024-12-13 13:34:46 -06:00
committed by Greg Kroah-Hartman
parent cdbb997822
commit 5bc2479a35
2 changed files with 79 additions and 4 deletions
+8 -1
View File
@@ -15,6 +15,11 @@ struct ntsync_sem_args {
__u32 max;
};
struct ntsync_mutex_args {
__u32 owner;
__u32 count;
};
#define NTSYNC_WAIT_REALTIME 0x1
struct ntsync_wait_args {
@@ -23,7 +28,8 @@ struct ntsync_wait_args {
__u32 count;
__u32 index;
__u32 flags;
__u32 pad[3];
__u32 owner;
__u32 pad[2];
};
#define NTSYNC_MAX_WAIT_COUNT 64
@@ -31,6 +37,7 @@ struct ntsync_wait_args {
#define NTSYNC_IOC_CREATE_SEM _IOW ('N', 0x80, struct ntsync_sem_args)
#define NTSYNC_IOC_WAIT_ANY _IOWR('N', 0x82, struct ntsync_wait_args)
#define NTSYNC_IOC_WAIT_ALL _IOWR('N', 0x83, struct ntsync_wait_args)
#define NTSYNC_IOC_CREATE_MUTEX _IOW ('N', 0x84, struct ntsync_mutex_args)
#define NTSYNC_IOC_SEM_RELEASE _IOWR('N', 0x81, __u32)