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>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <X83OYA0TaUszBD1y@google.com>
Date:   Sun, 6 Dec 2020 22:40:32 -0800
From:   Dmitry Torokhov <dmitry.torokhov@...il.com>
To:     Raul E Rangel <rrangel@...omium.org>
Cc:     linux-input@...r.kernel.org, Shirish.S@....com,
        Andy Shevchenko <andy@...radead.org>,
        Dan Murphy <dmurphy@...com>,
        Darren Hart <dvhart@...radead.org>,
        Jacek Anaszewski <jacek.anaszewski@...il.com>,
        "Lee, Chun-Yi" <jlee@...e.com>, Pavel Machek <pavel@....cz>,
        Rajat Jain <rajatja@...gle.com>,
        Stephen Boyd <swboyd@...omium.org>,
        linux-kernel@...r.kernel.org, linux-leds@...r.kernel.org,
        platform-driver-x86@...r.kernel.org
Subject: Re: [PATCH v2 1/2] Input: i8042 - Prevent intermixing i8042 commands

Hi Raul,

On Thu, Aug 27, 2020 at 02:41:53PM -0600, Raul E Rangel wrote:
> The i8042_mutex must be held by writers of the AUX and KBD ports, as
> well as users of i8042_command. There were a lot of users of
> i8042_command that were not calling i8042_lock_chip/i8042_unlock_chip.
> This resulted in i8042_commands being issues in between PS/2
> transactions.
> 
> This change moves the mutex lock into i8042_command and removes the
> burden of locking the mutex from the callers.

I think there is a benefit for allowing users issue a sequence of
commands to i8042 without interruptions, so I would prefer keeping
i8042_[un]lock_chip() in place.

Given that the issue you were observing was caused by i8042_port_close()
interfering with probing, maybe we could do something like this:


diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index abae23af0791..aff871001eda 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -344,6 +344,8 @@ int i8042_command(unsigned char *param, int command)
 	unsigned long flags;
 	int retval;
 
+	lockdep_assert_held(&i8042_mutex);
+
 	if (!i8042_present)
 		return -1;
 
@@ -364,6 +366,8 @@ static int i8042_kbd_write(struct serio *port, unsigned char c)
 	unsigned long flags;
 	int retval = 0;
 
+	lockdep_assert_held(&i8042_mutex);
+
 	spin_lock_irqsave(&i8042_lock, flags);
 
 	if (!(retval = i8042_wait_write())) {
@@ -411,6 +415,8 @@ static void i8042_port_close(struct serio *serio)
 		port_name = "KBD";
 	}
 
+	i8042_lock_chip();
+
 	i8042_ctr &= ~irq_bit;
 	if (i8042_command(&i8042_ctr, I8042_CMD_CTL_WCTR))
 		pr_warn("Can't write CTR while closing %s port\n", port_name);
@@ -422,6 +428,8 @@ static void i8042_port_close(struct serio *serio)
 	if (i8042_command(&i8042_ctr, I8042_CMD_CTL_WCTR))
 		pr_err("Can't reactivate %s port\n", port_name);
 
+	i8042_unlock_chip();
+
 	/*
 	 * See if there is any data appeared while we were messing with
 	 * port state.


Thanks.

-- 
Dmitry

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ