MIPS: OCTEON: make get_system_type() thread-safe
authorAaro Koskinen <aaro.koskinen@nsn.com>
Tue, 22 Jul 2014 11:51:08 +0000 (14:51 +0300)
committerZefan Li <lizefan@huawei.com>
Thu, 25 Sep 2014 03:49:10 +0000 (11:49 +0800)
commit33df36f48f2877f37037e185b6f11b077de27e5b
treec6b5e1543c7efe9ec06614f9511c9d2b7a5bec59
parent5ccd3e2a9ec54a2e9a9b0a7d9256f2433304fa24
MIPS: OCTEON: make get_system_type() thread-safe

commit 608308682addfdc7b8e2aee88f0e028331d88e4d upstream.

get_system_type() is not thread-safe on OCTEON. It uses static data,
also more dangerous issue is that it's calling cvmx_fuse_read_byte()
every time without any synchronization. Currently it's possible to get
processes stuck looping forever in kernel simply by launching multiple
readers of /proc/cpuinfo:

(while true; do cat /proc/cpuinfo > /dev/null; done) &
(while true; do cat /proc/cpuinfo > /dev/null; done) &
...

Fix by initializing the system type string only once during the early
boot.

Signed-off-by: Aaro Koskinen <aaro.koskinen@nsn.com>
Reviewed-by: Markos Chandras <markos.chandras@imgtec.com>
Patchwork: http://patchwork.linux-mips.org/patch/7437/
Signed-off-by: James Hogan <james.hogan@imgtec.com>
[lizf: Backport to 3.x: adjust context]
Signed-off-by: Zefan Li <lizefan@huawei.com>
arch/mips/cavium-octeon/setup.c