From patchwork Wed Sep 2 13:12:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 52970 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by patches.linaro.org (Postfix) with ESMTPS id BAFFE22E23 for ; Wed, 2 Sep 2015 13:12:41 +0000 (UTC) Received: by laeb10 with SMTP id b10sf4152625lae.1 for ; Wed, 02 Sep 2015 06:12:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-type:sender:precedence :list-id:x-original-sender:x-original-authentication-results :mailing-list:list-post:list-help:list-archive:list-unsubscribe; bh=0w/FKgVzLY+m5n05/kapy6fQ1reaWW47LidB3Q9gcTI=; b=KzuOGeD/8kswQQLVNF/FmU4O15wr0T6M6BezGKAe34lVtO4nTgodQoPVgytskdl9+j nZYjViF/HsckHiHcAWxk2HAkPYdU3xQoRPmjM1HCCCPxh+9W7BZoH94af52eYgSDDShL wlvujKRJWa48rkE8oqkvOe6rIgP0a3L7oTIESuIunYdGT7QHeedeW+NFumamcikiCR9g FLrkWPuGsKt2uqd5QM58gQO3XuE4c26whxXyJJ/A5Ia0KlXb+e86Ifa6Mpt0E2Xnis2p qzHiVJuyzON7WmIIAeA+NWWStSWtb9rSkjeAQT4ZVIVNzFFNPnqwe02H1RyX7oN/B+MN b0gA== X-Gm-Message-State: ALoCoQlkNxZzdnF52yyGx3L1guBMJbQP02ZykJAhouWlj2nE/LqRfq61MBB9Xl1D+b0RNhmAPH// X-Received: by 10.152.26.101 with SMTP id k5mr9107802lag.9.1441199560756; Wed, 02 Sep 2015 06:12:40 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.198.234 with SMTP id jf10ls78565lac.60.gmail; Wed, 02 Sep 2015 06:12:40 -0700 (PDT) X-Received: by 10.112.53.229 with SMTP id e5mr15450414lbp.61.1441199560587; Wed, 02 Sep 2015 06:12:40 -0700 (PDT) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com. [209.85.217.180]) by mx.google.com with ESMTPS id ap9si19604995lbc.133.2015.09.02.06.12.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Sep 2015 06:12:40 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) client-ip=209.85.217.180; Received: by lbcjc2 with SMTP id jc2so5735209lbc.0 for ; Wed, 02 Sep 2015 06:12:40 -0700 (PDT) X-Received: by 10.152.22.99 with SMTP id c3mr16627588laf.32.1441199560267; Wed, 02 Sep 2015 06:12:40 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.164.42 with SMTP id yn10csp566103lbb; Wed, 2 Sep 2015 06:12:39 -0700 (PDT) X-Received: by 10.68.242.42 with SMTP id wn10mr28916502pbc.77.1441199558902; Wed, 02 Sep 2015 06:12:38 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ut10si30903514pac.203.2015.09.02.06.12.37; Wed, 02 Sep 2015 06:12:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754778AbbIBNMg (ORCPT + 28 others); Wed, 2 Sep 2015 09:12:36 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:49135 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753894AbbIBNMe (ORCPT ); Wed, 2 Sep 2015 09:12:34 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id t82DCTfg024866; Wed, 2 Sep 2015 08:12:29 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id t82DCTga020280; Wed, 2 Sep 2015 08:12:29 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.224.2; Wed, 2 Sep 2015 08:12:29 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id t82DCSHT016269; Wed, 2 Sep 2015 08:12:29 -0500 From: Felipe Balbi To: James Morris CC: , , , Linux OMAP Mailing List , Felipe Balbi Subject: [PATCH v2] security: device_cgroup: fix RCU lockdep splat Date: Wed, 2 Sep 2015 08:12:28 -0500 Message-ID: <1441199548-29633-1-git-send-email-balbi@ti.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <20150902125608.GA8299@saruman.tx.rr.com> References: <20150902125608.GA8299@saruman.tx.rr.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: balbi@ti.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , while booting AM437x device, the following splat triggered: [ 12.005238] =============================== [ 12.009749] [ INFO: suspicious RCU usage. ] [ 12.014116] 4.2.0-next-20150831 #1154 Not tainted [ 12.019050] ------------------------------- [ 12.023408] security/device_cgroup.c:405 device_cgroup:verify_new_ex called without proper synchronization! [ 12.033576] other info that might help us debug this: [ 12.041942] rcu_scheduler_active = 1, debug_locks = 0 [ 12.048796] 4 locks held by systemd/1: [ 12.052700] #0: (sb_writers#7){.+.+.+}, at: [] __sb_start_write+0x8c/0xb0 [ 12.060954] #1: (&of->mutex){+.+.+.}, at: [] kernfs_fop_write+0x50/0x1b8 [ 12.069085] #2: (s_active#30){++++.+}, at: [] kernfs_fop_write+0x58/0x1b8 [ 12.077310] #3: (devcgroup_mutex){+.+...}, at: [] devcgroup_access_write+0x20/0x658 [ 12.086575] stack backtrace: [ 12.091124] CPU: 0 PID: 1 Comm: systemd Not tainted 4.2.0-next-20150831 #1154 [ 12.098609] Hardware name: Generic AM43 (Flattened Device Tree) [ 12.104807] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [ 12.112924] [] (show_stack) from [] (dump_stack+0x84/0x9c) [ 12.120491] [] (dump_stack) from [] (verify_new_ex+0xc4/0xdc) [ 12.128326] [] (verify_new_ex) from [] (devcgroup_access_write+0x374/0x658) [ 12.137426] [] (devcgroup_access_write) from [] (cgroup_file_write+0x28/0x1bc) [ 12.146796] [] (cgroup_file_write) from [] (kernfs_fop_write+0xc0/0x1b8) [ 12.155620] [] (kernfs_fop_write) from [] (__vfs_write+0x1c/0xd8) [ 12.163783] [] (__vfs_write) from [] (vfs_write+0x90/0x16c) [ 12.171426] [] (vfs_write) from [] (SyS_write+0x44/0x9c) [ 12.178806] [] (SyS_write) from [] (ret_fast_syscall+0x0/0x1c) Fix it by making sure rcu_read_lock() is held around calls to parent_has_perm(). Signed-off-by: Felipe Balbi Tested-by: Josh Boyer Acked-by: Serge Hallyn Tested-by: Josh Boyer --- Changes since v1: - move rcu_read_lock/unlock to wrap parent_has_perm() security/device_cgroup.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/security/device_cgroup.c b/security/device_cgroup.c index 73455089feef..dd77ed206fa4 100644 --- a/security/device_cgroup.c +++ b/security/device_cgroup.c @@ -608,6 +608,7 @@ static int devcgroup_update_access(struct dev_cgroup *devcgroup, int count, rc = 0; struct dev_exception_item ex; struct dev_cgroup *parent = css_to_devcgroup(devcgroup->css.parent); + int ret; if (!capable(CAP_SYS_ADMIN)) return -EPERM; @@ -734,7 +735,11 @@ static int devcgroup_update_access(struct dev_cgroup *devcgroup, break; } - if (!parent_has_perm(devcgroup, &ex)) + rcu_read_lock(); + ret = parent_has_perm(devcgroup, &ex); + rcu_read_unlock(); + + if (!ret) return -EPERM; rc = dev_exception_add(devcgroup, &ex); break;