]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.9.30/powerpc-pseries-fix-of_node_put-underflow-during-dlpar-remove.patch
Linux 4.14.95
[thirdparty/kernel/stable-queue.git] / releases / 4.9.30 / powerpc-pseries-fix-of_node_put-underflow-during-dlpar-remove.patch
CommitLineData
21e6eaa8
GKH
1From 68baf692c435339e6295cb470ea5545cbc28160e Mon Sep 17 00:00:00 2001
2From: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
3Date: Mon, 17 Apr 2017 20:21:40 -0400
4Subject: powerpc/pseries: Fix of_node_put() underflow during DLPAR remove
5
6From: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
7
8commit 68baf692c435339e6295cb470ea5545cbc28160e upstream.
9
10Historically struct device_node references were tracked using a kref embedded as
11a struct field. Commit 75b57ecf9d1d ("of: Make device nodes kobjects so they
12show up in sysfs") (Mar 2014) refactored device_nodes to be kobjects such that
13the device tree could by more simply exposed to userspace using sysfs.
14
15Commit 0829f6d1f69e ("of: device_node kobject lifecycle fixes") (Mar 2014)
16followed up these changes to better control the kobject lifecycle and in
17particular the referecne counting via of_node_get(), of_node_put(), and
18of_node_init().
19
20A result of this second commit was that it introduced an of_node_put() call when
21a dynamic node is detached, in of_node_remove(), that removes the initial kobj
22reference created by of_node_init().
23
24Traditionally as the original dynamic device node user the pseries code had
25assumed responsibilty for releasing this final reference in its platform
26specific DLPAR detach code.
27
28This patch fixes a refcount underflow introduced by commit 0829f6d1f6, and
29recently exposed by the upstreaming of the recount API.
30
31Messages like the following are no longer seen in the kernel log with this
32patch following DLPAR remove operations of cpus and pci devices.
33
34 rpadlpar_io: slot PHB 72 removed
35 refcount_t: underflow; use-after-free.
36 ------------[ cut here ]------------
37 WARNING: CPU: 5 PID: 3335 at lib/refcount.c:128 refcount_sub_and_test+0xf4/0x110
38
39Fixes: 0829f6d1f69e ("of: device_node kobject lifecycle fixes")
40Signed-off-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
41[mpe: Make change log commit references more verbose]
42Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
43Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
44
45---
46 arch/powerpc/platforms/pseries/dlpar.c | 1 -
47 1 file changed, 1 deletion(-)
48
49--- a/arch/powerpc/platforms/pseries/dlpar.c
50+++ b/arch/powerpc/platforms/pseries/dlpar.c
51@@ -288,7 +288,6 @@ int dlpar_detach_node(struct device_node
52 if (rc)
53 return rc;
54
55- of_node_put(dn); /* Must decrement the refcount */
56 return 0;
57 }
58