Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp83708ybi; Thu, 20 Jun 2019 18:21:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOKHylnTn+WJilwGQo030OCU148WZLTO2aT8LGKc5id8qD7uKwnRd7ay0X22K79ZsHYom2 X-Received: by 2002:a17:902:b115:: with SMTP id q21mr67789137plr.36.1561080082569; Thu, 20 Jun 2019 18:21:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561080082; cv=none; d=google.com; s=arc-20160816; b=GFtTZVOe1z1k61HI/QbjyS4lVZ3qcj+fw3Uz/4QlaY3iibRvlYxwGpBMweJM3L9A/I Cfh67hM90o3trJSxprDytJpeMr7al29ZHLXwn1y8Cf8M0kguCYKrwxdMxMX4eGcKLYrN htFcSJw6sOh/H9W4DY/nsrwQsLtGorpu8VRwBjdBikB6hYOQyHAFFkPaqceTVTtPPKxX ScJ9iuxojBpZt/Kb8EnDuwEJ/N0S7oBr636lTgZejb4IvBt5cXZAPdCnatOxwmQJ4wS8 N8TSTH6hPUWHrIvJ3v60VgEvOwDkMKTwRO/vuR3Nb7DGW7aBQk8fftFdH008FnuIy8Tg jX3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=S9uK51Tt5kTkNleSSR/hMhgYxxujw1wxKeyqQuG6LR0=; b=EPO01gQDhCErOV+QyBJ/xBAgy4WXNrkkAbAkNBGT3BiL3g6GuNSAz60yNFfM74jCES ICGF0zI4KO8oezA0486A4E7AZF0vDZ+rfFR0N9Qj8lEXf14ffJvcK2iOunkhUgapNBZe uNbavUCh7jfPtSgaVnrI/X/ir/jPC13IPHbUdyQz3SagrpGNIdF8WFFd+Fxopsv8jZcU 3Fk84qQuuXmZWbGLcDGwk+HKQsRwnehDhzTXnhnpUWeNDo9J1K+w6brQ6rHoK/xjsfoa +FVYvt0y/KSkHvjb4GS2k2Fpym9FPo2MG5f9SWRcbalej5nNnrggdqUu6KjMZeSkn+aG FK5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=H5xvGNs3; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d12si1166985plo.68.2019.06.20.18.21.06; Thu, 20 Jun 2019 18:21:22 -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=@google.com header.s=20161025 header.b=H5xvGNs3; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726719AbfFUBUc (ORCPT + 99 others); Thu, 20 Jun 2019 21:20:32 -0400 Received: from mail-pf1-f201.google.com ([209.85.210.201]:45510 "EHLO mail-pf1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726657AbfFUBU0 (ORCPT ); Thu, 20 Jun 2019 21:20:26 -0400 Received: by mail-pf1-f201.google.com with SMTP id i27so3245782pfk.12 for ; Thu, 20 Jun 2019 18:20:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=S9uK51Tt5kTkNleSSR/hMhgYxxujw1wxKeyqQuG6LR0=; b=H5xvGNs3/JGGDuqCosXJWsRozrb5ppiKaTdNYWvS42z7Nm1KS0IDqLzZj7y5L747HS LZ30WMLFKfEiTA9DmEQyGsStSLAeQDYtd8KjP8EeErMKxa1ixgm0YvXUBMGd277RaGIt sHjAP7bA5KJmvuIk50IAlBoQoBZvyOqtsA35V+Ivo84S0hn5KcJPKZg/W3Ghjf/qBK23 cPTwV3p0MO+KBxmdRGAatKc4IhIJ0MSdAxDnJ42o8cUHOl7U+j7cJIvuwTfhjU5x6aZj DrJHuE1edXR5UUMVvKGCWk8fR2wVKaYYeQZIW/HN0qH6jTY3yRrL50noU5MI5CX8cuvJ 0URw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=S9uK51Tt5kTkNleSSR/hMhgYxxujw1wxKeyqQuG6LR0=; b=FEs8R/Y8zk0SQ3GTZThPqiqT1dPmy+dKNXTKDeUrCj55JK6Lmusgg0yjeKoRj/wEcW mcIu7LauLD1Tb7UcqzWOlxKsANPZggvDxkcIH7zNmKuZW6Cwmo03Kyica4qSHw7hAcIS OLssV4m0OnpQWX4/IOfElczRjc3POqpjJNa5oWevOkTgwr8cshSzdQDKLTTEigfrS+P8 eB2RXWgeph1Le+B5Py/d0VC+6+/W4XbNgLtLfO17Hvko+P8adcsyVkVXC4O1UHnMaa98 pmKT83/bHLNDES8hItq4Tx7Hh4bm2Fd0FYrBDPIO0nDvOXoU7A7oL3ElsTO5nz7hCUJv f9WQ== X-Gm-Message-State: APjAAAVA6Jjk0SuYkyGwLYiITcl2O9yDB+rhcFzmEStJ8ikzrKqUDSLN oMX6wdqI+PnTiLq+OjoiDOUclHbGoCoairKLn7owZA== X-Received: by 2002:a63:1c09:: with SMTP id c9mr6048922pgc.63.1561080025466; Thu, 20 Jun 2019 18:20:25 -0700 (PDT) Date: Thu, 20 Jun 2019 18:19:26 -0700 In-Reply-To: <20190621011941.186255-1-matthewgarrett@google.com> Message-Id: <20190621011941.186255-16-matthewgarrett@google.com> Mime-Version: 1.0 References: <20190621011941.186255-1-matthewgarrett@google.com> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog Subject: [PATCH V33 15/30] ACPI: Limit access to custom_method when the kernel is locked down From: Matthew Garrett To: jmorris@namei.org Cc: linux-security@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Matthew Garrett , Matthew Garrett , David Howells , linux-acpi@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: David Howells cc: linux-acpi@vger.kernel.org --- drivers/acpi/custom_method.c | 4 ++++ include/linux/security.h | 1 + security/lockdown/lockdown.c | 1 + 3 files changed, 6 insertions(+) diff --git a/drivers/acpi/custom_method.c b/drivers/acpi/custom_method.c index aa972dc5cb7e..5c684b09a2d1 100644 --- a/drivers/acpi/custom_method.c +++ b/drivers/acpi/custom_method.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "internal.h" @@ -29,6 +30,9 @@ static ssize_t cm_write(struct file *file, const char __user * user_buf, struct acpi_table_header table; acpi_status status; + if (security_is_locked_down(LOCKDOWN_ACPI_TABLES)) + return -EPERM; + if (!(*ppos)) { /* parse the table header to get the table length */ if (count <= sizeof(struct acpi_table_header)) diff --git a/include/linux/security.h b/include/linux/security.h index 81c0968e485f..88d0f5d0cd87 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 a01301972290..bfc0e088aa85 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