[PATCH 14/15] rfkill: do not allow userspace to override ALL RADIOS OFF

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Henrique de Moraes Holschuh
Date: Sunday, May 18, 2008 - 11:48 am

SW_RFKILL_ALL is the "emergency power-off all radios" input event.  It must
be handled, and must always do the same thing as far as the rfkill system
is concerned: all transmitters are to go *immediately* offline.

For safety, do NOT allow userspace to override EV_SW SW_RFKILL_ALL OFF.  As
long as rfkill-input is loaded, that event will *always* be processed, and
it will *always* force all rfkill switches to disable all wireless
transmitters, regardless of user_claim attribute or anything else.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: Ivo van Doorn <IvDoorn@gmail.com>
Cc: Dmitry Torokhov <dtor@mail.ru>
---
 net/rfkill/rfkill-input.c |   29 ++++++++++++++---------------
 net/rfkill/rfkill-input.h |    1 +
 net/rfkill/rfkill.c       |   18 ++++++++++++++++++
 3 files changed, 33 insertions(+), 15 deletions(-)

diff --git a/net/rfkill/rfkill-input.c b/net/rfkill/rfkill-input.c
index 29c13d3..0fadeed 100644
--- a/net/rfkill/rfkill-input.c
+++ b/net/rfkill/rfkill-input.c
@@ -127,21 +127,20 @@ static void rfkill_event(struct input_handle *handle, unsigned int type,
 		switch (code) {
 		case SW_RFKILL_ALL:
 			/* EVERY radio type. data != 0 means radios ON */
-			rfkill_schedule_set(&rfkill_wwan,
-					    (data)? RFKILL_STATE_ON:
-						    RFKILL_STATE_OFF);
-			rfkill_schedule_set(&rfkill_wimax,
-					    (data)? RFKILL_STATE_ON:
-						    RFKILL_STATE_OFF);
-			rfkill_schedule_set(&rfkill_uwb,
-					    (data)? RFKILL_STATE_ON:
-						    RFKILL_STATE_OFF);
-			rfkill_schedule_set(&rfkill_bt,
-					    (data)? RFKILL_STATE_ON:
-						    RFKILL_STATE_OFF);
-			rfkill_schedule_set(&rfkill_wlan,
-					    (data)? RFKILL_STATE_ON:
-						    RFKILL_STATE_OFF);
+			/* handle EPO (emergency power off) through shortcut */
+			if (data) {
+				rfkill_schedule_set(&rfkill_wwan,
+						    RFKILL_STATE_ON);
+				rfkill_schedule_set(&rfkill_wimax,
+						    RFKILL_STATE_ON);
+				rfkill_schedule_set(&rfkill_uwb,
+						    RFKILL_STATE_ON);
+				rfkill_schedule_set(&rfkill_bt,
+						    RFKILL_STATE_ON);
+				rfkill_schedule_set(&rfkill_wlan,
+						    RFKILL_STATE_ON);
+			} else
+				rfkill_epo();
 			break;
 		default:
 			break;
diff --git a/net/rfkill/rfkill-input.h b/net/rfkill/rfkill-input.h
index 4dae500..f63d050 100644
--- a/net/rfkill/rfkill-input.h
+++ b/net/rfkill/rfkill-input.h
@@ -12,5 +12,6 @@
 #define __RFKILL_INPUT_H
 
 void rfkill_switch_all(enum rfkill_type type, enum rfkill_state state);
+void rfkill_epo(void);
 
 #endif /* __RFKILL_INPUT_H */
diff --git a/net/rfkill/rfkill.c b/net/rfkill/rfkill.c
index ba25bde..fdde692 100644
--- a/net/rfkill/rfkill.c
+++ b/net/rfkill/rfkill.c
@@ -182,6 +182,24 @@ void rfkill_switch_all(enum rfkill_type type, enum rfkill_state state)
 EXPORT_SYMBOL(rfkill_switch_all);
 
 /**
+ * rfkill_epo - emergency power off all transmitters
+ *
+ * This kicks all rfkill devices to RFKILL_STATE_OFF, ignoring
+ * everything in its path but rfkill_mutex.
+ */
+void rfkill_epo(void)
+{
+	struct rfkill *rfkill;
+
+	mutex_lock(&rfkill_mutex);
+	list_for_each_entry(rfkill, &rfkill_list, node) {
+		rfkill_toggle_radio(rfkill, RFKILL_STATE_OFF, 1);
+	}
+	mutex_unlock(&rfkill_mutex);
+}
+EXPORT_SYMBOL_GPL(rfkill_epo);
+
+/**
  * rfkill_force_state - Force the internal rfkill radio state
  * @rfkill: pointer to the rfkill class to modify.
  * @state: the current radio state the class should be forced to.
-- 
1.5.5.1

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

Messages in current thread:
[RFC] rfkill class rework, Henrique de Moraes H ..., (Sun May 18, 11:47 am)
[PATCH 01/15] ACPI: thinkpad-acpi: fix initialization erro ..., Henrique de Moraes H ..., (Sun May 18, 11:47 am)
[PATCH 02/15] ACPI: thinkpad-acpi: fix LED handling on old ..., Henrique de Moraes H ..., (Sun May 18, 11:47 am)
[PATCH 03/15] Input: rename SW_RADIO to SW_RFKILL_ALL (v2), Henrique de Moraes H ..., (Sun May 18, 11:47 am)
[PATCH 04/15] rfkill: clarify meaning of rfkill states, Henrique de Moraes H ..., (Sun May 18, 11:47 am)
[PATCH 05/15] rfkill: fix minor typo in kernel doc, Henrique de Moraes H ..., (Sun May 18, 11:47 am)
[PATCH 06/15] rfkill: handle SW_RFKILL_ALL events, Henrique de Moraes H ..., (Sun May 18, 11:47 am)
[PATCH 07/15] rfkill: add parameter to disable radios by d ..., Henrique de Moraes H ..., (Sun May 18, 11:47 am)
[PATCH 08/15] rfkill: add read-write rfkill switch support, Henrique de Moraes H ..., (Sun May 18, 11:47 am)
[PATCH 09/15] rfkill: add the WWAN radio type, Henrique de Moraes H ..., (Sun May 18, 11:47 am)
[PATCH 10/15] rfkill: rework suspend and resume handlers, Henrique de Moraes H ..., (Sun May 18, 11:48 am)
[PATCH 11/15] rfkill: add notifier chains support, Henrique de Moraes H ..., (Sun May 18, 11:48 am)
[PATCH 12/15] rfkill: add type string helper, Henrique de Moraes H ..., (Sun May 18, 11:48 am)
[PATCH 13/15] rfkill: add uevent notifications, Henrique de Moraes H ..., (Sun May 18, 11:48 am)
[PATCH 14/15] rfkill: do not allow userspace to override A ..., Henrique de Moraes H ..., (Sun May 18, 11:48 am)
[PATCH 15/15] rfkill: document rw rfkill switches and clar ..., Henrique de Moraes H ..., (Sun May 18, 11:48 am)
Re: [PATCH 11/15] rfkill: add notifier chains support, Thomas Renninger, (Mon May 19, 1:44 am)
Re: [PATCH 11/15] rfkill: add notifier chains support, Henrique de Moraes H ..., (Mon May 19, 6:10 am)
Re: [PATCH 15/15] rfkill: document rw rfkill switches and ..., Henrique de Moraes H ..., (Mon May 19, 3:04 pm)
Re: [PATCH 05/15] rfkill: fix minor typo in kernel doc, Ivo van Doorn, (Tue May 20, 3:08 am)
Re: [PATCH 06/15] rfkill: handle SW_RFKILL_ALL events, Ivo van Doorn, (Tue May 20, 3:08 am)
Re: [PATCH 09/15] rfkill: add the WWAN radio type, Ivo van Doorn, (Tue May 20, 3:08 am)
Re: [PATCH 11/15] rfkill: add notifier chains support, Ivo van Doorn, (Tue May 20, 3:09 am)
Re: [PATCH 12/15] rfkill: add type string helper, Ivo van Doorn, (Tue May 20, 3:09 am)
Re: [PATCH 13/15] rfkill: add uevent notifications, Ivo van Doorn, (Tue May 20, 3:09 am)
Re: [PATCH 15/15] rfkill: document rw rfkill switches and ..., Henrique de Moraes H ..., (Tue May 20, 8:54 am)
Re: [PATCH 09/15] rfkill: add the WWAN radio type, Henrique de Moraes H ..., (Tue May 20, 6:12 pm)
Re: [PATCH 15/15] rfkill: document rw rfkill switches and ..., Henrique de Moraes H ..., (Tue May 20, 6:44 pm)
Re: [PATCH 09/15] rfkill: add the WWAN radio type, Inaky Perez-Gonzalez, (Tue May 20, 8:35 pm)
Re: [PATCH 09/15] rfkill: add the WWAN radio type, Henrique de Moraes H ..., (Tue May 20, 8:42 pm)
Re: [PATCH 09/15] rfkill: add the WWAN radio type, Inaky Perez-Gonzalez, (Tue May 20, 11:48 pm)
Re: [PATCH 09/15] rfkill: add the WWAN radio type, Henrique de Moraes H ..., (Wed May 21, 7:07 am)
Re: [PATCH 14/15] rfkill: do not allow userspace to overri ..., Henrique de Moraes H ..., (Thu May 22, 1:51 pm)
Re: [PATCH 14/15] rfkill: do not allow userspace to overri ..., Henrique de Moraes H ..., (Tue May 27, 7:08 am)
Re: [PATCH 14/15] rfkill: do not allow userspace to overri ..., Henrique de Moraes H ..., (Tue May 27, 10:41 am)
[PATCH 15/15] rfkill: document rw rfkill switches and clar ..., Henrique de Moraes H ..., (Wed May 28, 5:45 pm)
Re: [PATCH 15/15] rfkill: document rw rfkill switches and ..., Henrique de Moraes H ..., (Thu May 29, 9:26 am)
Re: [PATCH 15/15] rfkill: document rw rfkill switches and ..., Henrique de Moraes H ..., (Thu May 29, 10:22 am)
Re: [PATCH 15/15] rfkill: document rw rfkill switches and ..., Henrique de Moraes H ..., (Thu May 29, 10:46 am)
Re: [PATCH 15/15] rfkill: document rw rfkill switches and ..., Dmitry Torokhov, (Thu May 29, 11:58 am)
Re: [PATCH 15/15] rfkill: document rw rfkill switches and ..., Henrique de Moraes H ..., (Thu May 29, 2:16 pm)
[PATCH] Input: rename SW_RADIO to SW_RFKILL_ALL (v2), Henrique de Moraes H ..., (Thu May 29, 2:25 pm)
Re: [PATCH 15/15] rfkill: document rw rfkill switches and ..., Henrique de Moraes H ..., (Tue Jun 3, 8:11 pm)