lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Wed, 31 May 2017 17:42:28 +0800
From:   Lv Zheng <lv.zheng@...el.com>
To:     "Rafael J . Wysocki" <rafael.j.wysocki@...el.com>,
        "Rafael J . Wysocki" <rjw@...ysocki.net>,
        Len Brown <len.brown@...el.com>
Cc:     Lv Zheng <lv.zheng@...el.com>, Lv Zheng <zetalog@...il.com>,
        linux-kernel@...r.kernel.org, linux-acpi@...r.kernel.org,
        Benjamin Tissoires <benjamin.tissoires@...hat.com>,
        Peter Hutterer <peter.hutterer@...-t.net>
Subject: [RFC PATCH v4 5/5] ACPI: button: Cleanup lid notification logics

Both nouveau and i915, the only 2 kernel space lid notification listeners,
invoke acpi_lid_open() API to obtain _LID returning value instead of using
the notified value. So kernel graphics drivers are only interested in _LID
return value, hence this patch makes this logic explicit in button driver.

However the preference may because kernel graphics drivers do not want to
receive non-bios notifications. Thus this patch also adds a global variable
to allow button driver to stop notifying non-bios notifications.

This is a no-op cleanup as the default behaviors are kept unchanged, but
may:
1. improve button.lid_init_state=method by introducing a possibility to
   allow kernel graphics driver to reduce redundant _LID evaluations, and
2. improve button.lid_init_state=open/method by introducing a possibility
   to stop notifying faked non bios events.

Cc: Benjamin Tissoires <benjamin.tissoires@...hat.com>
Cc: Peter Hutterer <peter.hutterer@...-t.net>
Signed-off-by: Lv Zheng <lv.zheng@...el.com>
---
 drivers/acpi/button.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

Index: linux-acpica/drivers/acpi/button.c
===================================================================
--- linux-acpica.orig/drivers/acpi/button.c
+++ linux-acpica/drivers/acpi/button.c
@@ -119,6 +119,7 @@ static u8 lid_init_state = ACPI_BUTTON_L
 static unsigned long lid_report_interval __read_mostly = 500;
 module_param(lid_report_interval, ulong, 0644);
 MODULE_PARM_DESC(lid_report_interval, "Interval (ms) between lid key events");
+static bool lid_notify_non_bios_events = true;
 
 /* --------------------------------------------------------------------------
                               FS Interface (/proc)
@@ -224,7 +225,17 @@ static void acpi_lid_notify_state(struct
 	if (state)
 		pm_wakeup_hard_event(&device->dev);
 
-	acpi_lid_notifier_call(device, state);
+	if (is_bios_event || lid_notify_non_bios_events) {
+		/*
+		 * The kernel drivers are only interested in the _LID
+		 * return value. But there are cases "state" is not a _LID
+		 * return value, so correct it before notifying.
+		 */
+		if (!is_bios_event &&
+		    lid_init_state != ACPI_BUTTON_LID_INIT_METHOD)
+			state = acpi_lid_evaluate_state(device);
+		acpi_lid_notifier_call(device, state);
+	}
 }
 
 static int acpi_button_state_seq_show(struct seq_file *seq, void *offset)
@@ -573,13 +584,13 @@ static int param_set_lid_init_state(cons
 
 	if (!strncmp(val, "open", sizeof("open") - 1)) {
 		lid_init_state = ACPI_BUTTON_LID_INIT_OPEN;
-		pr_info("Notify initial lid state as open\n");
+		pr_info("Report initial lid state as open to input layer\n");
 	} else if (!strncmp(val, "method", sizeof("method") - 1)) {
 		lid_init_state = ACPI_BUTTON_LID_INIT_METHOD;
-		pr_info("Notify initial lid state with _LID return value\n");
+		pr_info("Report initial lid state with _LID return value to input layer\n");
 	} else if (!strncmp(val, "ignore", sizeof("ignore") - 1)) {
 		lid_init_state = ACPI_BUTTON_LID_INIT_IGNORE;
-		pr_info("Do not notify initial lid state\n");
+		pr_info("Do not report initial lid state to input layer\n");
 	} else
 		result = -EINVAL;
 	return result;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ