[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20121026110344.GP2616@ZenIV.linux.org.uk>
Date: Fri, 26 Oct 2012 12:03:44 +0100
From: Al Viro <viro@...IV.linux.org.uk>
To: ??????? ???????? <dm.leontiev7@...il.com>
Cc: linux-kernel@...r.kernel.org, trivial@...nel.org, dleontie@....com
Subject: Re: procfs does not return error code when file name is already in
use
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 majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists