Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3353989ybl; Mon, 19 Aug 2019 17:20:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqx57tVXKwIoGMD+rUSAES6gVUBOIDIJwL5v2ecBuip3/Rl6ahoJlE7/IWsDFwGucaCq5Xlu X-Received: by 2002:a62:2603:: with SMTP id m3mr27979347pfm.163.1566260431904; Mon, 19 Aug 2019 17:20:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566260431; cv=none; d=google.com; s=arc-20160816; b=TrKOd7o145ohac5xpsrHBidoTtjwBUJydObiHjo8AmYG8cDe02CSAEeh/ihA7rEfwr 18Td1uX0VgZBh+jjJSg2NC4UkxUtgN02JSdlAkSo88ZQJNI7Iw4lB5V053LLRlMTlfcU bjNn1Q3L/5WJhc16Gx0jaF6N+IeGvF+/OMvaTA6yhmk748LI/UFLxataBEwr34RMypxj 1kCdn4odkEVL55DZ4UWJpM/3wFaUCq8AjqN99qnzinuCNnzSyWXry4kYlTRAuVcTcIY4 yqyV4+gN6cSQFWvDjyId5E05tfc6auvATi5HEgi5z4aJKJv4FMj6jJBOuc2dFTWpMg9l R/xA== 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=lNoz89i9XS2jvvI1H04tt6HZt6/wgDBv5mdC4YvRgGk=; b=eoRTl92uJpgyDauV8FgoabnSgSO86Jfj6JSpzdL4IwpoG9oA0QrThmdrh8+9t+a+wV k49lgwY8b7XUc/vZwDVGjZTXdZ+h0IXJSi7iaxgPHu/5man2qF9D/hrU5n04CQ4wG6xQ Mt88Xs9QzxZyX8OY47JOTCF3+jS0MgEqnImKumzsfnIHFSVqguqyT9QNp/JGi+sWY921 Sre5Fv19AMLbosv6uNNEPl4eAp/yYUS9tMMlNLGg1a+6O1nhThwLM27RpnNWM837j6fY n80g1t+qMRLpAYKRJgPAdQPfMfMZMttlle+q8yiOTt0usVLZ58O1sZ8znM/udzFKFzte VUAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=FBD5OFSB; 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 35si11116981plb.24.2019.08.19.17.20.16; Mon, 19 Aug 2019 17:20:31 -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=FBD5OFSB; 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 S1729114AbfHTATA (ORCPT + 99 others); Mon, 19 Aug 2019 20:19:00 -0400 Received: from mail-pf1-f201.google.com ([209.85.210.201]:39259 "EHLO mail-pf1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729102AbfHTAS6 (ORCPT ); Mon, 19 Aug 2019 20:18:58 -0400 Received: by mail-pf1-f201.google.com with SMTP id n186so3528191pfn.6 for ; Mon, 19 Aug 2019 17:18:57 -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=lNoz89i9XS2jvvI1H04tt6HZt6/wgDBv5mdC4YvRgGk=; b=FBD5OFSBztcf1k/51yy5DB86+s8rw9puUZD6jZa+gn00sbyPgW3Ca0yt76jHjBLaWd PPeVOeQ8TwSoDnE0dwd+ZCKNK6cOwphc74rNO9sgjC1iQZI1Jl92bGpvNWtFi4fuKOj2 6Rngiw0Sz76EbPcal0USv8Nw1V0Agsl9zSKmPyCM0oBA95rkaoEQV+e1VO2kt3P2/yJL jGoxg4yUtoUfeEgJ4B14T8lvK9E+mdU7C8r+d6ONqm3EwVORHnkHlFIClokihAxqgJEm xpSmqe1PBlBbPE65vrjUiLRVfmhAZPPx3GYV6c+daZ2BsdAq6TrSrf/295j/9pfAAiPu SWgQ== 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=lNoz89i9XS2jvvI1H04tt6HZt6/wgDBv5mdC4YvRgGk=; b=oOvvWjWd6Ohfpr3ET3ZeF1NltdUPpEQbSTTxRfn2/QodQoh9pPfewOyaGkEf1/nWDg 2dI0horbmsuFKDuFw1LifDt2ZbbNLVA9aB7ghWreVbnlsHf9jALi8kHUuIlQWc5j6/DN xWA30scK+LNnkL75NsIa30WvhrrdZKh54nqfLAVHWIhFn9mpn44wSAgmIEihf7SdNkPA iv4ww0N2HVqhfbWTQ4RIHSNVmV4BaZ8E8AKzOkJyB9qwIfsikcXUY64FSEFjmbmrKRkG pg1ThYjXaiXb+1CGRCIXEXb61d6wMkp1RlkP0xhscpyOm5s52bJTufeMbu/Aq7Ycb8Yo S+vQ== X-Gm-Message-State: APjAAAWNR3h/wT8VKBZ5u+PsQybfg9UDR1BimQhox0a7Qu5Rnlq7aOwU coGVxNGZZHr2s302s2zxuxTpxlo2o9UxGNAgQRlDsw== X-Received: by 2002:a63:6888:: with SMTP id d130mr21330152pgc.197.1566260336938; Mon, 19 Aug 2019 17:18:56 -0700 (PDT) Date: Mon, 19 Aug 2019 17:17:54 -0700 In-Reply-To: <20190820001805.241928-1-matthewgarrett@google.com> Message-Id: <20190820001805.241928-19-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 18/29] lockdown: 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 Signed-off-by: James Morris --- 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 83f4dd0bfd74..bbad407557b9 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 683f0607e6f2..b4a85badb03a 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 db3477585972..771c77f9c04a 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.23.0.rc1.153.gdeed80330f-goog