Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751479AbdIOPVj (ORCPT ); Fri, 15 Sep 2017 11:21:39 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:52378 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751152AbdIOPVi (ORCPT ); Fri, 15 Sep 2017 11:21:38 -0400 Subject: Re: [PATCH 3/3] ima: use fs method to read integrity data From: Mimi Zohar To: Christoph Hellwig , Linus Torvalds Cc: Dave Kleikamp , Bob Peterson , David Woodhouse , Chao Yu , Hugh Dickins , "Darrick J. Wong" , Matthew Garrett , Joel Becker , Jan Kara , Chris Mason , Ryusuke Konishi , Steven Whitehouse , Andreas Dilger , "Theodore Ts'o" , Mark Fasheh , linux-security-module@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, James Morris , Richard Weinberger , Jaegeuk Kim , Linux Kernel Mailing List , Christoph Hellwig Date: Fri, 15 Sep 2017 11:21:21 -0400 In-Reply-To: <20170915144903.GA3854@infradead.org> References: <1505451494-30228-1-git-send-email-zohar@linux.vnet.ibm.com> <1505451494-30228-4-git-send-email-zohar@linux.vnet.ibm.com> <20170915144903.GA3854@infradead.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.20.5 (3.20.5-1.fc24) Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-MML: disable x-cbid: 17091515-0012-0000-0000-0000025E1076 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17091515-0013-0000-0000-0000077C1FBF Message-Id: <1505488881.4200.96.camel@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-09-15_06:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1709150222 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 864 Lines: 21 On Fri, 2017-09-15 at 07:49 -0700, Christoph Hellwig wrote: > On Thu, Sep 14, 2017 at 10:50:27PM -0700, Linus Torvalds wrote: > > This is still wrong. > > > > (a) there is no explanation for why we need that exclusive lock in the > > first place > > > > Why should a read need exclusive access? You'd think shared is sufficient. > > But regardless, it needs *explanation*. > > Shared is sufficient, and nothing in the patch (except for the > description) actually requires an exclusive lock. It just happens that > ima holds it exclusive for other internal reasons. Although reading the file to calculate the file hash doesn't require taking the lock exclusively, in either "fix" mode or called from __fput, immediately after calculating the file hash, the file hash is written out as an xattr.  Writing the xattr requires taking the lock exclusively. Mimi