]> git.karo-electronics.de Git - karo-tx-linux.git/commit
sysctl: refactor sysctl string writing logic
authorKees Cook <keescook@chromium.org>
Thu, 22 May 2014 00:44:10 +0000 (10:44 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 22 May 2014 00:44:10 +0000 (10:44 +1000)
commit40c746c49788ed6a821873e8132cb41297a1d53d
tree199d4675dfc7bef1cb96fa1793ce0fc40d4a2ea3
parentaf5c58f0e6fa74cfbc85547c581904b60f88654e
sysctl: refactor sysctl string writing logic

Consolidate buffer length checking with new-line/end-of-line checking.
Additionally, instead of reading user memory twice, just do the assignment
during the loop.

This change doesn't affect the potential races here.  It was already
possible to read a sysctl that was in the middle of a write.  In both
cases, the string will always be NULL terminated.  The pre-existing race
remains a problem to be solved.

Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
kernel/sysctl.c