Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp4382992ybg; Mon, 8 Jun 2020 06:35:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzYGfnHEOXthhUqlFhAlY2F/Omo+sEB9UGDx+a6amVHTC5c+3lOWCwGGM7Go43gm4usDGU X-Received: by 2002:a17:906:ce2f:: with SMTP id sd15mr20489013ejb.445.1591623346825; Mon, 08 Jun 2020 06:35:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591623346; cv=none; d=google.com; s=arc-20160816; b=vahMBEVOrLh8En8/wpbis59sGjmgJ6RWWygSlkzhIF5jbn07hua6zGTJ6D32GKCyL7 tOW/weTnIT+aplwdXvd1FMuqXDKW3/l9IPVsYMzVoKtzaKymTZ5kPWBndu6UBxv2tu3m JkUjCFDQfm3gOtdirf2Tzh5ZYGLv+64XyQ+y345sHeZSb9y6Jdx+b3/ONXRP729NA0zf Ix7sX5UgZLeSSXzLX8bLPZePCaLE/OLeCjO4w133TG93mTJwsWsscKqC3Y5RHT425lFk ynPTx+d5o8cOKs4LpMHfjrZzQ2aZrcKBRf1DO7jGkn8Ld5rZpOxxzLDUDfhoc+LO/fQn 0Fig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ObZ22oOgYNGbVd4Cp8pB6DVUyibIVTQNw5PapcI68nk=; b=Ofs6foATo+pcZsyPKaPzevmSsKQ64NBgHDn4ghfz4qttlUA6TlpyHsC58k8HjgpHso 1AD43z8enk83oPsdV/Fxau+WM5mYhzW4BLMmlHvUq6siYEuG0ab2RK3d+vD8GAA/+9aw Q+jBQI0lZuyHihxqpNxNd8S3TJNpdLl2hKURVoQ/Cc32KmCUs8wfcZda+Yc9qXMVbIpV SL4grJACfxswGEctNCqEkbSG/I12IzRx7mo/AvlVriTRlJHSfB/IpPXHPHADQ1MRX5+q gdYpHuwup/ZQ92w+CNGTje78XqV9YHiZ6BuJB8n6DEObaN9cpXsfIYy6RxHVdwZ3hPtS BDTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=a5taWeGU; 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 4si8701810edw.72.2020.06.08.06.35.23; Mon, 08 Jun 2020 06:35:46 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=a5taWeGU; 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 S1729868AbgFHNcy (ORCPT + 99 others); Mon, 8 Jun 2020 09:32:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729179AbgFHNcx (ORCPT ); Mon, 8 Jun 2020 09:32:53 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF981C08C5C2; Mon, 8 Jun 2020 06:32:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=ObZ22oOgYNGbVd4Cp8pB6DVUyibIVTQNw5PapcI68nk=; b=a5taWeGUX4HtnKc/RAOz5WhgUz q6JBnbH3JTiA0cXFU9kiCQWCXW/ILe82YRWyyJCFX/BccSHPnnjG1RJ6fzG56MfIi0KikIvn0P9nf mSUvR/7yJhmJEjL6YHLbAviatSAnH4qTUW0bZBTaepq+d1h02hdnqQwrHGin2OYMxi/uH2q6I2CFE Bmf2dgwgtuy4ue+pK94M55DxD5NmhDOJiqDCKv4agDJrK2TlRU50paxHDYtrUgdGEJVwJptb7wL36 BMBtG7PyeI/lJRa1zCDx0cj4FHW1VWU83+4CkoMg/YVIb/7CHlo624nM17uJ2flQPUeEY+5R/1ZIc 7xPFI5/w==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jiHtR-0001E9-NY; Mon, 08 Jun 2020 13:32:49 +0000 Date: Mon, 8 Jun 2020 06:32:49 -0700 From: Matthew Wilcox To: Mimi Zohar Cc: Scott Branden , Luis Chamberlain , Wolfram Sang , Greg Kroah-Hartman , David Brown , Alexander Viro , Shuah Khan , bjorn.andersson@linaro.org, Shuah Khan , Arnd Bergmann , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-fsdevel@vger.kernel.org, BCM Kernel Feedback , Olof Johansson , Andrew Morton , Dan Carpenter , Colin Ian King , Kees Cook , Takashi Iwai , linux-kselftest@vger.kernel.org, Andy Gross , linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, Christoph Hellwig Subject: Re: [PATCH v7 1/8] fs: introduce kernel_pread_file* support Message-ID: <20200608133249.GW19604@bombadil.infradead.org> References: <20200606050458.17281-1-scott.branden@broadcom.com> <20200606050458.17281-2-scott.branden@broadcom.com> <20200606155216.GP19604@bombadil.infradead.org> <1591621401.4638.59.camel@linux.ibm.com> <20200608131630.GV19604@bombadil.infradead.org> <1591622526.4638.71.camel@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1591622526.4638.71.camel@linux.ibm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 08, 2020 at 09:22:06AM -0400, Mimi Zohar wrote: > On Mon, 2020-06-08 at 06:16 -0700, Matthew Wilcox wrote: > > On Mon, Jun 08, 2020 at 09:03:21AM -0400, Mimi Zohar wrote: > > > With this new design of not using a private vmalloc, will the file > > > data be accessible prior to the post security hooks? ?From an IMA > > > perspective, the hooks are used for measuring and/or verifying the > > > integrity of the file. > > > > File data is already accessible prior to the post security hooks. > > Look how kernel_read_file works: > > > > ret = deny_write_access(file); > > ret = security_kernel_read_file(file, id); > > *buf = vmalloc(i_size); > > bytes = kernel_read(file, *buf + pos, i_size - pos, &pos); > > ret = security_kernel_post_read_file(file, *buf, i_size, id); > > > > kernel_read() will read the data into the page cache and then copy it > > into the vmalloc'd buffer. There's nothing here to prevent read accesses > > to the file. > > The post security hook needs to access to the file data in order to > calculate the file hash. ?The question is whether prior to returning > from kernel_read_file() the caller can access the file data. Whether you copy the data (as today) or map it (as I'm proposing), the data goes into the page cache. It's up to the security system to block access to the page cache until it's been verified.