Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6480001ybi; Wed, 31 Jul 2019 15:22:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqzsY2BAn542JtKFcQ3TIECLCl2JCaKB2/OsQ1oFXLAruZsR8DmXfLoMB29wOGKkprXRc2A8 X-Received: by 2002:a17:902:145:: with SMTP id 63mr126215654plb.55.1564611760153; Wed, 31 Jul 2019 15:22:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564611760; cv=none; d=google.com; s=arc-20160816; b=L3hBKYWAwwMMUbyx4eTU4E8qL6c3PUQ9H6VnZ68m028D+o3qC6lef4xR50q6bKRhCS j173vIfw2lKBr0yG9Ntg92wEJhXxLQaiv2qUcrIFgOCjrjgOcw7f9lV0yjM20RBeMPR/ lG+ALOPnksSOcWDRYzw/0ykkgA2sdXb6Eoq3wW8TgrR+FA90/xn2+5TvITLbG2eUcT1M s0hIx9sH433YOjh8btIWcuhtPJpW9vtwSEPcqLC/S7Z04zT/0x/GZYfZ8YmGQwBnvTTH 5HXmmhJhxk1ig+yADbjtgK0io7DAS/Mc3bN+vnHrSl9/suqGCC625mwEoxrMSjIgkGN1 O3mA== 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=AYLtZ41z1RHlFpOZnl+JGLaHaK4EJ2Av6xB01tUKIjQ=; b=XlNtl19JR+cVv5/mrzyCywcZjw+uXLsPd+VMqs/d+HC/2KnLedQ/wUQVV1okYS78ny kCxHLb/oqtnxKh29arh+IGBz6/K2zr6zt7p1FrZfgzhg4qkYsm/nA7sTLxQFYbdapgJ+ i7RxWOBYBxry1kHUETHC8L+DBpbJV8iwKGQ0WQcQGJ9DlVrbdUItvyv4twA/DEnXfjvE uiI5j8J9ivfp2D3Afx49bl5BckTVD+6wUclT9nDkNnUSLOrWfyLYqPGbghe65LtLQB6K OxcvtHE4Y40FMxX72zBZF2imqaGo4iDoEDbRjJOAa+YTKaeZMj8mhRAwJh7Mjmo5/hgI MVtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=vvpeXRKy; 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 z12si32437352pgp.342.2019.07.31.15.22.25; Wed, 31 Jul 2019 15:22:40 -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=vvpeXRKy; 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 S1731341AbfGaWRR (ORCPT + 99 others); Wed, 31 Jul 2019 18:17:17 -0400 Received: from mail-pl1-f202.google.com ([209.85.214.202]:33107 "EHLO mail-pl1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731329AbfGaWRM (ORCPT ); Wed, 31 Jul 2019 18:17:12 -0400 Received: by mail-pl1-f202.google.com with SMTP id f2so38311460plr.0 for ; Wed, 31 Jul 2019 15:17:12 -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=AYLtZ41z1RHlFpOZnl+JGLaHaK4EJ2Av6xB01tUKIjQ=; b=vvpeXRKyc5OhHv4Gr/tukOYbwIwjOYYXtqIP/Io9iIGtPO3Kve6jw/W7bz2rF/pLv1 RlW5o4cGWbTXLPdROo8nSoKA3X7rpN7sDIwV1d/Fkm3vpj5fFKlODN732XeUwRiYz3Ke TW9ChBbAGCWNTBdcbOZ73xw4f5kes2Emo/1AT/+3MfhQ8BoEcrnKZHlAFFwFtqt85uMv Hrp+989qk4cKlnGSLSV1ao/ObzrMwaeocP0iHhwU4p9uXakErgQiaqLm3O0VzWsyNNyY 9CqLjrTvWM8AjYlNkYT/fe066FOTrmczakFGWc6cjFSFGLsLIYYWVoFByBrYFECbZTDO MNew== 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=AYLtZ41z1RHlFpOZnl+JGLaHaK4EJ2Av6xB01tUKIjQ=; b=AgRH1n59gKOqnkX+PAfkgZowwbiCGcZ/qSERu7RAan3H426QfPCoOM4u+hx+sh11UI WH5pOTteYjHMBcH+pFAmn03LgmtT3aHv/+q/d9m5uuPXbym0ZM804P5ED4aK8FFZK+lb 6iwGJEfkpnf5SHUKI1ifmY49uBxaz85+6b4QnN12I/m6p8ocmKC4B8jrb9NRx0dQyaGo VX84YTh6aGhJfiiUDqMQRPmRjM7CWD3pn1bcXcsm+gzY6F7jyhdQ/dkzUEi/Uhz0pOOn vC5A42KhvVHDgOyEHwC69DPRyLM7ZBbFDhPwY9KFZBiYOq4vKSbD1uGLG69p0drib6dZ zkPA== X-Gm-Message-State: APjAAAUBYZnCoFAwbGe3S8aDQ+AozdZCZMhDr5WUaXHdg6PPkRpAglO0 82mUjAgGO2LIk7gJWsnooS91oAosJ1+z10iQ6dizpA== X-Received: by 2002:a63:5402:: with SMTP id i2mr88751122pgb.414.1564611431661; Wed, 31 Jul 2019 15:17:11 -0700 (PDT) Date: Wed, 31 Jul 2019 15:16:06 -0700 In-Reply-To: <20190731221617.234725-1-matthewgarrett@google.com> Message-Id: <20190731221617.234725-19-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 18/29] Lock down TIOCSSERIAL From: Matthew Garrett To: jmorris@namei.org Cc: linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, David Howells , Greg Kroah-Hartman , Matthew Garrett , Kees Cook , Jiri Slaby , linux-serial@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: David Howells Lock down TIOCSSERIAL as that can be used to change the ioport and irq settings on a serial port. This only appears to be an issue for the serial drivers that use the core serial code. All other drivers seem to either ignore attempts to change port/irq or give an error. Reported-by: Greg Kroah-Hartman Signed-off-by: David Howells Signed-off-by: Matthew Garrett Reviewed-by: Kees Cook cc: Jiri Slaby Cc: linux-serial@vger.kernel.org --- drivers/tty/serial/serial_core.c | 5 +++++ include/linux/security.h | 1 + security/lockdown/lockdown.c | 1 + 3 files changed, 7 insertions(+) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 4223cb496764..6e713be1d4e9 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -862,6 +863,10 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port, goto check_and_exit; } + retval = security_locked_down(LOCKDOWN_TIOCSSERIAL); + if (retval && (change_irq || change_port)) + goto exit; + /* * Ask the low level driver to verify the settings. */ diff --git a/include/linux/security.h b/include/linux/security.h index 3773ad09b831..8f7048395114 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -112,6 +112,7 @@ enum lockdown_reason { LOCKDOWN_MSR, LOCKDOWN_ACPI_TABLES, LOCKDOWN_PCMCIA_CIS, + LOCKDOWN_TIOCSSERIAL, LOCKDOWN_INTEGRITY_MAX, LOCKDOWN_CONFIDENTIALITY_MAX, }; diff --git a/security/lockdown/lockdown.c b/security/lockdown/lockdown.c index 22482e1b9a77..00a3a6438dd2 100644 --- a/security/lockdown/lockdown.c +++ b/security/lockdown/lockdown.c @@ -27,6 +27,7 @@ static char *lockdown_reasons[LOCKDOWN_CONFIDENTIALITY_MAX+1] = { [LOCKDOWN_MSR] = "raw MSR access", [LOCKDOWN_ACPI_TABLES] = "modifying ACPI tables", [LOCKDOWN_PCMCIA_CIS] = "direct PCMCIA CIS storage", + [LOCKDOWN_TIOCSSERIAL] = "reconfiguration of serial port IO", [LOCKDOWN_INTEGRITY_MAX] = "integrity", [LOCKDOWN_CONFIDENTIALITY_MAX] = "confidentiality", }; -- 2.22.0.770.g0f2c4a37fd-goog