Re: [PATCH] Remove BKL from sysctl(2)

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Alan Cox <alan@...>
Cc: Andi Kleen <andi@...>, Alexey Dobriyan <adobriyan@...>, <akpm@...>, <linux-kernel@...>
Date: Thursday, January 24, 2008 - 3:56 am

> Yes - that's why I am wondering if we want a general 'sysctl' mutex or

I think for the strings it would be better to just do a kind of copy-on-write.
As in don't use the array directly, but a pointer instead and then sysctl 
allocates a new string, switches the pointer around
and then does a RCU delayed free on the old string if it wasn't in .data.

This would also have the advantage that the small upper limits these 
strings currently have are gone and actually save a little memory in 
the common case of them not being changed.

Only case that wouldn't fix would be someone keeping the string accessed
over a sleep point. And for preemptible kernels it would need rcu_read_lock().
So no free lunch without code auditing. But it would be probably the best
way to go forward longer term.

For multi number arrays the code ideally needs to be robust against temporary
inconsistencies.

BTW while interesting in theory in practice i suspect the actual likelyhood
of a user actually hitting such a race is pretty small because sysctls tend
to be set up a boot only where not much is going on.

-Andi

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] Remove BKL from sysctl(2), Alexey Dobriyan, (Tue Jan 22, 4:27 pm)
Re: [PATCH] Remove BKL from sysctl(2), Alan Cox, (Wed Jan 23, 6:51 am)
[PATCH 2/2] Race-free kernel.core_pattern, Alexey Dobriyan, (Sun Jan 27, 8:26 am)
Re: [PATCH 2/2] Race-free kernel.core_pattern, Andi Kleen, (Sun Jan 27, 12:49 pm)
Re: [PATCH] Remove BKL from sysctl(2), Andi Kleen, (Wed Jan 23, 7:09 am)
Re: [PATCH] Remove BKL from sysctl(2), Alan Cox, (Wed Jan 23, 7:38 am)
Re: [PATCH] Remove BKL from sysctl(2), Andi Kleen, (Thu Jan 24, 3:56 am)
Re: [PATCH] Remove BKL from sysctl(2), Ingo Molnar, (Tue Jan 22, 4:52 pm)