diff options
author | Ulrich Obergfell <uobergfe@redhat.com> | 2015-11-05 21:44:50 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-11-05 22:34:48 -0500 |
commit | 8614ddef82139d08234dbf681188f9bcddae9f03 (patch) | |
tree | dc10d978bad575ec2045f1605084485e95313806 /kernel/watchdog.c | |
parent | ee89e71eb091d3ef8ca2be8bd4ec77ccfa91334c (diff) |
kernel/watchdog.c: avoid races between /proc handlers and CPU hotplug
The handler functions for watchdog parameters in /proc/sys/kernel do not
protect themselves against races with CPU hotplug. Hence, theoretically
it is possible that a new watchdog thread is started on a hotplugged CPU
while a parameter is being modified, and the thread could thus use a
parameter value that is 'in transition'.
For example, if 'watchdog_thresh' is being set to zero (note: this
disables the lockup detectors) the thread would erroneously use the value
zero as the sample period.
To avoid such races and to keep the /proc handler code consistent,
call
{get|put}_online_cpus() in proc_watchdog_common()
{get|put}_online_cpus() in proc_watchdog_thresh()
{get|put}_online_cpus() in proc_watchdog_cpumask()
Signed-off-by: Ulrich Obergfell <uobergfe@redhat.com>
Acked-by: Don Zickus <dzickus@redhat.com>
Reviewed-by: Aaron Tomlin <atomlin@redhat.com>
Cc: Ulrich Obergfell <uobergfe@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/watchdog.c')
-rw-r--r-- | kernel/watchdog.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/kernel/watchdog.c b/kernel/watchdog.c index 7357842da933..13fdda1a4c91 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c | |||
@@ -857,6 +857,7 @@ static int proc_watchdog_common(int which, struct ctl_table *table, int write, | |||
857 | int err, old, new; | 857 | int err, old, new; |
858 | int *watchdog_param = (int *)table->data; | 858 | int *watchdog_param = (int *)table->data; |
859 | 859 | ||
860 | get_online_cpus(); | ||
860 | mutex_lock(&watchdog_proc_mutex); | 861 | mutex_lock(&watchdog_proc_mutex); |
861 | 862 | ||
862 | if (watchdog_suspended) { | 863 | if (watchdog_suspended) { |
@@ -908,6 +909,7 @@ static int proc_watchdog_common(int which, struct ctl_table *table, int write, | |||
908 | } | 909 | } |
909 | out: | 910 | out: |
910 | mutex_unlock(&watchdog_proc_mutex); | 911 | mutex_unlock(&watchdog_proc_mutex); |
912 | put_online_cpus(); | ||
911 | return err; | 913 | return err; |
912 | } | 914 | } |
913 | 915 | ||
@@ -949,6 +951,7 @@ int proc_watchdog_thresh(struct ctl_table *table, int write, | |||
949 | { | 951 | { |
950 | int err, old; | 952 | int err, old; |
951 | 953 | ||
954 | get_online_cpus(); | ||
952 | mutex_lock(&watchdog_proc_mutex); | 955 | mutex_lock(&watchdog_proc_mutex); |
953 | 956 | ||
954 | if (watchdog_suspended) { | 957 | if (watchdog_suspended) { |
@@ -974,6 +977,7 @@ int proc_watchdog_thresh(struct ctl_table *table, int write, | |||
974 | } | 977 | } |
975 | out: | 978 | out: |
976 | mutex_unlock(&watchdog_proc_mutex); | 979 | mutex_unlock(&watchdog_proc_mutex); |
980 | put_online_cpus(); | ||
977 | return err; | 981 | return err; |
978 | } | 982 | } |
979 | 983 | ||
@@ -988,6 +992,7 @@ int proc_watchdog_cpumask(struct ctl_table *table, int write, | |||
988 | { | 992 | { |
989 | int err; | 993 | int err; |
990 | 994 | ||
995 | get_online_cpus(); | ||
991 | mutex_lock(&watchdog_proc_mutex); | 996 | mutex_lock(&watchdog_proc_mutex); |
992 | 997 | ||
993 | if (watchdog_suspended) { | 998 | if (watchdog_suspended) { |
@@ -1015,6 +1020,7 @@ int proc_watchdog_cpumask(struct ctl_table *table, int write, | |||
1015 | } | 1020 | } |
1016 | out: | 1021 | out: |
1017 | mutex_unlock(&watchdog_proc_mutex); | 1022 | mutex_unlock(&watchdog_proc_mutex); |
1023 | put_online_cpus(); | ||
1018 | return err; | 1024 | return err; |
1019 | } | 1025 | } |
1020 | 1026 | ||