Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7611951imu; Tue, 22 Jan 2019 08:40:49 -0800 (PST) X-Google-Smtp-Source: ALg8bN5l2Xvcx7hYcEFZkBWXm4IE0Z/YPa0IN7gl4fMWsLO3cnEqdtEhSegs5dcJc6U9/uBu9Opj X-Received: by 2002:a62:59c9:: with SMTP id k70mr34051870pfj.243.1548175249043; Tue, 22 Jan 2019 08:40:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548175249; cv=none; d=google.com; s=arc-20160816; b=XIaaVyZs1EQpgkpk4YwptNRmCdWDmocVr6Q++JwV5Hlnlhpsi72Lpa/dcU8AJ2i7Km 7oyY4Ux5QLNcXx5PyTmmYR0+m5opCUYTzKWkb3lhIM2QoBDhz5ZRmyyxDOznXYvddgD0 or7lLnvTLQyUK0BybTf7FNSmqGW2zayHnHtaJv3h8wY57hlSTbZu6cbPtmf6cbgcF/AC xZaAfziQJg4hVigOA0QRvVKtx52x6+FXJ0UGMrDtsMhmW4tXueGeiad4ZfvXQXkeJatS jT7gfQOau8Z9pW6to2BG3k9U3RSXWnsLwee1i3XJmr9rnw4LAgC4ejrwCcS/Vfa7lTwC 9+pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=auYwc393zJj48jZM/qic2EBb1idU96nTaOUnhtO+0r0=; b=EZ5eke7KeXdeWV5trvwbATcz9xlkEZ5p7HEgvkEo4Bgc5BiK3Y8sM0n6Ci4XRnQqOW N/gLvSIkZlu6AMiOFyztEckzzNuz2eh1bwiNfGZ6cjhoE9ahy2XOxn23Hds5Gbl7qxdx Txmcmw27v1YsmHiueIRm210BWyY61P2JG89UZfYE99IQFs7dL/EaTpV3sLVjIFrIBCF3 Kx2QRhwZleT/vc0auKlmiiso7dnYTKM0nR+vUVIFrZHckSgd9BBbRbw6Uy7KkaY8Yhuw 1GLiyyKPDGBlMPRXH8Ry72ORyKw/KsIF/KC/tXjwJN/IamrjJK1N3FQ5NnarsFzFZbWa HSbA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s13si17649437pgc.509.2019.01.22.08.40.33; Tue, 22 Jan 2019 08:40:49 -0800 (PST) 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; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729442AbfAVQi5 (ORCPT + 99 others); Tue, 22 Jan 2019 11:38:57 -0500 Received: from mx2.suse.de ([195.135.220.15]:45778 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729092AbfAVQi4 (ORCPT ); Tue, 22 Jan 2019 11:38:56 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 5685FB081; Tue, 22 Jan 2019 16:38:55 +0000 (UTC) Date: Tue, 22 Jan 2019 10:38:52 -0600 From: Goldwyn Rodrigues To: Mimi Zohar Cc: Amir Goldstein , Ignaz Forster , linux-integrity , linux-kernel , Fabian Vogt , Al Viro Subject: Re: [PATCH v2] ima: define ima_post_create_tmpfile() hook and add missing call Message-ID: <20190122163852.nbo7z5hrizfsb344@merlin> References: <1545158873.4206.86.camel@linux.ibm.com> <20190117213421.ggasuc263dpqh46c@merlin> <1548072003.3782.24.camel@linux.ibm.com> <1548171789.4038.6.camel@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1548171789.4038.6.camel@linux.ibm.com> User-Agent: NeoMutt/20180323 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10:43 22/01, Mimi Zohar wrote: > On Mon, 2019-01-21 at 14:29 +0200, Amir Goldstein wrote: > > On Mon, Jan 21, 2019 at 2:00 PM Mimi Zohar wrote: > > > > > > On Thu, 2019-01-17 at 15:34 -0600, Goldwyn Rodrigues wrote: > > > > On 13:47 18/12, Mimi Zohar wrote: > > > > > If tmpfiles can be made persistent, then newly created tmpfiles need to > > > > > be treated like any other new files in policy. > > > > > > > > > > This patch indicates which newly created tmpfiles are in policy, causing > > > > > the file hash to be calculated on __fput(). > > > > > > > > Discussed in overlayfs, this would be better if we use this on inode > > > > and called from vfs_tmpfile() instead of do_tmpfile(). This will cover > > > > the overlayfs case which uses tmpfiles while performing copy_up(). > > > > The patch is attached. > > > > > > > > Here is the updated patch which works for my cases. > > > > However, it is the the failure case after setting the IMA flags > > > > I am concerned about, though I don't think that should be as harmful. > > > > > > Right. The new IMA hook allocates memory for storing the flags, which > > > needs to be cleaned up on failure. For this reason, the IMA call is > > > deferred until after the transition from locally freeing memory on > > > failure to relying on __fput(). In "do_last", the call to IMA is > > > after "opened"; and in the original version of this patch the call to > > > IMA is after finish_open(). > > > > > > > Not sure I understand the concern. > > The integrity context is associated with the inode and will be freed > > on destroy_inode() no matter which error path is taken. > > Am I missing something? > > No, as long as destroy_inode() is called, it should be fine. > Excellent. I will resend the patch as v3. Thanks! -- Goldwyn