Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp845589ybd; Sat, 22 Jun 2019 17:00:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqwcpqQ4kPJ5xHIFA93ffyjC0GdX9uE7o/tLO+hdULI6ovrnBu83NenUDMnqSbKzj28NwMRU X-Received: by 2002:a17:90a:bb94:: with SMTP id v20mr15850008pjr.88.1561248016240; Sat, 22 Jun 2019 17:00:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561248016; cv=none; d=google.com; s=arc-20160816; b=T8ZnWpoZ7o2rnNVVvvmbWgprq+cZalfU8RvIWAlbKNlrI6y+OmEy2UuNKMmJf4at6P xVpC/xEwrL1FpKSU5rrcLQsA8IQcjSwB2lIFawJtwwSGJDbB2228oBpknS/s9EzLuDNV MQC1Qfwydna7fB6sOh23a2M/P2RsOh+zKS8rese1zhhiI7QEgomhnLtaPzvpHfArrWdz QWkrYIM4XTjHxpyriW8oPwuw5uloN7pT0VwuBA5OlTiXAOQe6fqvtKRz44cG46Hvzhb3 JaEgf66DHB0YZ07QKdjI6H4GOjwcv7WDjgud5eJUvJt7L4AV9o5GKjVFkkYP2u8aBxe4 1Hcw== 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-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Am+xsKrCSgqUDTnEarlPfGUv+iV9mXgrux7mgCCSlTE=; b=jg8KyOfnaS3uPbCRgQOiYzbrZEOgqxwF3MRnE5jVZcc6nOvVAVZfpjSxd5Td+yyXmo LBAUaSV3cv8sHXkXCr0f0LwD6vj1CIo8sRTs7iZ5D94Ca/JX/FkAM3JFnyg/6Kz3LgF5 lo5Mv7b7bAS4L8R4UjSe7ONEeIqFryilMb3k7jKwW7YDwsw1oWQa7tMoJpY27gA72sME q8a6ob5LwObzbcUgyHH64/b7TnUmTfMSn+mJJ7mJl2d0fvBokzK16/gfwfqTsmFK3sXP c+6U4CjTSTVeL6zcKu97p/Ygf2FubwWd0KARYtgMgXB3yMZ3ew05ppLZi1ll7OwjpHlY eubA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=F8I13xTr; 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=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q19si5735484pgv.31.2019.06.22.16.59.58; Sat, 22 Jun 2019 17:00:16 -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=@chromium.org header.s=google header.b=F8I13xTr; 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=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726548AbfFVX7W (ORCPT + 99 others); Sat, 22 Jun 2019 19:59:22 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:43738 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726481AbfFVX7V (ORCPT ); Sat, 22 Jun 2019 19:59:21 -0400 Received: by mail-pf1-f195.google.com with SMTP id i189so5417623pfg.10 for ; Sat, 22 Jun 2019 16:59:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Am+xsKrCSgqUDTnEarlPfGUv+iV9mXgrux7mgCCSlTE=; b=F8I13xTrwM4qgJZ1AlQrosD+/dfL+k4I2BJY5EwJJA+V0o/F4JxRpPGagXK9/2IVqc tVdO/fP0tNnP1OTDV6AAHYpD3L4hjjSex1yKEnFJU9WGvBCye6SuBL31SaMoMmV8zOR5 K/fDvVu8JN62Z0d68189BG2IJWum90YlEuK10= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Am+xsKrCSgqUDTnEarlPfGUv+iV9mXgrux7mgCCSlTE=; b=MUwMibhobCEHBSs1YEjSHoGkbFcLlDX3+mGyKUJ1n1mH5RN/4TMqrC/v8/1xIUO5ei wcrNRlCrNWz/CrxN/mSnCNguP2FvE2yAf3PDCk9Zh3W1r/EgPF5GZBtDFF+kk7a3qWni hnEkEEGO5mMrYKj3raYqD+jO6K9ShCVQ/gF6jxJGwjN5V07Rr7BNnu66aBSgEtb8B6qv fUy2j4TmCMfAaAcKzqgoUgmxzDelExT21ZvseGFVaHEMfpg/J0Ju9lJ5L+dVcUR6OUsX hVAW42cH8s4F+YM/waUQ6sKKt/U4fD7rsJuWL0mW++G2z7PiqrJXeOkVGXNcoy+5p10y yDIw== X-Gm-Message-State: APjAAAWGio31UCFdzW7g1N+r+9LR1UtbvFQk6jHnQUKr7R9iKVZtdWH3 dUBZA/YcvT54xGFHO+gAiPa9fw== X-Received: by 2002:a63:c10d:: with SMTP id w13mr25197902pgf.28.1561247960107; Sat, 22 Jun 2019 16:59:20 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id c9sm7343653pfn.3.2019.06.22.16.59.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 22 Jun 2019 16:59:19 -0700 (PDT) Date: Sat, 22 Jun 2019 16:59:18 -0700 From: Kees Cook To: Matthew Garrett Cc: jmorris@namei.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Matthew Garrett , Matthew Garrett , David Howells , linux-acpi@vger.kernel.org Subject: Re: [PATCH V34 14/29] ACPI: Limit access to custom_method when the kernel is locked down Message-ID: <201906221659.B618D83@keescook> References: <20190622000358.19895-1-matthewgarrett@google.com> <20190622000358.19895-15-matthewgarrett@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190622000358.19895-15-matthewgarrett@google.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 21, 2019 at 05:03:43PM -0700, Matthew Garrett wrote: > From: Matthew Garrett > > custom_method effectively allows arbitrary access to system memory, making > it possible for an attacker to circumvent restrictions on module loading. > Disable it if the kernel is locked down. > > Signed-off-by: Matthew Garrett Reviewed-by: Kees Cook -Kees > Signed-off-by: David Howells > cc: linux-acpi@vger.kernel.org > --- > drivers/acpi/custom_method.c | 6 ++++++ > include/linux/security.h | 1 + > security/lockdown/lockdown.c | 1 + > 3 files changed, 8 insertions(+) > > diff --git a/drivers/acpi/custom_method.c b/drivers/acpi/custom_method.c > index aa972dc5cb7e..6e56f9f43492 100644 > --- a/drivers/acpi/custom_method.c > +++ b/drivers/acpi/custom_method.c > @@ -8,6 +8,7 @@ > #include > #include > #include > +#include > > #include "internal.h" > > @@ -28,6 +29,11 @@ static ssize_t cm_write(struct file *file, const char __user * user_buf, > > struct acpi_table_header table; > acpi_status status; > + int ret; > + > + ret = security_locked_down(LOCKDOWN_ACPI_TABLES); > + if (ret) > + return ret; > > if (!(*ppos)) { > /* parse the table header to get the table length */ > diff --git a/include/linux/security.h b/include/linux/security.h > index 30bc6f058926..cc2b5ee4cadd 100644 > --- a/include/linux/security.h > +++ b/include/linux/security.h > @@ -89,6 +89,7 @@ enum lockdown_reason { > LOCKDOWN_PCI_ACCESS, > LOCKDOWN_IOPORT, > LOCKDOWN_MSR, > + LOCKDOWN_ACPI_TABLES, > LOCKDOWN_INTEGRITY_MAX, > LOCKDOWN_CONFIDENTIALITY_MAX, > }; > diff --git a/security/lockdown/lockdown.c b/security/lockdown/lockdown.c > index 297a065e6261..1725224f0024 100644 > --- a/security/lockdown/lockdown.c > +++ b/security/lockdown/lockdown.c > @@ -25,6 +25,7 @@ static char *lockdown_reasons[LOCKDOWN_CONFIDENTIALITY_MAX+1] = { > [LOCKDOWN_PCI_ACCESS] = "direct PCI access", > [LOCKDOWN_IOPORT] = "raw io port access", > [LOCKDOWN_MSR] = "raw MSR access", > + [LOCKDOWN_ACPI_TABLES] = "modified ACPI tables", > [LOCKDOWN_INTEGRITY_MAX] = "integrity", > [LOCKDOWN_CONFIDENTIALITY_MAX] = "confidentiality", > }; > -- > 2.22.0.410.gd8fdbe21b5-goog > -- Kees Cook