Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3199433pxk; Mon, 21 Sep 2020 07:42:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3M0cfSW3VJ9NjXjC3Q3pHcWX1aUUo5l7NGGX14aiCfvX7QvUpGBGD/Ugj3P1Ye60g4kv7 X-Received: by 2002:a17:906:fcc7:: with SMTP id qx7mr52512296ejb.254.1600699333942; Mon, 21 Sep 2020 07:42:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600699333; cv=none; d=google.com; s=arc-20160816; b=sfs5E2Am/Vjavz0xJxsko3j3fEpmTWLiavYB8xoVvJ/yVwW96DWnGq08/mUi6QjF1j gPiGUfxrKn8YqqD/tU5Y0YCCRMeiyE6u/cTo8k7Q/jngyBl7dMHgDAnWrfuE1IhpsWhc LOhPXRqBPq4Lg0pNdXQhyNxo0pPSE/J5cDtkyzYNnBmwU2HiRKITE2MUY3O7/MzChMfK E77Dn15p6zX/zXQxsfZcy3z9/kgY9NdLrq9is/c6vYUdIhmNZu6fZGvIEYsHqM4gcINn DaMiDDFXoiCSHh+aOP2L2EzS8cAvdbGcMvrkXBk+jZmPCaKblPtEFfvWOq4LB5c3yNfJ jTyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=jWs1ILDyayzgOtb/zCH3iu1JNQaoJ09EQcnhNGP+Iao=; b=jyQQRDghGhoBapvMaofh/KqnBHJBmlCr8iJEb7Dx3IZUBT6PajWd8SBK0+9oA2RWzV sv6A19CaeKfIT7UWC3qU6G+X58ww9UMC0+HrCgKhq1a8Au3jzc/3fnXOPb7D3nKXqhOC viU131gPhEnX+ap9nsXENERcXO80iymL3eV7tx2MUgOqHRYS9UqBd68ysRWtpUXJ4Wzc 2NjDloH0e3vRa4DDPnzB1f/GNwEFh1n1iR9jwx21mxcEFG15yu+YPWw6xpbcWZuPFScZ 3I8rBOwykwFR2sbt0/hT94jKxWty0GEEBVjkdpk/olTHR8e939oOe0EYhIZww6iqL90M 19Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dYK9fk5e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cy18si8596004edb.148.2020.09.21.07.41.50; Mon, 21 Sep 2020 07:42:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dYK9fk5e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727786AbgIUOka (ORCPT + 99 others); Mon, 21 Sep 2020 10:40:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:49012 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727499AbgIUOk3 (ORCPT ); Mon, 21 Sep 2020 10:40:29 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 871C62220C; Mon, 21 Sep 2020 14:40:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600699229; bh=q4jjtEd3ZJjIdaUmU/BM5CW0hA/WfkWaAf8pdOR6yLo=; h=From:To:Cc:Subject:Date:From; b=dYK9fk5e73f4ValuLgosAn4oxbXpa3t6R67V2j/zgCOiO4bw0tH3ssxjUcF5/LBEx QlN6Z31GdrY+oSMU2wFDJo3ZIaRQz7hHpw90Kyoh2g/GafmcixUaxElVLHBFl5fNfg v9viJcmDLnP1lUVU0fRXcXKba6+Yb+HS+DC33ygo= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Amol Grover , James Morris , Sasha Levin , linux-security-module@vger.kernel.org Subject: [PATCH AUTOSEL 5.8 01/20] device_cgroup: Fix RCU list debugging warning Date: Mon, 21 Sep 2020 10:40:08 -0400 Message-Id: <20200921144027.2135390-1-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Amol Grover [ Upstream commit bc62d68e2a0a69fcdcf28aca8edb01abf306b698 ] exceptions may be traversed using list_for_each_entry_rcu() outside of an RCU read side critical section BUT under the protection of decgroup_mutex. Hence add the corresponding lockdep expression to fix the following false-positive warning: [ 2.304417] ============================= [ 2.304418] WARNING: suspicious RCU usage [ 2.304420] 5.5.4-stable #17 Tainted: G E [ 2.304422] ----------------------------- [ 2.304424] security/device_cgroup.c:355 RCU-list traversed in non-reader section!! Signed-off-by: Amol Grover Signed-off-by: James Morris Signed-off-by: Sasha Levin --- security/device_cgroup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/security/device_cgroup.c b/security/device_cgroup.c index 43ab0ad45c1b6..04375df52fc9a 100644 --- a/security/device_cgroup.c +++ b/security/device_cgroup.c @@ -354,7 +354,8 @@ static bool match_exception_partial(struct list_head *exceptions, short type, { struct dev_exception_item *ex; - list_for_each_entry_rcu(ex, exceptions, list) { + list_for_each_entry_rcu(ex, exceptions, list, + lockdep_is_held(&devcgroup_mutex)) { if ((type & DEVCG_DEV_BLOCK) && !(ex->type & DEVCG_DEV_BLOCK)) continue; if ((type & DEVCG_DEV_CHAR) && !(ex->type & DEVCG_DEV_CHAR)) -- 2.25.1