Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6174020imu; Mon, 21 Jan 2019 04:32:00 -0800 (PST) X-Google-Smtp-Source: ALg8bN6m57gvBsYhLvL+GgX6wwMKq+z1ytMpKsNMFvdjh3lKmPWE9JRc5zkNbKFEK8IbF7lXSlyP X-Received: by 2002:a17:902:4523:: with SMTP id m32mr29896848pld.53.1548073920257; Mon, 21 Jan 2019 04:32:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548073920; cv=none; d=google.com; s=arc-20160816; b=crB+pw+liw62eBJJ1EGPFK2DhH8+rgJMpNp93DWC1wz7dDr7DBcDYzq8q0qCRl4xSc a6+TrP7JlG187fSVYy6kAcp0czsKT9fRUQc8FMTG+O5nU761J01n8V678rm4XkAabrq2 wQNr85Z2VkbtBR3MdX4fI28tBxM+TTTaCWrknZg9Y6kwkUZeeNr//5Vh7MJnaEGsHNlm KWE61ijX9SepjvpfK4Fzm6cw7mYD59E4eDWpu791WDwgBni51FoPm46Z8H9yNQy2r4nV qHTzgDf/2PZHTXuq7oJA/R4TxybbymNzujCChu5aV8SyvFDgMR7QKP/z+u6ejsNwoJeL nIRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=7m+KvIsLSKcpmR1P89YwAZS9iEqag+YvOiB6GUSKYq8=; b=pS3odmdhco3POJQBs8jcJghfyQa3Dx0HUjFt9jQbl4iAkD/micZK3esao7kb3cFV3Y OGzL+XUi0oT/qWN2nHFWFv0cuGPZh46OdgP4spQ1TWoNsUHPD7TiBluwsDjWRvGpbd/Z L71A9Nt+bR6vR7NaA5GHZK1/yORRKYqLWzrlepIhoIr/fkWvdyxsfpPRElqDKNCsSjEp pDQ2zfouHVsys0yrD5VyoJGwAMIpJTI1oZPqMRrC88t8Jz3x7cEIfN6r1q/iLXKFSQnx wggMw1nHGEreLnHBgdVxdFXANOZKJfm9ZLghhI9MXWTiKQ5MPRy8qYGKpX+g3p6bVJ0w Pq0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Nj5uH1Sh; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u13si11883515plq.268.2019.01.21.04.31.38; Mon, 21 Jan 2019 04:32:00 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Nj5uH1Sh; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728648AbfAUMaF (ORCPT + 99 others); Mon, 21 Jan 2019 07:30:05 -0500 Received: from mail-yw1-f66.google.com ([209.85.161.66]:38827 "EHLO mail-yw1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728299AbfAUMaE (ORCPT ); Mon, 21 Jan 2019 07:30:04 -0500 Received: by mail-yw1-f66.google.com with SMTP id d190so7956829ywb.5; Mon, 21 Jan 2019 04:30:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7m+KvIsLSKcpmR1P89YwAZS9iEqag+YvOiB6GUSKYq8=; b=Nj5uH1Shx4LzFYzel1sUqEe9P7AkXujq9nvcr24mHaGriEbS5iE5G6qDZ2nRM2or2O DgkcnGtPKta++gx4tlJiptEduKwFT5+kht/Qkq6TUkveGMoSGH2w0Dvdw6ybeRJv9yW2 Y3GqeAsmrHBx3zl3JFJA6m89dMcT9+JDbmqA9rMDr1XFvqYoEhosIQVgH2iKdePP1WRs 12+gBZCL51EL4mkM+GDACOnj15Vx/GYH+CmEDMMFACsUwQQ7Ldytu4HfxnvGcYfXKoSP BJClM4ajlKXlfhHCsj2IVoG+wULvzMXIOdGicgcV+seGfYlJc7NFzC+zDp0UySa48l1U XPJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7m+KvIsLSKcpmR1P89YwAZS9iEqag+YvOiB6GUSKYq8=; b=fW3G4QoUm9FpllbdAGUFpzLSmgbF+Hz9pJ6loXioKBmdsRA6vqx9NLsCBdRsBhGs2L U/FuM2EKQUSOIASygwwNmWHLwMTcuFv/uFYlN4dvenaNlGIbfHhx7mZXj75+znLcRcRy EA3bQ7tqEXYPwhJKLVvqsHjZ9xtTfJ6UJkDEmaJXgk499ZwygixRDHBepRduos2bkFf4 eq0Jw26/o3RdVbmtdof+QO881gbQhptv4IfE50mWk4ANTieESeq6C40dFgiZt0z7+Uyo pC5Cuy3u4GrWvGFtDyjtkLmMglmmBsBv+Qum2qf0ePivijKlHBDa/sJPQQLZjs9hXg1Z Lrpw== X-Gm-Message-State: AJcUukdhnZNm3nRskAT7icS2kcPuRK0q7jlLcblh5y8eDxkRJoTVZful xz4Cr/bmxmOcuqZld05LP+hjEVAz4EqmJPO4wsk= X-Received: by 2002:a81:54:: with SMTP id 81mr28519046ywa.404.1548073802792; Mon, 21 Jan 2019 04:30:02 -0800 (PST) MIME-Version: 1.0 References: <1545158873.4206.86.camel@linux.ibm.com> <20190117213421.ggasuc263dpqh46c@merlin> <1548072003.3782.24.camel@linux.ibm.com> In-Reply-To: <1548072003.3782.24.camel@linux.ibm.com> From: Amir Goldstein Date: Mon, 21 Jan 2019 14:29:51 +0200 Message-ID: Subject: Re: [PATCH v2] ima: define ima_post_create_tmpfile() hook and add missing call To: Mimi Zohar Cc: Goldwyn Rodrigues , Ignaz Forster , linux-integrity , linux-kernel , Fabian Vogt , Al Viro Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? Thanks, Amir.