Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1238676ybi; Fri, 21 Jun 2019 17:06:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqwztE3+2yJMbkwv+ajFqlSDu7EWEfv7xW+1G9a820vRek3mmrstR130zaaZ7fGOigHPAhrd X-Received: by 2002:a17:902:b115:: with SMTP id q21mr74336181plr.36.1561162013889; Fri, 21 Jun 2019 17:06:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561162013; cv=none; d=google.com; s=arc-20160816; b=b/0As+/6cnasKdVMZWVWmfgDtaKiGBHn0L+dA2Q5fjmD1OtcXFy60bh7+eUoCB9zPv lzqR56ZtVSqytZNKPogoSLcFvyyzAQdyNkUuMmleZGaiM87HGUMjdvScg7jWutTduB/+ XTkalv3T1GMz056s3ZOBLPunVqcrotzDtj6yvkUilqNLKK8RUBknRYooGXlFXnYM4ImR KDDVrY0lvCvzpzFV5eLRpMEqEYRzBp9lSjCI+deJnbU6Tr/QnkUQNIiFkU1XJGFZmpLB JYs5jDUR+QdV0Ej687GjaJpRiMxsxFPz9caqnv3ctcgYrCAx3TpJrpI9AiekGoD3Vy0g lu0w== 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=7XUJQ2WWQgV+58iwM6R5lnhVlgjpfti3qggxZNIjvHc=; b=bXCNS25/z99XRegHoePUqmXzpUUhwpzd9GP/J8iJGmJottbydvoPJdbeepIYhMddck CfY0WD3o2ACCKkEoNqRdiw2P7DQehmqti+cB5tJOTqOw0c33ew/RaXdAYavUR3L5Tc/m b21oHlx3YqTBrWsZZNJpP8KfTDFJvHGU0tzGaNIfedG5R0kJbB+2Ra9ifCBj9Y2dMTTv SvBNV+6PE+ptq4Tzese3mRUAoLuqcznEZf3cmae6S5o22z/GjorbRtsO8nmhOHtRzqUr GRVL3lAM1p9YXdmUgF6GMPMcoFGWRT4SXV82fKwS08L46m5XrsMyDp6g00FXZAd16kCE UEYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=YbOGu6X3; 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 c142si3937299pfc.194.2019.06.21.17.06.38; Fri, 21 Jun 2019 17:06:53 -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=YbOGu6X3; 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 S1726876AbfFVAEv (ORCPT + 99 others); Fri, 21 Jun 2019 20:04:51 -0400 Received: from mail-pf1-f201.google.com ([209.85.210.201]:33602 "EHLO mail-pf1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726856AbfFVAEs (ORCPT ); Fri, 21 Jun 2019 20:04:48 -0400 Received: by mail-pf1-f201.google.com with SMTP id d190so5328402pfa.0 for ; Fri, 21 Jun 2019 17:04: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=7XUJQ2WWQgV+58iwM6R5lnhVlgjpfti3qggxZNIjvHc=; b=YbOGu6X3QdBGGGe8faHuFUYcFb8svwX0Yxl+CKZAFfrIXqI87gpdCYLkBy1RaGPta6 yrXHUhg6AvScoTY4m1Odo+/d3z9d7LUQVs7GrNeE9mFjrvxC0jFRRG0WFDmeARdHINoL 9EcWj34vMERn+3r+itQyO16RcWcpEpm9Lf6JNPHsvRDe46Q5sI5yk8mvHp3AbTMt9oeY Eovet+DRjjFBtgQyhhJsO/zVZP74OIBcPT7f8KuZ2LtAAHjxLB0tATATujAR/MbaUZZ4 Pm/32Y/fZlVXUWXMUQoLA+3vWhjjyHix9KSTINraPHgkYVJQZgEicVTLVGsYT3pskJn6 egvA== 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=7XUJQ2WWQgV+58iwM6R5lnhVlgjpfti3qggxZNIjvHc=; b=c21PGiSzi82Z1HUmOypLnYpTNVr6KPZRAz+A/Bj9/fEFpkf56xDtzxfW79GHCSD1/d opmRozo8JCNqmFz+KePb4udkxTg4uc9C5Zp7/ebAWsEtXaRz59QU7ahtCcN2+WelMU68 NY1pTqKDsLukY3JY8u/XX0fgNXoNpdej1o2GMn7+vHq4B2MApc3Hjp26rvWYXJoC4SKS +0lhO7NvvU7ZfLT57DMVHT2Vztyp/CwyhXT+q/A1/0c1JExc0brRI7d0uYILdXHacUtW CxTdTBSDd/uK6G+mXh1Qyl0OWbtkKEXPFTxBGBmBEk2IiC4E81IGQ+c2aBd0d5vb6Ea/ MOAw== X-Gm-Message-State: APjAAAVQ+tjDJeBOKXxD9kWmHi544dPdyoEQ74lNx4cvbkcxzm7O8Byx klY4+EGa16CVapt9nSoUs9j6YmYy0LS0uPPppIvRbQ== X-Received: by 2002:a63:f70b:: with SMTP id x11mr21395458pgh.212.1561161887383; Fri, 21 Jun 2019 17:04:47 -0700 (PDT) Date: Fri, 21 Jun 2019 17:03:47 -0700 In-Reply-To: <20190622000358.19895-1-matthewgarrett@google.com> Message-Id: <20190622000358.19895-19-matthewgarrett@google.com> Mime-Version: 1.0 References: <20190622000358.19895-1-matthewgarrett@google.com> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog Subject: [PATCH V34 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 , 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 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 351843f847c0..a84f231a5df4 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 @@ -852,6 +853,10 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port, new_flags = (__force upf_t)new_info->flags; old_custom_divisor = uport->custom_divisor; + retval = security_locked_down(LOCKDOWN_TIOCSSERIAL); + if (retval && (change_port || change_irq)) + goto exit; + if (!capable(CAP_SYS_ADMIN)) { retval = -EPERM; if (change_irq || change_port || diff --git a/include/linux/security.h b/include/linux/security.h index 03c125b277ca..61e3f4a62d16 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -91,6 +91,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 7be3e8fb5847..c89046dc2155 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] = "modified 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.410.gd8fdbe21b5-goog