Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2701207ybi; Thu, 18 Jul 2019 12:47:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqzGmPpNwdf1E42qWM+VOGOqEW3DyqPZ3pQaSZBVfy2mkojlffydTJdhSHRsMYhcNnGlf7AT X-Received: by 2002:a17:90a:1a45:: with SMTP id 5mr54013881pjl.43.1563479225503; Thu, 18 Jul 2019 12:47:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563479225; cv=none; d=google.com; s=arc-20160816; b=rQdtRLNqeBNvMU+h1m8nU5UAEFkolRMHeQsXsSDu1gXLxduBofX4RzbVdWFNZQ3bev 85DaQk4kqvm0tpNq86xOzwlEWeqUmRt92cOFgaDvu2N2XJUIv34CuW/WR7vd7P8aEpMA PqzaIW0c2g2QkQifaHRrWBe7IrK2WH+8YH2Lz9Z5aVYEsna+BcGMZnY7xCfrZ3T/JwFQ D8GW7rUVodGHKmO2QZZPIaYuOrxCvtCPBMjB3a63QhFQrAeAdZC+8GwTSn+9UZ9k9GuF HfpeLxQ4GCfXYprs5Xs1wbjV52TGQhrTfcbj3rwVb50AHATUxjkdQKXuUNOcmUy5fDm9 HgDg== 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=RmH/lQXgmHpT1wDdkDviRnHZue3oZYbqIfCTXvy7fCM=; b=bBQORekTXr/sgYInI6T0ux8sL9Xpan8B71zvPNjdfQHYM4trRVnR7hMokZffVy0nun nGKCxtR/VuspvxtuUk1SzA34RgWrWVytWaWiM1IXWmJPzJnOtn1eYpwEDD0IV07DQ5QQ 9b91Vbhp6ym7Q/S47ypStllu8JxQPb1kPo3bcuOvNLif6uVuykuPuiOYPs4twqnoFwoI cIow1lNnnurQ3vhsAoUjCHbrr7JmFvPeCZidPY1npaNSRkJ1orL/SZ+jMF4ueYRlCRR6 9NAuvg60As/fXSnDf5rrmk4eHXLZiU/FTWY4SziGqxwOUkMnbm2ljuqhB9eewnuvAw2E ZhQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=sr+U+0BU; 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 j6si1433349pfi.240.2019.07.18.12.46.50; Thu, 18 Jul 2019 12:47:05 -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=sr+U+0BU; 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 S2403840AbfGRTo5 (ORCPT + 99 others); Thu, 18 Jul 2019 15:44:57 -0400 Received: from mail-pf1-f201.google.com ([209.85.210.201]:49366 "EHLO mail-pf1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403805AbfGRToz (ORCPT ); Thu, 18 Jul 2019 15:44:55 -0400 Received: by mail-pf1-f201.google.com with SMTP id 145so17207560pfw.16 for ; Thu, 18 Jul 2019 12:44:55 -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=RmH/lQXgmHpT1wDdkDviRnHZue3oZYbqIfCTXvy7fCM=; b=sr+U+0BUhfEnXadfS3Td1uoyOy7MyzT1cfjoaE68UBw1WhRqNJMBFgpLkQFYR8CYek KMLLN+smdCN2smIEcLzxglZftb5hu87OZDSnHoh58j9iUJ9WtMY8gtatqIWRzLoReE4k rOXwOJJUY3pNC9LTVR+45zWViuky5wZ5OsqQmEH21XbkAZ2iczTBIY0BDe0O6ftn+0Nd N8VHxUEL9vzNp13MjZ/HenFMfJvjHjVq4+s9MH40Hv98la5iFc/+chgCT/UbR25vQQo8 f1K5mSd6Q5IDsOeHHgZ8Jj3sZRtyFkxD9BOWOQoOTJwCQ5ZkVLIwSvMUjWHIe2vcYKG3 IrqQ== 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=RmH/lQXgmHpT1wDdkDviRnHZue3oZYbqIfCTXvy7fCM=; b=WoTeMSz/OvaEVljnca3Jw/tsq0+AlzFd4zJ9TARlub6WZCtwOyWdIZgFzhzYSn1Bso yPvt3apFigxP/PSUZ7ZuxN6+7EpsmkiW5BqlcRBOOwXNeOEBbCHYQOBffsDflZ+iBsFa pSulD2N2bJZmPGD8SOHysBPuF6s8fNSM+NnZ0JaAiE3vmIE8DYgpHZMM5nnnqbTHfnQE 32DqwATbZFkSl+a7u7Bs8pByHlXg8NjUXwCqW7IQPcobAR0QZaSZqNgCgQFWYRgURTvi 0e0FbVuFbetrHcj8UMADymzyVncZx8lYrYkNpxSbJmVD6gVf6H4RKpwmhcpJHDUDRS/I HS4w== X-Gm-Message-State: APjAAAXmSQ72w8fJLuZ0Z/hTakNEeeIWeriaNHt2sloOprTq6DJOSxfj Leg7j0o64d54AWzp6etqD2FikPzRlB0oj39wAciArQ== X-Received: by 2002:a63:460c:: with SMTP id t12mr49204271pga.69.1563479094865; Thu, 18 Jul 2019 12:44:54 -0700 (PDT) Date: Thu, 18 Jul 2019 12:44:00 -0700 In-Reply-To: <20190718194415.108476-1-matthewgarrett@google.com> Message-Id: <20190718194415.108476-15-matthewgarrett@google.com> Mime-Version: 1.0 References: <20190718194415.108476-1-matthewgarrett@google.com> X-Mailer: git-send-email 2.22.0.510.g264f2c817a-goog Subject: [PATCH V36 14/29] ACPI: Limit access to custom_method when the kernel is locked down From: Matthew Garrett To: jmorris@namei.org Cc: linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Matthew Garrett , Matthew Garrett , David Howells , Kees Cook , 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 Reviewed-by: Kees Cook 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 b2ef4c2ec955..7031307becd7 100644 --- a/drivers/acpi/custom_method.c +++ b/drivers/acpi/custom_method.c @@ -9,6 +9,7 @@ #include #include #include +#include #include "internal.h" @@ -29,6 +30,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 155ff026eca4..1c32522b3c5a 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -110,6 +110,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 d99c0bee739d..ecb51b1a5c03 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] = "modifying ACPI tables", [LOCKDOWN_INTEGRITY_MAX] = "integrity", [LOCKDOWN_CONFIDENTIALITY_MAX] = "confidentiality", }; -- 2.22.0.510.g264f2c817a-goog