Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp4070269pxb; Tue, 17 Nov 2020 10:26:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJwXf4fkuQ2UrDwynTJAAehyieX/GHGTwq4CEWkrlEkshr9Qel8rRO+6VsPIMRX3tJPqxUkE X-Received: by 2002:a17:906:2e8e:: with SMTP id o14mr21023850eji.324.1605637572050; Tue, 17 Nov 2020 10:26:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605637572; cv=none; d=google.com; s=arc-20160816; b=oy1cQg8V9Qjytf7jpYv4r0DjT/3a5OfeblycbyqRX4XTlKKLUeLY579xfNBdxw109H /MWJzzKfh1KXJrsKqEaZiMr+AeIF+6JjOAfUqOhVaar2nisWSJ+jUZ6LO0T8moML4QUx Osr0sWWGaKd9F0GJdMVD78hSjTiQQMnec8rwSYp8crj0o9YYCA7G9+hW2LkDazPj2Tlp 4PefDd/TDTxhYsvBHFcnnDjTJWR5KNv2EhPYBXthkKlC6L+wJpIrQpMvwP/KOkyBm160 w+eVfLYi4TkIXatD7MX6V1vi0DJX9fn4EWNInnL6GH0CMUwAvUp4AJVe/rX9Z/WVbQQX evSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=jvUf4J0DFW1w2WtJ3V6+jniQAPhY7yyvFEspsD/tJmg=; b=MghrbGujbld7HGf7rzZnYjTaxhr/pHRBnsRPAGcI/ksvXbQZ8QLfiqqiXCsjb01zzV UNEt97au+n2hgsR6ZUH//CuLPZ6uuRQDkRfRbDxcoRLzGgzG36ZisxEIkszvy7HZMWJ4 ClGVJBKEjXLqRS5d04zy95+f2cHIu5vghxxbFRt3c7KpyPtkYitZY9Lv2D5jH16zAH9G QB23x0xPaL/7dTb5FkwW9Kv9WFKNeZipaMAihA+fktmWsPuUKVZBrEo4fW/zB37dLjVH 07XaUvgw4XXrp6UsS8ntlUm+08yndl/eiWxIY3P6sr/bYnf0ciHylzcXCDltQPN4ZWdC /vjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=PEkPOajt; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n19si15294104edv.187.2020.11.17.10.25.48; Tue, 17 Nov 2020 10:26:12 -0800 (PST) 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=@linux-foundation.org header.s=google header.b=PEkPOajt; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730925AbgKQSYU (ORCPT + 99 others); Tue, 17 Nov 2020 13:24:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730650AbgKQSYT (ORCPT ); Tue, 17 Nov 2020 13:24:19 -0500 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C856C0613CF for ; Tue, 17 Nov 2020 10:24:19 -0800 (PST) Received: by mail-lj1-x242.google.com with SMTP id p12so25390183ljc.9 for ; Tue, 17 Nov 2020 10:24:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=jvUf4J0DFW1w2WtJ3V6+jniQAPhY7yyvFEspsD/tJmg=; b=PEkPOajtdsc4vIPnzM9bVRVqYkht1WKu9HytymEE8l1JV5LOIEPq4BZ4U++e/c0KUw gwT0H1upKqxmypmrqpI9U3ggwpq1tCugR4BokqmJbZUSWy5UvZT3kY0Gec7Lk89ev35b zSUKO3Tk9zzocvLF3Nc/ui5aJ3U1f2I/TBi5s= 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=jvUf4J0DFW1w2WtJ3V6+jniQAPhY7yyvFEspsD/tJmg=; b=Re/fMtaZNI8fgk4+RQHXCmsPnuG4y5r0Tetiy97tKPB3rQJF7b3SkAvWfLve4jbtH0 6nPpnWbcmR26rpqRsEXcZV+4OyReOgBAFOHfL4ZzzNIObhdplwdFDShBWqJ0YROAxLT2 bHpNVJeGwDxSWZxtjKsOWpxbhWOfJPC+l98mVBg9MPDHs56PoK3iYs8xQY17mquqi+ip aHOzOGw+z5DsVRnLjFIscqMtZq7tgFuHMIG7Tjs5vbfK1V8YWl5Gb3Wv8kd7t4/sjE7N d5yxeHATsFIeMOuvUIgSWK1/EIvwGjrPQLh9n4PK7zBIx1Ztv+ysHPmDuTeKoARCunQq fwEg== X-Gm-Message-State: AOAM5327ozwfvgYoghtHChi1vTWncse6V+wI20IFJSMg4GM9pXV/Q/cl TsB6H4RQ9vtDHa9D+FaiBkfTSke92XF/sw== X-Received: by 2002:a2e:9a88:: with SMTP id p8mr2410833lji.266.1605637456898; Tue, 17 Nov 2020 10:24:16 -0800 (PST) Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com. [209.85.167.43]) by smtp.gmail.com with ESMTPSA id h10sm1171028lfc.18.2020.11.17.10.24.15 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 17 Nov 2020 10:24:15 -0800 (PST) Received: by mail-lf1-f43.google.com with SMTP id 74so31449695lfo.5 for ; Tue, 17 Nov 2020 10:24:15 -0800 (PST) X-Received: by 2002:a19:c301:: with SMTP id t1mr2049940lff.105.1605637454918; Tue, 17 Nov 2020 10:24:14 -0800 (PST) MIME-Version: 1.0 References: <20201113080132.16591-1-roberto.sassu@huawei.com> <20201114111057.GA16415@infradead.org> <0fd0fb3360194d909ba48f13220f9302@huawei.com> <20201116162202.GA15010@infradead.org> <20201116174127.GA4578@infradead.org> <3f8cc7c9462353ac2eef58e39beee079bdd9c7b4.camel@linux.ibm.com> In-Reply-To: <3f8cc7c9462353ac2eef58e39beee079bdd9c7b4.camel@linux.ibm.com> From: Linus Torvalds Date: Tue, 17 Nov 2020 10:23:58 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RESEND][PATCH] ima: Set and clear FMODE_CAN_READ in ima_calc_file_hash() To: Mimi Zohar Cc: Christoph Hellwig , Roberto Sassu , "linux-integrity@vger.kernel.org" , "linux-security-module@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Silviu Vlasceanu , "stable@vger.kernel.org" , "viro@zeniv.linux.org.uk" , "linux-fsdevel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 16, 2020 at 10:35 AM Mimi Zohar wrote: > > We need to differentiate between signed files, which by definition are > immutable, and those that are mutable. Appending to a mutable file, > for example, would result in the file hash not being updated. > Subsequent reads would fail. Why would that require any reading of the file at all AT WRITE TIME? Don't do it. Really. When opening the file write-only, you just invalidate the hash. It doesn't matter anyway - you're only writing. Later on, when reading, only at that point does the hash matter, and then you can do the verification. Although honestly, I don't even see the point. You know the hash won't match, if you wrote to the file. Linus