2001-10-31 02:20:53

by John Levon

[permalink] [raw]
Subject: rmmod whilst reading/writing sysctl


Where is the prevention of module unload whilst a sysctl from a module is being read/written ?

sysctl syscall is protected by BKL, but I can't see similar code for the cat >/proc/sys/...
case

If there is none, how do I support sysctl from a module safely ?

thanks
john

--
"I'm dismayed whenever libertarianism and programming are associated; in my
mind, it is as nebulous as associating people who write books as communists or
those who read newspapers as capitalists."
- graydon


2001-10-31 02:32:46

by Alexander Viro

[permalink] [raw]
Subject: Re: rmmod whilst reading/writing sysctl



On Wed, 31 Oct 2001, John Levon wrote:

>
> Where is the prevention of module unload whilst a sysctl from a module is being read/written ?
>
> sysctl syscall is protected by BKL, but I can't see similar code for the cat >/proc/sys/...

... and that protection is worth nothing, since we copy data to/from
userland. Forget about BKL - it doesn't prevent races.

There is a shitload of rmmod (and plain "we remove the object" - it doesn't
have to be a module) races in that area. Composite trees _suck_. sysctls,
devfs, ddfs - whatever. If tree is served by several drivers - it's broken.

In case of sysctls I have an old patch that could be turned into something
working, but that will take a lot of changes in code that exports sysctls,
so that may be very painful.