Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4931923yba; Mon, 13 May 2019 02:15:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqy2ODh913vsCvlBD5jDWEXVeGhYQ3c+vjBW4GTvdk0rFoQndr06AKucCLONdvBtPICSW0Zx X-Received: by 2002:a17:902:6683:: with SMTP id e3mr21641599plk.291.1557738958580; Mon, 13 May 2019 02:15:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557738958; cv=none; d=google.com; s=arc-20160816; b=Ham3hIrQPzkynyVFBBxCcrj2OX6MKAwAEyJ7z/g7Lo0kJlw5xweI7WRZNbCZg51xUo KlGd2UaXwqcmw0ffuzYydnk0wnNU69Yz/AFf2Nngl4HqkcA9SqLXS6j91fH1Um3AMAPK 7tswxcaOJLjom4UcT69Ev71mW/BOke9TvjY4kPHEwVIdE1C+Ug702bSXZMC3zhjNTUtX kaO3phBZzGum9e4Vxzh25qoLCd9a5nypSYf/gQdSdY2xfjgW4eOIvk4By6GxKsqsY8IB /Sfkp/FT9DTVCLEkkUy8NUqpSOGceG2UPMkppN1lFF4+JrLtwQrYmC60u86aKy4dIt8X EIHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=qwDWppeak4StkwwIqPbFuP2Sw+vbSRTA0LO5Y4RKZco=; b=cwMFMWIEjLWzVWDqZg8CczsAN2FUMHt6nriBhEtO1ocF2ZiInq6rmVYN73rkuyoZNf HAQmDGso+MFztHFqKxKXxaq0aZ0GLukdXxiTP05Rm5pE8BaqQlWZlccfWbEg1IEEU5jN Vq3B25idlH6Ckrc0mq7691gKuzMLtXAEcbsg7O2rpOQe5zf97Zqi998zbH/aFWJRi5z3 mmZlF6qToMGI8wf1DWl9dMHv3ZK7uXelYc8qwExKYaEx0mBGMCZI7IBH/JLWegwOv6gm 6Z2Nm+MeelmluYxo5a67EezNRl2WTXFHb3bx6SR8ib/MMt3kBxX2b6pKOuBmcj0CAQ8S ZcUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@landley-net.20150623.gappssmtp.com header.s=20150623 header.b=tmI+LoFj; 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 y8si14963523pgv.115.2019.05.13.02.15.42; Mon, 13 May 2019 02:15:58 -0700 (PDT) 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=@landley-net.20150623.gappssmtp.com header.s=20150623 header.b=tmI+LoFj; 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 S1728471AbfEMJGi (ORCPT + 99 others); Mon, 13 May 2019 05:06:38 -0400 Received: from mail-ot1-f68.google.com ([209.85.210.68]:36849 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727598AbfEMJGh (ORCPT ); Mon, 13 May 2019 05:06:37 -0400 Received: by mail-ot1-f68.google.com with SMTP id c3so11049769otr.3 for ; Mon, 13 May 2019 02:06:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=landley-net.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=qwDWppeak4StkwwIqPbFuP2Sw+vbSRTA0LO5Y4RKZco=; b=tmI+LoFjQc55qWJ3TmAEv7WpKUFTRX9KD1OY/i5sNq7aiCvOZCyz2ADAPxrkxESKUe a+Rk8qfaztMAdRNHsGcgs1ggDSDjLq/8EWWhx0e/BoF9aQodR0l7eiThmHvJ5mjKlY7J f5wSH3O2xSL0rYvUD4HiMFByVYXYc97tUyRsTUct2YpdPFUaDAJ1dT2PLCVuBByxHVwC FpCYqfa1DVeer7auP8Y08EFcdzTQYDGR49z7bOoCDVIpAQayyHvSr776tbOPUiVhhvpR 2ibGfPTJS0lGQXW21J8NqErRDz3wzRO2p/ymSp2uIQmPnJtXa5Kwlekizr2Qr6fGFR80 eOkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=qwDWppeak4StkwwIqPbFuP2Sw+vbSRTA0LO5Y4RKZco=; b=Z07/DzQp/1/YOWDmYPhOomumbXp04F1UO72z+SNLsxDW6vScbSQOTGeRGv65koM/7h eyF6+2p3WQoe7N+/zSzrNfIbDmPPhwIE5tP8RIkdfZS9Qod2M6pslMIvt6k+s3UuB9vB wNp+0F3I3K4e537txMRuQ8gPMC/GaSo0yEEc7W5hDgbzAFaLT8S5gKRVEcKBCa9mHAky BogkzKE9YHMHJHWFmGYAIf2amfXJf+etqgQc0auyDMopSn5MydZuylL9rYBAYQAI8gmf AoD74Bt24hTyLhMhEgNIF9dyfwLifyw6P15wYu4oEyUaXh7AA3UR0YAP+CRa6ytl6Esk QK1Q== X-Gm-Message-State: APjAAAWW4qYNnZ5FiemmCv3PAWuNe1LlR4ROE48CjvZJszSSjtic9k5Y 3+HdAmKMWA96tXWaz8ukeynoSg== X-Received: by 2002:a9d:6a4e:: with SMTP id h14mr211477otn.216.1557738396848; Mon, 13 May 2019 02:06:36 -0700 (PDT) Received: from [192.168.1.5] (072-182-052-210.res.spectrum.com. [72.182.52.210]) by smtp.googlemail.com with ESMTPSA id s8sm5024580otp.37.2019.05.13.02.06.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 02:06:36 -0700 (PDT) Subject: Re: [PATCH v2 0/3] initramfs: add support for xattrs in the initial ram disk To: Roberto Sassu , Arvind Sankar Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-integrity@vger.kernel.org, initramfs@vger.kernel.org References: <20190512194322.GA71658@rani.riverdale.lan> <3fe0e74b-19ca-6081-3afe-e05921b1bfe6@huawei.com> From: Rob Landley Message-ID: <4f522e28-29c8-5930-5d90-e0086b503613@landley.net> Date: Mon, 13 May 2019 04:07:08 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <3fe0e74b-19ca-6081-3afe-e05921b1bfe6@huawei.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/13/19 2:49 AM, Roberto Sassu wrote: > On 5/12/2019 9:43 PM, Arvind Sankar wrote: >> On Sun, May 12, 2019 at 05:05:48PM +0000, Rob Landley wrote: >>> On 5/12/19 7:52 AM, Mimi Zohar wrote: >>>> On Sun, 2019-05-12 at 11:17 +0200, Dominik Brodowski wrote: >>>>> On Thu, May 09, 2019 at 01:24:17PM +0200, Roberto Sassu wrote: >>>>>> This proposal consists in marshaling pathnames and xattrs in a file called >>>>>> .xattr-list. They are unmarshaled by the CPIO parser after all files have >>>>>> been extracted. >>>>> >>>>> Couldn't this parsing of the .xattr-list file and the setting of the xattrs >>>>> be done equivalently by the initramfs' /init? Why is kernel involvement >>>>> actually required here? >>>> >>>> It's too late.  The /init itself should be signed and verified. >>> >>> If the initramfs cpio.gz image was signed and verified by the extractor, how is >>> the init in it _not_ verified? >>> >>> Ro >> >> Wouldn't the below work even before enforcing signatures on external >> initramfs: >> 1. Create an embedded initramfs with an /init that does the xattr >> parsing/setting. This will be verified as part of the kernel image >> signature, so no new code required. >> 2. Add a config option/boot parameter to panic the kernel if an external >> initramfs attempts to overwrite anything in the embedded initramfs. This >> prevents overwriting the embedded /init even if the external initramfs >> is unverified. > > Unfortunately, it wouldn't work. IMA is already initialized and it would > verify /init in the embedded initial ram disk. So you made broken infrastructure that's causing you problems. Sounds unfortunate. > The only reason why > opening .xattr-list works is that IMA is not yet initialized > (late_initcall vs rootfs_initcall). Launching init before enabling ima is bad because... you didn't think of it? > Allowing a kernel with integrity enforcement to parse the CPIO image > without verifying it first is the weak point. If you don't verify the CPIO image then in theory it could have anything in it, yes. You seem to believe that signing individual files is more secure than signing the archive. This is certainly a point of view. > However, extracted files > are not used, and before they are used they are verified. At the time > they are verified, they (included /init) must already have a signature > or otherwise access would be denied. You build infrastructure that works a certain way, the rest of the system doesn't fit your assumptions, so you need to change the rest of the system to fit your assumptions. > This scheme relies on the ability of the kernel to not be corrupted in > the event it parses a malformed CPIO image. I'm unaware of any buffer overruns or wild pointer traversals in the cpio extraction code. You can fill up all physical memory with initramfs and lock the system hard, though. It still only parses them at boot time before launching PID 1, right? So you have a local physical exploit and you're trying to prevent people from working around your Xbox copy protection without a mod chip? > Mimi suggested to use > digital signatures to prevent this issue, but it cannot be used in all > scenarios, since conventional systems generate the initial ram disk > locally. So you use a proprietary init binary you can't rebuild from source, and put it in a cpio where /dev/urandom is a file with known contents? Clearly, not exploitable at all. (And we update the initramfs.cpio but not the kernel because clearly keeping the kernel up to date is less important to security...) Whatever happened to https://lwn.net/Articles/532778/ ? Modules are signed in-band in the file, but you need xattrs for some reason? > Roberto Rob