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 for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <a9dc272e4e06db661125b7b4c330821b532afc4d.1642209079.git.mirq-linux@rere.qmqm.pl>
Date:   Sat, 15 Jan 2022 02:12:07 +0100
From:   Michał Mirosław <mirq-linux@...e.qmqm.pl>
To:     Wolfram Sang <wsa@...nel.org>
Cc:     linux-i2c@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] i2c: core: fix potential use-after-free on adapter removal

put_device(&adap->dev) might free the memory pointed to by `adap`,
so we shouldn't read adap->owner after that.

Fix by saving module pointer before calling put_device().

Signed-off-by: Michał Mirosław <mirq-linux@...e.qmqm.pl>
---
 drivers/i2c/i2c-core-base.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 2c59dd748a49..5d694f8ce9ef 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -2464,11 +2464,14 @@ EXPORT_SYMBOL(i2c_get_adapter);
 
 void i2c_put_adapter(struct i2c_adapter *adap)
 {
+	struct module *owner;
+
 	if (!adap)
 		return;
 
+	owner = adap->owner;
 	put_device(&adap->dev);
-	module_put(adap->owner);
+	module_put(owner);
 }
 EXPORT_SYMBOL(i2c_put_adapter);
 
-- 
2.30.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ