Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp4544568img; Tue, 26 Mar 2019 11:29:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqwep/tfwwUgjIc0y89D0GHBlRhnF5fpRhu7XzMb5u7x9t195YX91nBMW9STzoODDPYD6/cT X-Received: by 2002:a17:902:aa87:: with SMTP id d7mr31653475plr.146.1553624996684; Tue, 26 Mar 2019 11:29:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553624996; cv=none; d=google.com; s=arc-20160816; b=eutKiGQqdBgbL7eWn6KUIHFpfCXzVgzfzcE9yZTLh6nd9nx8yJWCFGyZql3PKV4oUP E+sGYxKxpCEli3J/EXIh/E91cAh5UNefi2Z/Ho25QnG+k1taBbnPWhL42s5pkEDbDY/z ZmbyptPPE55OlVYaJ5dlrHbu4RWJ8kXLavhIDdrC5Hjd1sQXQ+G5vAljDx3FB7XVFAVa n+m+0CG7JR2ChHVSX5S7c6wtbY3D+K9drEcW1UitIYvqJHNtU7ZsRxuqSIqO7cyTD1/p GACJmvX9M1/4menaPDpU/diCt/SFmbb7kQicRelbhKE6i7/IArSGWxXSGobL3azTABk0 PPZA== 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=h9EnFy04jMHVM1ZMNH2nx3A+bDTELFHTwxmLElxP71o=; b=REGbQeOhyeo+JrbK3qiiZNumlBniWYlCA8GC7MhQuoCbyVUO/kXCj5HqjfYjOxtp7J Z+sKS/u50CGESEfP3QzUrv2QSrX8cVj1DJO99Jt+m+Sk0YN9V/0ZMgNwZXxxVG0TxYwr DEAZ+uwsO9ueRq6rQPNLgOeTXgcP2P3CwhdFQ1pC+sAQWxaWYvO/s01XMsvIlzdp31Xe SbC4r1XGks3DWYX5rp6GT8rX+/8GKHVSabAdozrICNqihCS13W7c5ryTodwd4CTAMHRb lhzeJj/O8JXIFISEyr9Kaazu7DkdCVj9xZ3r8XE1KWS2PeIRddhVXtTrg2JQheOPgcUH +MZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Z7k55eRQ; 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 h1si16691144pfb.276.2019.03.26.11.29.41; Tue, 26 Mar 2019 11:29:56 -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=Z7k55eRQ; 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 S1732803AbfCZS2k (ORCPT + 99 others); Tue, 26 Mar 2019 14:28:40 -0400 Received: from mail-qt1-f202.google.com ([209.85.160.202]:37946 "EHLO mail-qt1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732784AbfCZS2i (ORCPT ); Tue, 26 Mar 2019 14:28:38 -0400 Received: by mail-qt1-f202.google.com with SMTP id v18so14455736qtk.5 for ; Tue, 26 Mar 2019 11:28:38 -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=h9EnFy04jMHVM1ZMNH2nx3A+bDTELFHTwxmLElxP71o=; b=Z7k55eRQRYGcZah8QOHEIlHkH8KCl4gYI7fGrsmv4pyVRN2TE0VQxMVCfKBoCJFYcV kvxQC/SOAqFtnWiz6XNtEHDlp0wdjYRXLoWdNGYNtazGpr1wIYh7W9UzmDh5iZf7wwKM bpBIXO6ymj34WPya4v+dPjhxdGs93VkG7jXgcc7DLXNfHMLrPcWGD1nX79BWUY3qY48s DgpRcNhmY8ZJAqANIbasB7lKFamqPuXlJZNJNd40vPj/fgZvScq0VExRxburPO3qk/JN 1PtAOp8+Mk7977nxUVBg5Z6w7LvRhumrO/NQ7JKIlm0NMH9sDbothKVECbiaIBhj6xzz yUIA== 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=h9EnFy04jMHVM1ZMNH2nx3A+bDTELFHTwxmLElxP71o=; b=hzVTD6tsM6RSNaR2cFrHIws7X55KDgv1e4OMIsDCL4Q9oRAEmZufKdt1BXf2vNVYjI ol59BAI1xfgR0rCd4Ia/iuC4udQJySNz04U0b9AOUdscPRRzMIF/w4XEnjmlnEJcq401 BvDSOudZ1T5n91Up0QN2erZy+QipHnV9bgCUX8R6n913HydGNfvpkt+bTnuJA82CBXQG tCTaCzFeH/d+PuB6aDV/R7s8BDaMuXsPMByJCI6p1icIUsoXA6/rnSba1JU6AbqXh/pj z5fWsT9AuxZfXHCAgLgf6/5jXyJcPO38JMNTD4IeXEPxHH5LJBeGaXL8qAnIf6c2jmJ4 5dJA== X-Gm-Message-State: APjAAAW8YLukkON1DyOrU+DW1pDD8NrUb0ugawQn8tTLEVkWm6jIHd+z hpOsVZK3xNqmUvCxmsRcYUqY2flbDpHETP7hCg4UJA== X-Received: by 2002:a37:a797:: with SMTP id q145mr2953780qke.292.1553624917716; Tue, 26 Mar 2019 11:28:37 -0700 (PDT) Date: Tue, 26 Mar 2019 11:27:33 -0700 In-Reply-To: <20190326182742.16950-1-matthewgarrett@google.com> Message-Id: <20190326182742.16950-18-matthewgarrett@google.com> Mime-Version: 1.0 References: <20190326182742.16950-1-matthewgarrett@google.com> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e-goog Subject: [PATCH V31 17/25] 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, linux-api@vger.kernel.org, luto@kernel.org, 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 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index d4cca5bdaf1c..65b67f0d4386 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", LOCKDOWN_INTEGRITY)) { + retval = -EPERM; + goto exit; + } + if (!capable(CAP_SYS_ADMIN)) { retval = -EPERM; if (change_irq || change_port || -- 2.21.0.392.gf8f6787159e-goog