Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3354943ybl; Mon, 19 Aug 2019 17:21:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqyWtAfT2+n5pzIfSOoRrRwcNApyvo/E730+ark3T5bnrTaoZZQPUwyf4ODIbQM3TFhB+dFo X-Received: by 2002:a62:5802:: with SMTP id m2mr4474821pfb.169.1566260507756; Mon, 19 Aug 2019 17:21:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566260507; cv=none; d=google.com; s=arc-20160816; b=hvlUUZ97OWPXysMhZ+mbRm/yASIgsPi/660BuRicLDTgafbaurECHrSTw4Mx3R8sqR 837OMTkJanz0ycXdKnmxCks9US8/fwpW/2Dx2LKAjcVV3iFB67iI4w+YJufOBkX8efZN 7714R3ZW+P9/yg9ngEjgVgKmrjS5AKFQ3Tv2+MY7kA7NW5IaIpkMCKi2xaaL8rkluu7D 9Fd54El/i4ue08jlaICcqHCl5QvoA/jxKCFwcoNC0bMmOqxbsW5KE5hC4BhCp8fqhTOx XnPuUtlMK1nv6S008PsiIJR5G+xspm21PKgzXxhz1/8AmPb/WuBL3yjdM24YvE7i9S0S 6WQA== 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=cqqNQcjxZKCBbJrhwZmXlaL29Q1qsVjTwEkp4+lUxdU=; b=W6no1pt2vdx/xQxwjSgOtzQx3yL0xZ89VOUDtLFHRYCqkZhqZv4ARsaJr7y3mfW5z1 ecksD6ieIOCqqwrv/6y2HqQAL7cZpwKG6kGKYer6pMzYtSBt901Q76dfy+eKYi0lNgij TXKLJ1nXdjENh9lR7s/AHp8Khjz6nN7Up9fKlqSvd+cpRfvfRxRXQv/XqQUxrz/4m0KP 5NopSwkRobZSJgj1qgS3pxZp3fU1Atn5H9dqnuK+iMW3HSp0eIGRStqgRvgXRfDq1Pxj igpTobC+zn36u3ekHOeXS8GofxCr1eY3/e2T/uQSzWOmUAss1Uso09tKJlqHx9Hipt9k 2lMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=BO4kQ093; 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 a19si10871383pgv.180.2019.08.19.17.21.32; Mon, 19 Aug 2019 17:21:47 -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=BO4kQ093; 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 S1729091AbfHTAUI (ORCPT + 99 others); Mon, 19 Aug 2019 20:20:08 -0400 Received: from mail-qk1-f201.google.com ([209.85.222.201]:43039 "EHLO mail-qk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728970AbfHTASr (ORCPT ); Mon, 19 Aug 2019 20:18:47 -0400 Received: by mail-qk1-f201.google.com with SMTP id m2so5228852qkk.10 for ; Mon, 19 Aug 2019 17:18:47 -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=cqqNQcjxZKCBbJrhwZmXlaL29Q1qsVjTwEkp4+lUxdU=; b=BO4kQ0935/Y6yDgFnhcP8U6VvEnTvdTFa/3/fszoNSnRJF6dFBqhAjx6db960YfW0K qw9yz47/8ZyE7El9zyKrpX6FxYTqfCOL/KV4sKWwPji/sOlAKKSZJGMnIfy08kBE/oZj 5Ow1ygy8tsS7ANpFzOe7Kp1U16F48xU8m+P1WFrA1xc3bLm6Jgh5b9hFkkh5oaITb+Ji sWSWe0i1edcvaMRxj6V14kv8WeQFfDfQM3JvK0bj3fESox4Fnq9hVhynGXjBbP3l99Ut R8L+pMW90KxNobngtePTakpHnAIOlPcoCK4QFSrTWkmEbbuLhqiAbOcS0Cx5ErD3vfgm UIiQ== 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=cqqNQcjxZKCBbJrhwZmXlaL29Q1qsVjTwEkp4+lUxdU=; b=CYHuD6GoiWK+u2/9wgafCIBjWGz6PvnXeGa0iIKpQVJGlkFcyqgMgKUo/rsP/RdLBH 2ktm99d2lIzpaMJhcta4JhWMKMKXXLMLkPY/J9OrflkkFivfjI5abv5E8u7Lc6bZfniT 6ZWUGQt1tIZqRq7xLD/SDo4Mlpok2bIFImSBuF/cPHHWijgW+KigpLnK4e7iFNN+GW5k xHP8Ym0ed+4W9M9pQagdnKMyEOb2cpC1QGC4sat3AknTdCJ+7qVZVCRz0OJLNWd+n6tP 3fWTs0jwVjG3plhRD51qJiwbbdD5kxRunPOiwZid2CpSP6hSzpk+ztuP9hyc//roGpYZ 8P0g== X-Gm-Message-State: APjAAAXDhqdKICiZ/36N4guKNNnurC0ynjBYZ1Yqxj1n6zSkw14op2cI Hg9/bmZjuZBJFVtArIeOcc5g0d4FyjPryqjdvNPDgA== X-Received: by 2002:a05:620a:1413:: with SMTP id d19mr23052964qkj.341.1566260326602; Mon, 19 Aug 2019 17:18:46 -0700 (PDT) Date: Mon, 19 Aug 2019 17:17:50 -0700 In-Reply-To: <20190820001805.241928-1-matthewgarrett@google.com> Message-Id: <20190820001805.241928-15-matthewgarrett@google.com> Mime-Version: 1.0 References: <20190820001805.241928-1-matthewgarrett@google.com> X-Mailer: git-send-email 2.23.0.rc1.153.gdeed80330f-goog Subject: [PATCH V40 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 Signed-off-by: James Morris --- 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 010637a79eac..390e39395112 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 b1c1c72440d5..6d44db0ddffa 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.23.0.rc1.153.gdeed80330f-goog