Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6479014ybi; Wed, 31 Jul 2019 15:21:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXb1zdJakVbWArgu0OM25QkY7ysTmNpUUuUQxXLOmkeBNOlU9EPlPYdfQaIl0QoIQ6W5zv X-Received: by 2002:a17:902:f46:: with SMTP id 64mr123553838ply.235.1564611686785; Wed, 31 Jul 2019 15:21:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564611686; cv=none; d=google.com; s=arc-20160816; b=eqafEj8o1PsFLdow2EVfpUn0k+RBZPaDhnu695yGiZj51FHMrKxqsNdrma9UFe87Dt Zi/w7LZ0UFqh679aHC8l/SaqBVBrDhULslct7r7IgleqWoNO5lZDT34BlrcO7mXRFGHj t4z1cScu1y1mh8LA/PShCtQLjntqSwXxQrbsQ/SzTI9s60KxY8DsXvgdX7TNHvIqUhqi H51roxujDYJJFf7//FtSZplLNQy7sqWd/cBMJMMqARuiJRBiceOgmJvAjxIUeNb59x15 4BsiqW2mv63axT0K71p33ruYcsCX379i1FtFW2ix7KNO9j5qKYoKUqmVb8wytts76Z44 v2yA== 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=HYGYby6crp40dCLBmhgwCvdnfCZZwxit6AHkXOrrVgc=; b=hZV1O2AGQ+HwzPRNAxMiWFJwAWWFHhXmlh/cu6g+x7hpLrjBrl0BxsF7Fz4DnU8FTE ShLNJsjDBYPEckoYZWqLUDxIlYkQvzMm3+FSlkAMOCBJ8Fhlc4WQrFzU83++KrJSdB03 JIfuldpePNG8W/Dla9RWDqI1btsDflpOZ845i3V3o1QQklTo5S4My0wqOea8gGvbV8BD a/LWdqoEsCNu7rNO3ViiXTSBXuToqWW7X0fJfbyCt3QgjHgmx4sa+x67PDkN4Jigsqdi DYF/OwAf9InczNmnU4UueY4GHjEI3c1VH9vm6LL3xrtUAHXx29SpNZk8gbXtpTtd3hpj dhaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=vEIr33UI; 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 z185si31986890pfz.248.2019.07.31.15.21.11; Wed, 31 Jul 2019 15:21:26 -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=vEIr33UI; 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 S1731300AbfGaWRF (ORCPT + 99 others); Wed, 31 Jul 2019 18:17:05 -0400 Received: from mail-pl1-f202.google.com ([209.85.214.202]:45512 "EHLO mail-pl1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731288AbfGaWRC (ORCPT ); Wed, 31 Jul 2019 18:17:02 -0400 Received: by mail-pl1-f202.google.com with SMTP id y9so38342476plp.12 for ; Wed, 31 Jul 2019 15:17:02 -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=HYGYby6crp40dCLBmhgwCvdnfCZZwxit6AHkXOrrVgc=; b=vEIr33UIHvwt3NqWIeZrb/59ulOIkcz7rfoXwf/T7Bm7ES4NLBQqA6eXizkSfE5vv3 FVEAfneKoLgNu2aaC4bzbB6LYw3f5NFnjVqP9s+oObZTrYzSawiE4g5T+5pK9LWkPzUl 7xNScG5swOXfYyB94pVc7cUTPklTEBfex/kk3GW9Dg8+hjfhm1+QG3rYI58FWSo1tnd4 UeCcXHE0/5Ni3ftiD+G+C/RFLw00Rz2lckGBrmAO/B7jRyjVzhQxOkSNAX9TQgQB3NmR 7rl0+tiA/WMA9OSfgrZdMhc7qhOUYeikze2HYm/uZdry/tyxh+9xAwJQvnLL40YFd70T P3sw== 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=HYGYby6crp40dCLBmhgwCvdnfCZZwxit6AHkXOrrVgc=; b=EgQR8oZQdebWHq9TOu8wZLhmvjpIVof5QXUkxZ/kAHpXICEKkZ0WL52FwLsVZqwDw/ MMHxxd4LLjL47W8LwcR3VNRwaz/WqplNx98T69hrfCJzTVoCbQ4zAYYWm4t32HV5/4of saHEoFhlSvFtJij3dMwB6xzurZQqFmn8tb3ZBHVU2/NlhFDCJ0HrMOWnhrrJM/6QYhTt Y8Lajbh1xY4Elk6n26OQwb2RUqqhahvm11i1G1btZ1isV+FGzOuPsRNm2ya7JF8paunL pTOrkZPvxSAAH86keP3BMuguBD28qOEM1d//xonAYQ83vxtApQmJtzOwVLDfTkhXdtUe afKw== X-Gm-Message-State: APjAAAV0i+m8+fqZZ6lAp3sGwWiSwN7lUgSFZmPlgkK1QkBxWbpsxBQM HJAAy7x0/PbsMnvZj9d4GPc81k30Wk2tjnEDoi7plQ== X-Received: by 2002:a65:458d:: with SMTP id o13mr114131617pgq.34.1564611421758; Wed, 31 Jul 2019 15:17:01 -0700 (PDT) Date: Wed, 31 Jul 2019 15:16:02 -0700 In-Reply-To: <20190731221617.234725-1-matthewgarrett@google.com> Message-Id: <20190731221617.234725-15-matthewgarrett@google.com> Mime-Version: 1.0 References: <20190731221617.234725-1-matthewgarrett@google.com> X-Mailer: git-send-email 2.22.0.770.g0f2c4a37fd-goog Subject: [PATCH V37 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.770.g0f2c4a37fd-goog