]>
Commit | Line | Data |
---|---|---|
8c9c9088 GKH |
1 | From 0fcc4c8c044e117ac126ab6df4138ea9a67fa2a9 Mon Sep 17 00:00:00 2001 |
2 | From: Jann Horn <jannh@google.com> | |
3 | Date: Tue, 19 Mar 2019 02:36:59 +0100 | |
4 | Subject: device_cgroup: fix RCU imbalance in error case | |
5 | ||
6 | From: Jann Horn <jannh@google.com> | |
7 | ||
8 | commit 0fcc4c8c044e117ac126ab6df4138ea9a67fa2a9 upstream. | |
9 | ||
10 | When dev_exception_add() returns an error (due to a failed memory | |
11 | allocation), make sure that we move the RCU preemption count back to where | |
12 | it was before we were called. We dropped the RCU read lock inside the loop | |
13 | body, so we can't just "break". | |
14 | ||
15 | sparse 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 | ||
21 | Fixes: d591fb56618f ("device_cgroup: simplify cgroup tree walk in propagate_exception()") | |
22 | Cc: stable@vger.kernel.org | |
23 | Signed-off-by: Jann Horn <jannh@google.com> | |
24 | Acked-by: Michal Hocko <mhocko@suse.com> | |
25 | Signed-off-by: Tejun Heo <tj@kernel.org> | |
26 | Signed-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: |