Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ntsync: Introduce NTSYNC_IOC_MUTEX_READ.

This corresponds to the NT syscall NtQueryMutant().

This returns the recursion count, owner, and abandoned state of the mutex.

Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
Link: https://lore.kernel.org/r/20241213193511.457338-14-zfigura@codeweavers.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Elizabeth Figura and committed by
Greg Kroah-Hartman
0b3c3144 a948f417

+27
+26
drivers/misc/ntsync.c
··· 605 605 return 0; 606 606 } 607 607 608 + static int ntsync_mutex_read(struct ntsync_obj *mutex, void __user *argp) 609 + { 610 + struct ntsync_mutex_args __user *user_args = argp; 611 + struct ntsync_device *dev = mutex->dev; 612 + struct ntsync_mutex_args args; 613 + bool all; 614 + int ret; 615 + 616 + if (mutex->type != NTSYNC_TYPE_MUTEX) 617 + return -EINVAL; 618 + 619 + all = ntsync_lock_obj(dev, mutex); 620 + 621 + args.count = mutex->u.mutex.count; 622 + args.owner = mutex->u.mutex.owner; 623 + ret = mutex->u.mutex.ownerdead ? -EOWNERDEAD : 0; 624 + 625 + ntsync_unlock_obj(dev, mutex, all); 626 + 627 + if (copy_to_user(user_args, &args, sizeof(args))) 628 + return -EFAULT; 629 + return ret; 630 + } 631 + 608 632 static int ntsync_obj_release(struct inode *inode, struct file *file) 609 633 { 610 634 struct ntsync_obj *obj = file->private_data; ··· 654 630 return ntsync_mutex_unlock(obj, argp); 655 631 case NTSYNC_IOC_MUTEX_KILL: 656 632 return ntsync_mutex_kill(obj, argp); 633 + case NTSYNC_IOC_MUTEX_READ: 634 + return ntsync_mutex_read(obj, argp); 657 635 case NTSYNC_IOC_EVENT_SET: 658 636 return ntsync_event_set(obj, argp, false); 659 637 case NTSYNC_IOC_EVENT_RESET:
+1
include/uapi/linux/ntsync.h
··· 52 52 #define NTSYNC_IOC_EVENT_RESET _IOR ('N', 0x89, __u32) 53 53 #define NTSYNC_IOC_EVENT_PULSE _IOR ('N', 0x8a, __u32) 54 54 #define NTSYNC_IOC_SEM_READ _IOR ('N', 0x8b, struct ntsync_sem_args) 55 + #define NTSYNC_IOC_MUTEX_READ _IOR ('N', 0x8c, struct ntsync_mutex_args) 55 56 56 57 #endif