Question

I have a device driver module which does a register_chardev(). In the driver open() function I wish to be able to determine the pid or pgid of the process which is attempting to open the device node. Is this possible? Does anyone have any ideas of where to begin?

I am assuming this should somewhat secure my device node to only allow my applications to use it, since you cannot migrate a process to a new process group unless they are in the same session.

Was it helpful?

Solution

The kernel isn't the right place to make this kind of policy decision - the correct place to set the permissions on who can open the device node is by setting the usual ownership and permissions on the device node file in the filesystem.

If you really have your heart set on it, current->pid is the PID, current->tgid is the thread group id and current->group_leader->pid is the PGID.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top