On Fri, Oct 26, 2012 at 01:57:43PM +0400, ??????? ???????? wrote:
> I'm working a kernel module, and one of my tasks is to disallow a
> process to open my character device(/dev/xxx) more than once. I tried
> to solve this problem by creating /proc/apu directory, and creating a
> /proc/xxx/{pid} file for when process opens /dev/xxx. This file will
> act as per-process mutex, and provide a way to control resource usage.Whoever had set that "task" upon you deserves to be painfully educated until they realize that thus stated the limitation is absolutely worthless - file does not have to be opened by the same process that uses it. IOW, limiting opens to one per process does not provide any kind of resource control - it's trivially bypassed by creating an AF_UNIX socketpair, then forking children in a loop, each doing open + send SCM_RIGHTS datagram to parent over that socket with opened fd in it + exit. And receiving those datagrams until you get as many opened descriptors for your device as you wanted. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/

