From patchwork Mon Aug 31 20:40:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 52898 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by patches.linaro.org (Postfix) with ESMTPS id 6034922EB3 for ; Mon, 31 Aug 2015 20:40:42 +0000 (UTC) Received: by lbbpd10 with SMTP id pd10sf42087770lbb.3 for ; Mon, 31 Aug 2015 13:40:41 -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 :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=kOi6txW3nCwS7JFN6CoT+V83bAqFg6p2YmjDrNYRhtg=; b=eKICK6knpOuspGu9lvL5BRAwY4sNyCyOEu8PZ7TBYf42UzWnsswEGozdCZe9BiMc7F h96LFlbr2U2VmB14g/4UHMyHgQCtR+0/c0b3ludmOEPntGejn5rBogUOIJf02b+RMPCk wlcXSab72tETzob4JlLEeGINvK2+eRprNArr+t5qmmHZ4tgsPc4DXGkEY4TYnp61CZtC naQOgP5fejd/dLMcIPxQ10ACOEXy3ol6RKAPE+YOgyjmHBZM1ZXnFs0sZqvtMx69/eff Dzfzf6aOCggZVHcphZ6zNZaMoRH8rQuN/2m9jMtIEEbvVV7a29XudTdGszyyaaVRDanQ jUgg== X-Gm-Message-State: ALoCoQk73YEJ317pfBWVJT9ObufS/lmuIqzYp5ZHr/7FIpORtsXa1x59nvTHAV2C/v+9vj3bXURy X-Received: by 10.180.12.205 with SMTP id a13mr120885wic.4.1441053641307; Mon, 31 Aug 2015 13:40:41 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.3.200 with SMTP id e8ls538947lae.4.gmail; Mon, 31 Aug 2015 13:40:41 -0700 (PDT) X-Received: by 10.112.92.101 with SMTP id cl5mr10767294lbb.67.1441053641151; Mon, 31 Aug 2015 13:40:41 -0700 (PDT) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id h8si14449784laa.5.2015.08.31.13.40.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Aug 2015 13:40:41 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by laba3 with SMTP id a3so79048063lab.1 for ; Mon, 31 Aug 2015 13:40:41 -0700 (PDT) X-Received: by 10.152.43.198 with SMTP id y6mr3258517lal.41.1441053641023; Mon, 31 Aug 2015 13:40:41 -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 yn10csp78252lbb; Mon, 31 Aug 2015 13:40:39 -0700 (PDT) X-Received: by 10.68.98.194 with SMTP id ek2mr39963026pbb.152.1441053639724; Mon, 31 Aug 2015 13:40:39 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id em2si10939204pbb.199.2015.08.31.13.40.38; Mon, 31 Aug 2015 13:40:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-omap-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 S1752724AbbHaUki (ORCPT + 5 others); Mon, 31 Aug 2015 16:40:38 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:54137 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752064AbbHaUkh (ORCPT ); Mon, 31 Aug 2015 16:40:37 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id t7VKeWTF027552; Mon, 31 Aug 2015 15:40:32 -0500 Received: from DLEE70.ent.ti.com (dlemailx.itg.ti.com [157.170.170.113]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id t7VKeW01014063; Mon, 31 Aug 2015 15:40:32 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.224.2; Mon, 31 Aug 2015 15:40:31 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id t7VKeVKn012814; Mon, 31 Aug 2015 15:40:31 -0500 From: Felipe Balbi To: James Morris CC: , , , Linux OMAP Mailing List , Felipe Balbi Subject: [PATCH] security: device_cgroup: fix RCU lockdep splat Date: Mon, 31 Aug 2015 15:40:29 -0500 Message-ID: <1441053629-31844-1-git-send-email-balbi@ti.com> X-Mailer: git-send-email 2.5.0 MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-omap@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.215.46 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 devcgroup_update_access(). Signed-off-by: Felipe Balbi --- security/device_cgroup.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/security/device_cgroup.c b/security/device_cgroup.c index 73455089feef..0a6316b50357 100644 --- a/security/device_cgroup.c +++ b/security/device_cgroup.c @@ -766,8 +766,10 @@ static ssize_t devcgroup_access_write(struct kernfs_open_file *of, int retval; mutex_lock(&devcgroup_mutex); + rcu_read_lock(); retval = devcgroup_update_access(css_to_devcgroup(of_css(of)), of_cft(of)->private, strstrip(buf)); + rcu_read_unlock(); mutex_unlock(&devcgroup_mutex); return retval ?: nbytes; }