TOMOYO: Fix race on updating profile's comment line.
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Sat, 2 Apr 2011 15:09:26 +0000 (00:09 +0900)
committerJames Morris <jmorris@namei.org>
Mon, 18 Apr 2011 23:37:06 +0000 (09:37 +1000)
In tomoyo_write_profile() since 2.6.34, a lock was by error missing when
replacing profile's comment line. If multiple threads attempted

  echo '0-COMMENT=comment' > /sys/kernel/security/tomoyo/profile

in parallel, garbage collector will fail to kfree() the old value.
Protect the replacement using a lock. Also, keep the old value rather than
replace with empty string when out of memory error has occurred.

Signed-off-by: Xiaochen Wang <wangxiaochen0@gmail.com>
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: James Morris <jmorris@namei.org>

No differences found