From: Al Viro <viro@ZenIV.linux.org.uk>
To: ??????? ???????? <dm.leontiev7@gmail.com>
Cc: linux-kernel@vger.kernel.org, trivial@kernel.org, dleontie@amd.com
Subject: Re: procfs does not return error code when file name is already in use
Date: Fri, 26 Oct 2012 12:03:44 +0100 [thread overview]
Message-ID: <20121026110344.GP2616@ZenIV.linux.org.uk> (raw)
In-Reply-To: <CA+JonM0vrXtGzhv44o5rOH-3z_BuU52=Nu8WmiMz5m1=ENZ9HA@mail.gmail.com>
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.
next prev parent reply other threads:[~2012-10-26 11:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-26 9:57 procfs does not return error code when file name is already in use Дмитрий Леонтьев
2012-10-26 10:06 ` Jiri Kosina
2012-10-26 12:05 ` Thadeu Lima de Souza Cascardo
2012-10-26 11:03 ` Al Viro [this message]
2012-10-26 12:22 ` Thadeu Lima de Souza Cascardo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121026110344.GP2616@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=dleontie@amd.com \
--cc=dm.leontiev7@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=trivial@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox