All of lore.kernel.org
 help / color / mirror / Atom feed
* Patch "IB/core: Fix sysfs registration error flow" has been added to the 4.4-stable tree
@ 2017-05-17 15:56 gregkh
  0 siblings, 0 replies; only message in thread
From: gregkh @ 2017-05-17 15:56 UTC (permalink / raw)
  To: jackm, dledford, gregkh, leon; +Cc: stable, stable-commits


This is a note to let you know that I've just added the patch titled

    IB/core: Fix sysfs registration error flow

to the 4.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     ib-core-fix-sysfs-registration-error-flow.patch
and it can be found in the queue-4.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.


>From b312be3d87e4c80872cbea869e569175c5eb0f9a Mon Sep 17 00:00:00 2001
From: Jack Morgenstein <jackm@dev.mellanox.co.il>
Date: Sun, 19 Mar 2017 10:55:57 +0200
Subject: IB/core: Fix sysfs registration error flow

From: Jack Morgenstein <jackm@dev.mellanox.co.il>

commit b312be3d87e4c80872cbea869e569175c5eb0f9a upstream.

The kernel commit cited below restructured ib device management
so that the device kobject is initialized in ib_alloc_device.

As part of the restructuring, the kobject is now initialized in
procedure ib_alloc_device, and is later added to the device hierarchy
in the ib_register_device call stack, in procedure
ib_device_register_sysfs (which calls device_add).

However, in the ib_device_register_sysfs error flow, if an error
occurs following the call to device_add, the cleanup procedure
device_unregister is called. This call results in the device object
being deleted -- which results in various use-after-free crashes.

The correct cleanup call is device_del -- which undoes device_add
without deleting the device object.

The device object will then (correctly) be deleted in the
ib_register_device caller's error cleanup flow, when the caller invokes
ib_dealloc_device.

Fixes: 55aeed06544f6 ("IB/core: Make ib_alloc_device init the kobject")
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/infiniband/core/sysfs.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -863,7 +863,7 @@ err_put:
 	free_port_list_attributes(device);
 
 err_unregister:
-	device_unregister(class_dev);
+	device_del(class_dev);
 
 err:
 	return ret;


Patches currently in stable-queue which might be from jackm@dev.mellanox.co.il are

queue-4.4/ib-core-fix-sysfs-registration-error-flow.patch
queue-4.4/ib-mlx4-fix-ib-device-initialization-error-flow.patch
queue-4.4/ib-mlx4-reduce-sriov-multicast-cleanup-warning-message-to-debug-level.patch

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-05-17 15:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-17 15:56 Patch "IB/core: Fix sysfs registration error flow" has been added to the 4.4-stable tree gregkh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.