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] [thread-next>] [day] [month] [year] [list]
Message-ID: <CWXP265MB2680C04F5A68F11BFD36F441C4019@CWXP265MB2680.GBRP265.PROD.OUTLOOK.COM>
Date:   Wed, 30 Jun 2021 11:46:57 +0000
From:   Christian Löhle <CLoehle@...erstone.com>
To:     "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-block@...r.kernel.org" <linux-block@...r.kernel.org>,
        "axboe@...nel.dk" <axboe@...nel.dk>,
        Christian Löhle <CLoehle@...erstone.com>
Subject: [PATCHv2] block: prevent sending events from removed device

Skip kobject_uevent_env in case the associated kobject
no longer exists, as calling kobject_uevent_env with
NULL is not safe.

Signed-off-by: Christian Loehle <cloehle@...erstone.com>
---
 block/genhd.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/block/genhd.c b/block/genhd.c
index 9f8cb7beaad1..46629fbe23ae 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1655,8 +1655,16 @@ static void disk_check_events(struct disk_events *ev,
                     (disk->event_flags & DISK_EVENT_FLAG_UEVENT))
                         envp[nr_events++] = disk_uevents[i];
 
-       if (nr_events)
-               kobject_uevent_env(&disk_to_dev(disk)->kobj, KOBJ_CHANGE, envp);
+       if (nr_events) {
+               struct kobject *dev_kobj = kobject_get(&disk_to_dev(disk)->kobj);
+               /* The device kobject might have been removed in the
+                * meantime, so check for it first.
+                * If it was removed there is no need to signal events
+                */
+               if (dev_kobj)
+                       kobject_uevent_env(dev_kobj, KOBJ_CHANGE, envp);
+               kobject_put(dev_kobj);
+       }
 }
 
 /*
-- 
2.32.0
Hyperstone GmbH | Line-Eid-Strasse 3 | 78467 Konstanz
Managing Directors: Dr. Jan Peter Berns.
Commercial register of local courts: Freiburg HRB381782

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ