Received: by 10.192.165.148 with SMTP id m20csp4773139imm; Tue, 24 Apr 2018 08:11:46 -0700 (PDT) X-Google-Smtp-Source: AIpwx49LcRfa8JlMjCl2ZFa4f6+TD5g8lvb6hzC9uAMwzIObspeQtW1milwvLCd+y/1YvDLOf2yz X-Received: by 10.98.228.13 with SMTP id r13mr24248679pfh.51.1524582706192; Tue, 24 Apr 2018 08:11:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524582706; cv=none; d=google.com; s=arc-20160816; b=r/nz/o1MNMoYriGgW59US8AmLpOq0+xeN+1+qHUMbqEmEB91hzVa8VtOQa89SlpQyi cfbwNjpxU0PoW6wJG9wTXizkawMxwQt+OP3s4hDXhYTIjMpoTIXiiz0++HL1gbqEcY8g pMP0yR7Ega5ppUPN4xeqXoo1wkecvnsL9YHjJ1el2W3qydAu6SneNwksXzzWPJdQEA/e YSkplHbIlujMR0xQN5T26xfmsipK0XkZ1xAbhFZhcTs+RRVkQ7SpLTm+dXZJObApXicI SLeGkqeGk9AheIEbkLwlqJ2KnqA5J5iiBSMnOGd2bgXBn12f0twcYtMr5NlKVR8sTY/6 Kb6w== 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:arc-authentication-results; bh=UDpbBgUS/VQYS1rmJ7/3JRRPR9jZ4TV2wRpjSlExLnU=; b=vQR1U/QwcZQzcLcwqkrrOMGuLC5tkkRBsXEgonH9NpLB/hFCP/mn8UzZlyspZKX61O 6bA8gY7+LeV3bjBKnAKmGwAMaCmVNDFW7h/EGBqWtmgnOp3E6G+KB5mOTzKiuHBbDSbp fVbIWtnZLHYJDkLPAzxAe3eGKchaHfoYgPG3kknAj4f8h4QZ/wVIdCDA6WtESgiZOmj1 7S8L9bgVHH2MVOO69AQQCn/k+IjW1BU3PaiKpXM8fMJjkjkPAvMDTIu+mv1IUVDd3Ng/ cRXTeNAFBq58FoJPNQuOxaPgCsmwj2OP+HNv59jfNTK1lHw2/AVgdWZHwQ/hoFevcD+P q0TQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h186si12019663pge.324.2018.04.24.08.11.16; Tue, 24 Apr 2018 08:11:46 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751377AbeDXPJ6 (ORCPT + 99 others); Tue, 24 Apr 2018 11:09:58 -0400 Received: from mail-wm0-f45.google.com ([74.125.82.45]:40644 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751038AbeDXPJ4 (ORCPT ); Tue, 24 Apr 2018 11:09:56 -0400 Received: by mail-wm0-f45.google.com with SMTP id j5so1477230wme.5 for ; Tue, 24 Apr 2018 08:09:55 -0700 (PDT) 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=UDpbBgUS/VQYS1rmJ7/3JRRPR9jZ4TV2wRpjSlExLnU=; b=CYVrEQRfJeEZhirCVQRYK7JsrtcYxZabfHgd8zO3khJ2A81RHkaRJRfza6GMnWo0/P K+waqTNn3C8VeXRl0U2OTfM/qHQfpUBQ8d8qbZTuSkoMGvp7nKizS2gm1QnfNclohYS1 OXJTFVG6YuSoF3hIWw3jjNdcAxTFVvrp5tPnrt3sxLB/j6A7LYiPJRY8EtG+P00WNKJ1 AUdfjqrw1znuvCP5qnnRcOmSViu9sILeSKYyw1vOHoDur+9XtqdTtMCLERnHtixeFN93 +Gap9F+bSQAFqtucGx92Ese4lO9eCmMgzHUnRhDFoqRX4t8kSJMePPgLn8zZarrX+PRa oHDw== X-Gm-Message-State: ALQs6tDPKv9D31LLV0sCosfVH7c4fRs+floF1rhYArLg+KuGaLEzMg9c f/UgskBBRTG4OiZ3s+x5G6SvmQ== X-Received: by 10.28.7.76 with SMTP id 73mr13280424wmh.128.1524582594879; Tue, 24 Apr 2018 08:09:54 -0700 (PDT) Received: from shalem.localdomain (546A5441.cm-12-3b.dynamic.ziggo.nl. [84.106.84.65]) by smtp.gmail.com with ESMTPSA id a205sm10149624wmf.18.2018.04.24.08.09.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Apr 2018 08:09:54 -0700 (PDT) Subject: Re: [PATCH v3 2/5] efi: Add embedded peripheral firmware support To: "Luis R. Rodriguez" , Mimi Zohar , Kees Cook Cc: Darren Hart , Andy Shevchenko , Ard Biesheuvel , Greg Kroah-Hartman , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Peter Jones , Dave Olsthoorn , Will Deacon , Andy Lutomirski , Matt Fleming , David Howells , Josh Triplett , dmitry.torokhov@gmail.com, mfuzzey@parkeon.com, Kalle Valo , Arend Van Spriel , Linus Torvalds , nbroeking@me.com, bjorn.andersson@linaro.org, Torsten Duwe , x86@kernel.org, linux-efi@vger.kernel.org References: <20180408174014.21908-1-hdegoede@redhat.com> <20180408174014.21908-3-hdegoede@redhat.com> <20180423211143.GZ14440@wotan.suse.de> From: Hans de Goede Message-ID: <71e6a45a-398d-b7a4-dab0-8b9936683226@redhat.com> Date: Tue, 24 Apr 2018 17:09:52 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180423211143.GZ14440@wotan.suse.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 23-04-18 23:11, Luis R. Rodriguez wrote: > Hans, please see use of READING_FIRMWARE_PREALLOC_BUFFER, we'll need a new ID > and security for this type of request so IMA can reject it if the policy is > configured for it. Hmm, interesting, actually it seems like the whole existence of READING_FIRMWARE_PREALLOC_BUFFER is a mistake, the IMA framework really does not care if we are loading the firmware into memory allocated by the firmware-loader code, or into memory allocated by the device-driver requesting the firmware. As such the current IMA code (from v4.17-rc2) actually does not handle READING_FIRMWARE_PREALLOC_BUFFER at all, here are bits of code from: security/integrity/ima/ima_main.c: static int read_idmap[READING_MAX_ID] = { [READING_FIRMWARE] = FIRMWARE_CHECK, [READING_MODULE] = MODULE_CHECK, [READING_KEXEC_IMAGE] = KEXEC_KERNEL_CHECK, [READING_KEXEC_INITRAMFS] = KEXEC_INITRAMFS_CHECK, [READING_POLICY] = POLICY_CHECK }; int ima_post_read_file(struct file *file, void *buf, loff_t size, ... if (!file && read_id == READING_FIRMWARE) { if ((ima_appraise & IMA_APPRAISE_FIRMWARE) && (ima_appraise & IMA_APPRAISE_ENFORCE)) return -EACCES; /* INTEGRITY_UNKNOWN */ return 0; } Which show that the IMA code is not handling READING_FIRMWARE_PREALLOC_BUFFER as it should (I believe it should handle it the same as READING_FIRMWARE). Now we could fix that, but the only user of READING_FIRMWARE_PREALLOC_BUFFER is the code which originally introduced it: https://patchwork.kernel.org/patch/9162011/ So I believe it might be better to instead replace it with just READING_FIRMWARE and find another way to tell kernel_read_file() that there is a pre-allocated buffer, perhaps the easiest way there is that *buf must be NULL when the caller wants kernel_read_file() to vmalloc the mem. This would of course require auditing all callers that the buf which the pass in is initialized to NULL. Either way adding a third READING_FIRMWARE_FOO to the kernel_read_file_id enum seems like a bad idea, from the IMA pov firmware is firmware. What this whole exercise has shown me though is that I need to call security_kernel_post_read_file() when loading EFI embedded firmware. I will add a call to security_kernel_post_read_file() for v4 of the patch-set. > Please Cc Kees in future patches. Will do. Regards, Hans