Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp4528538imb; Wed, 6 Mar 2019 16:03:14 -0800 (PST) X-Google-Smtp-Source: APXvYqzt7Afu6Z9QI9FIU80fYnhRrFTZlcfjMJDUt1gJ0d73It6O0IPn1o1pbsEP2+cGe0f5Jwoz X-Received: by 2002:a65:4844:: with SMTP id i4mr8457848pgs.347.1551916994089; Wed, 06 Mar 2019 16:03:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551916994; cv=none; d=google.com; s=arc-20160816; b=xWPfnIKNSi5waXH2qoyFpnuaobe3tMaERldPm9hRnCZ6KtajNPprloxte07WnPCl2U Msp/icE09lcTpKmPU4nq+aRxsmHKfK35d63pzQKHaIxBFlDDC5qwqvaWgQuS9zIgSjKm R/XoKms4jw5HANChr4ely+qlrlPEzO4she1928kK+Q8pW5MCcRLH9lgFVcm6Ijo70EP8 ZNaiLqrb7czfpn+r/beTf4dFDMr+t6fRub802kk47Eis8fSpHEvZGR3tllbAPeEqmkGB aCnrda7O0IgX4zBBOgctA+JQH6Ia18E0qfFBuPGqpZdl65ufahPQu0pb7Az/szHl/9n2 AkdQ== 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=e2I9s9eqW/pXhDtnWHYZKjtstIRBgNmOxa3j3Xgurck=; b=TdcAZ2kqCq6sSKDr44c15w3DWzhJdyoTqgQNxl39RthUmNHBj1hRtFp45Pw38aEU2b opsAGb0AdgY5TOB5wdx5YiDeDsesijQpxWVjCqvvG1PoTHg8N02X9BY6ErFmPEslPuYE PHjo08uF1Wal+iVAa90ETjovZogHv/+V2eBYcHh3NcEg0jZXfZmHVjCZ50LSztT6oBF1 2sdmkXpsucF2gCD50QQ8I/4VLS6tMCy+onIhihiWv5XOSlUx4kqQ56ShBJ9FJwJLX+rn CESxYBiVaIOsWEt7JoCElUu3ogUxKuT/qTxLof7cLlLTJs9Y1JMuI2ZOL6Y9epEs0ovo yc3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=v0tBa2sQ; 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 v35si859685pgn.113.2019.03.06.16.02.58; Wed, 06 Mar 2019 16:03:14 -0800 (PST) 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=v0tBa2sQ; 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 S1726651AbfCGAAT (ORCPT + 99 others); Wed, 6 Mar 2019 19:00:19 -0500 Received: from mail-vs1-f74.google.com ([209.85.217.74]:45442 "EHLO mail-vs1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726636AbfCGAAR (ORCPT ); Wed, 6 Mar 2019 19:00:17 -0500 Received: by mail-vs1-f74.google.com with SMTP id k17so1512552vsm.12 for ; Wed, 06 Mar 2019 16:00:16 -0800 (PST) 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=e2I9s9eqW/pXhDtnWHYZKjtstIRBgNmOxa3j3Xgurck=; b=v0tBa2sQbOTLb/utAQ2jny2osFBJ/ZHvmthqYWL8mOmUeYd3yB3hOM9kXvC58IMMKc iVeQ1IpvYNjWwnQllc4Nd3mLWcxLuR1Xpp0LYZk5Nz0pdJWgwOPXwb0BmboZwisQ2fBU ykU8Abjk4JdNj7+gWWyzdjcA9tSZSIcDOagC6sb+4jlYIXSTAYR5Qzk6U3w7WzxOoUWi iTAnXLEUhWL4rwGZQsFEpYE5MRfIs7KSC5mxtEhOz3tRConSFneIBvZ26r0n0P4Pun5M OkQnYbfX56BwMRQl/la7dXKkpI/h2zE5PLHg44xE128DgK7eVWqvGZblKSbyKV9stUhJ tRmQ== 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=e2I9s9eqW/pXhDtnWHYZKjtstIRBgNmOxa3j3Xgurck=; b=joLCT1xIS4+YTx7eMNbHUFde7r3pM3fGNYXXn3eW5GbSq0mbvxkDR5RgPCLDC6LMic k5aZysYWO7/sJC2ORW9vLjp0TfMMvP1hTn0XiMTX2bC9UZ/13+YrEtGkEw/N0X1p123G sTg4Obow4qPd8Qb6izY7db9uMaiSLof9f6F7+lo2ub1AxS+BVbnZ9qljd9KlzzXoihgr i92oqbk8U1rTjbrqBzB6aUBGkRITQ3TKFQFY8dVqdNHt/KNZpB4pPQuzaJ3FqYPh+/qn taOH0rEtbAIMkAg/8SeuTFZ4s3Gav5lD+rYFmb2J+gAyFM9izlO16d4NmD0pNBTADH6n 2OiQ== X-Gm-Message-State: APjAAAXzalg9/IObEG1ZWCOVoBb6I4Yb3yUkii/BHmEH/stTWuEgzyuJ hrRVWgBox5Ypzi6ZYwGS373SoqYuOFhqKzsbIlNg2A== X-Received: by 2002:ab0:2495:: with SMTP id i21mr6864138uan.9.1551916815988; Wed, 06 Mar 2019 16:00:15 -0800 (PST) Date: Wed, 6 Mar 2019 15:59:05 -0800 In-Reply-To: <20190306235913.6631-1-matthewgarrett@google.com> Message-Id: <20190306235913.6631-20-matthewgarrett@google.com> Mime-Version: 1.0 References: <20190306235913.6631-1-matthewgarrett@google.com> X-Mailer: git-send-email 2.21.0.352.gf09ad66450-goog Subject: [PATCH 19/27] Lock down TIOCSSERIAL From: Matthew Garrett To: jmorris@namei.org Cc: linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, dhowells@redhat.com 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 cc: Jiri Slaby Signed-off-by: Matthew Garrett --- drivers/tty/serial/serial_core.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index d4cca5bdaf1c..04534877b575 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -842,6 +842,12 @@ 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; + if ((change_port || change_irq) && + kernel_is_locked_down("Using TIOCSSERIAL to change device addresses, irqs and dma channels")) { + retval = -EPERM; + goto exit; + } + if (!capable(CAP_SYS_ADMIN)) { retval = -EPERM; if (change_irq || change_port || -- 2.21.0.352.gf09ad66450-goog