]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/5.0.10/device_cgroup-fix-rcu-imbalance-in-error-case.patch
Fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 5.0.10 / device_cgroup-fix-rcu-imbalance-in-error-case.patch
CommitLineData
8c9c9088
GKH
1From 0fcc4c8c044e117ac126ab6df4138ea9a67fa2a9 Mon Sep 17 00:00:00 2001
2From: Jann Horn <jannh@google.com>
3Date: Tue, 19 Mar 2019 02:36:59 +0100
4Subject: device_cgroup: fix RCU imbalance in error case
5
6From: Jann Horn <jannh@google.com>
7
8commit 0fcc4c8c044e117ac126ab6df4138ea9a67fa2a9 upstream.
9
10When dev_exception_add() returns an error (due to a failed memory
11allocation), make sure that we move the RCU preemption count back to where
12it was before we were called. We dropped the RCU read lock inside the loop
13body, so we can't just "break".
14
15sparse complains about this, too:
16
17$ make -s C=2 security/device_cgroup.o
18./include/linux/rcupdate.h:647:9: warning: context imbalance in
19'propagate_exception' - unexpected unlock
20
21Fixes: d591fb56618f ("device_cgroup: simplify cgroup tree walk in propagate_exception()")
22Cc: stable@vger.kernel.org
23Signed-off-by: Jann Horn <jannh@google.com>
24Acked-by: Michal Hocko <mhocko@suse.com>
25Signed-off-by: Tejun Heo <tj@kernel.org>
26Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
27
28---
29 security/device_cgroup.c | 2 +-
30 1 file changed, 1 insertion(+), 1 deletion(-)
31
32--- a/security/device_cgroup.c
33+++ b/security/device_cgroup.c
34@@ -560,7 +560,7 @@ static int propagate_exception(struct de
35 devcg->behavior == DEVCG_DEFAULT_ALLOW) {
36 rc = dev_exception_add(devcg, ex);
37 if (rc)
38- break;
39+ return rc;
40 } else {
41 /*
42 * in the other possible cases: