Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2702220pxb; Tue, 24 Aug 2021 05:43:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzd316rv4SYztEQCuVHJk/M3TJ6WUSGmy8VrQTRxVMOsOYWo9KCYWc21WPkpMGuKQc7GKqe X-Received: by 2002:aa7:c952:: with SMTP id h18mr43469818edt.18.1629809028450; Tue, 24 Aug 2021 05:43:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629809028; cv=none; d=google.com; s=arc-20160816; b=ug96vPa6Ve1YA/bKZmGRTjm+wKUueidHe5RKW7Xz6fVPuhQPlNDdDNn5T44hw3AvSD OeH82MD35Gl5NujWWHiUaqOLGWhWqAWWZ7bMlt5LgD/7zpefMmseGRQramOTuUEQcWjK ma7c8UxNyACCVVs/2hhKaXe+y5hf2JkdC8k+WwMjnKmRBadiEprzFeHWZk0SYhICLzu9 RI2Qw7t0G3jVt9icwN1k2nDEJDDR1kbForflkWFmCe2PuitQRuKuxqFOtc+2NNYJyIDM b/L7H8Ix9YNHTaiHQtCQg66mp/16fYWzR6ILKE3pU14qQjGW3mQ+KxLMchwNm4Rkq7oK 4cfw== 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 :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature; bh=1+jTVe2SbG0OIxYvjCqJfmIEo15dcWnkJJD8WSTNT2c=; b=OeWDaQw8awjm0iGqWtvxuRY2zkKladE+ig13uPHGANUoKnKhpAV9yZ/GkrQkOeFX2t 3L76SjhWkze4Y53cImDLJTxryfH841ytmIGd2Kd1H8d0PwNUuAvVObFWGtHGeF5ckU61 ZhjyJUbSZaNm1tpqJ6Bpfx1RSTQfTe73ayapAyhyck+hWFYtsbCOO/m/NPI3vQbgjT/L rBjHq7RYUa5JN1jlOYYz1SExDWne8Jm85pyQMaenApihPodDZsFVmgbgmFElvDPvmcgj 0yFOmWfeM2rAfsNDzkPlC3b/amHyL6K4Qk787mahZ9oCm6feYT3p1uf1TqO6ZCYcn+QB 9F5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Gwb4OXfP; 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=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id nc1si10778472ejc.377.2021.08.24.05.43.24; Tue, 24 Aug 2021 05:43:48 -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=@ibm.com header.s=pp1 header.b=Gwb4OXfP; 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=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237379AbhHXMjs (ORCPT + 99 others); Tue, 24 Aug 2021 08:39:48 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:20588 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S237196AbhHXMjr (ORCPT ); Tue, 24 Aug 2021 08:39:47 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 17OCY3vn118550; Tue, 24 Aug 2021 08:38:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : subject : from : to : cc : date : in-reply-to : references : content-type : mime-version : content-transfer-encoding; s=pp1; bh=1+jTVe2SbG0OIxYvjCqJfmIEo15dcWnkJJD8WSTNT2c=; b=Gwb4OXfPkoasReWabIHnDbDFpRVl+A3SWPFqbj5OM4FjYGtiytDgaI+HJ8E6neL1sDyr jI/TsUV1HHYcS4LGDqfMAqdSDTGwlJHJ2aYjVQiaNGVQo6bSgQXtvFj1pP3O0Eu8C6uY cftRVwkWoBM8BZMpXNqJ0x4ppJ0bTmnePqsjw6rcEihB7HzyFUgtb5DgqPpb081pxtRv LJ7u7HEeuD15lMTRfkdU7pzxFvpaV1IDnrKuHtAZWiX77YR8x6DOfK2YxgmcsyX/rS00 roSuMW35a8ijfE9QrsRlIEYbuvhCbfoLc5Pg8MlS2ERmeT9D3aw6VYTv/kKkCs3zyl1t uQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3amvttpu9e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 24 Aug 2021 08:38:50 -0400 Received: from m0098413.ppops.net (m0098413.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 17OCYNwK120631; Tue, 24 Aug 2021 08:38:50 -0400 Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 3amvttpu81-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 24 Aug 2021 08:38:50 -0400 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 17OCbRwj027031; Tue, 24 Aug 2021 12:38:48 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma04ams.nl.ibm.com with ESMTP id 3ajs48w628-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 24 Aug 2021 12:38:48 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 17OCZ4mV55575030 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 24 Aug 2021 12:35:04 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BFC72AE055; Tue, 24 Aug 2021 12:38:45 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0D899AE061; Tue, 24 Aug 2021 12:38:44 +0000 (GMT) Received: from li-f45666cc-3089-11b2-a85c-c57d1a57929f.ibm.com (unknown [9.160.88.64]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 24 Aug 2021 12:38:43 +0000 (GMT) Message-ID: <2c4f61ff68544b2627fc4a38ad1e4109184ec68a.camel@linux.ibm.com> Subject: Re: [PATCH] ima: fix deadlock within "ima_match_policy" function. From: Mimi Zohar To: liqiong , THOBY Simon Cc: "dmitry.kasatkin@gmail.com" , "jmorris@namei.org" , "serge@hallyn.com" , "linux-integrity@vger.kernel.org" , "linux-security-module@vger.kernel.org" , "linux-kernel@vger.kernel.org" Date: Tue, 24 Aug 2021 08:38:43 -0400 In-Reply-To: <3ba4da9d-fa7b-c486-0c48-67cee4d5de6d@nfschina.com> References: <20210819101529.28001-1-liqiong@nfschina.com> <20210824085747.23604-1-liqiong@nfschina.com> <3ba4da9d-fa7b-c486-0c48-67cee4d5de6d@nfschina.com> Content-Type: text/plain; charset="ISO-8859-15" X-Mailer: Evolution 3.28.5 (3.28.5-16.el8) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: OAF4OJxESa_6v8_XNPYC-lJS3HujDIh8 X-Proofpoint-ORIG-GUID: yIFyAedLM7p_QQFuogEEIoA2Fr4C4qQ8 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.790 definitions=2021-08-24_02:2021-08-24,2021-08-24 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxscore=0 malwarescore=0 adultscore=0 clxscore=1015 impostorscore=0 suspectscore=0 bulkscore=0 spamscore=0 phishscore=0 mlxlogscore=999 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108240084 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2021-08-24 at 20:09 +0800, liqiong wrote: > Hi Simon : > > ima: fix deadlock within RCU list of ima_rules. > Before the following paragraph, an introductory sentence is needed. Try adding a sentence to the affect that "ima_rules" initially points to the "ima_default_rules", but after loading a custom policy points to the "ima_policy_rules". Then describe the bug at a high level, something like - transitioning to the "ima_policy_rules" isn't being done safely. Followed by the details. > ima_match_policy() is looping on the policy ruleset while > ima_update_policy() updates the variable "ima_rules". This can > lead to a situation where ima_match_policy() can't exit the > 'list_for_each_entry_rcu' loop, causing RCU stalls > ("rcu_sched detected stall on CPU ..."). > > This problem can happen in practice: updating the IMA policy > in the boot process while systemd-services are being checked. > > In addition to ima_match_policy(), other function with > "list_for_each_entry_rcu" should happen too. Fix locking by > introducing a duplicate of "ima_rules" for each > "list_for_each_entry_rcu". > > > How about this commit message ? > > I have tested this patch in lab, we can reproduced this error case, > have done reboot test many times. This patch should work. The above comment doesn't belong in the commit message, but is a message to the reviewers/maintainers and goes after the patch descriptions three dashes line. thanks, Mimi