Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3663588img; Mon, 25 Mar 2019 15:13:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqy9ErgNhVzJNol3Fe9An1UY0P6vnVle+Hy2+far1srqL8G7wvOiEOq2B2MFaX1LMw9NzR68 X-Received: by 2002:a17:902:1121:: with SMTP id d30mr27850334pla.104.1553551986875; Mon, 25 Mar 2019 15:13:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553551986; cv=none; d=google.com; s=arc-20160816; b=d/lIbRA3QpAN63fFOGaxvSLah6p+nJNy+6gAy0pTUcZarRbsA786Xo1wTCscgT+E8+ fvEWPfMrhMfz9VYMQEHvJ+iGf1uTs39LpWZTj4U1K0fUO68EXkA7Fj6UE6WLWMyr8IMZ 5zZD+AAHUFSIo4/6nrTxxlfqNx6FASbMHZ7ZCJ+xlQTiq6tOvZj5RoxclioVZaQyLCdb eDDRRPT8FmKkWU2zXaqvg3bfigCRhquVN8elGGrT2CQshtyt3NV06MQ8anjp/AC+zxQ3 x80YTXSTOtKr98TFwB1OWYCo1i0Pnd5eG2vsJixbhCVbJUnCB4+qqFJsWMkchG6g6b3o 4IEQ== 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=d2w/jghx/Rqm9mT1Z9xpzhe5/Zw0d2YU0UIlwgQoEuk=; b=LeOa8+1yBdB5W7BYg26hGlZ26stzEfNUi4CnQOKSdIILe5W2XpF8lJad26UABJmra4 cVXUEQ7D2gw2+aSqRyqEATvjhvmEqj8Sd3QzObxHPGtJeVB2J2DSgPoQkhwYv8CeOM1Q jDFc7rdr/jWM7ht7RXUskKkaGs9D/unxIyZQShgK+sSiWXNHUMUnuDf2povpyAmZCBbr kdm7cbNurxfYUfysauSRS3J3J878v+iPwyii/T9+ViI3cYzcHzXHO4ZPGZlnurVbvSxq 9nAOWSmsgw4to60taX3ob9SotxGC7yxhOc49jIGJiQo7Pc73tSzNPwk9GR9OCCdwuQ/A mcAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=FrawaBB6; 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 w14si14276722pga.584.2019.03.25.15.12.51; Mon, 25 Mar 2019 15:13:06 -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=FrawaBB6; 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 S1731116AbfCYWKu (ORCPT + 99 others); Mon, 25 Mar 2019 18:10:50 -0400 Received: from mail-qk1-f201.google.com ([209.85.222.201]:40046 "EHLO mail-qk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731095AbfCYWKq (ORCPT ); Mon, 25 Mar 2019 18:10:46 -0400 Received: by mail-qk1-f201.google.com with SMTP id l187so9929603qkd.7 for ; Mon, 25 Mar 2019 15:10:46 -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=d2w/jghx/Rqm9mT1Z9xpzhe5/Zw0d2YU0UIlwgQoEuk=; b=FrawaBB6eN8b4P/bVnjNhs6scGHBTE+TRJi3FQc+Wwj3NMeo6WCD3+HQbjxbbv7+WI wDvx0vr8l5x8DzoI7Tj5mPDrvDE+B/5x/IkMJfAz/BDDG/Xw1MnUdDSmAETbxxPgdsmX VYNfR2jows0dyDzxsN0D5o4jEVaObey0r1uqPlTIw9+c9pUY9s2qld90O2y0Nsj7j2dn T+Bpo74qJ+oGzlbqnocrS8st4xl4QLtcoBL8M5dUotNMJLJ1Fia6RrOf17DILTsA8kZN M6JQjp5NfHLIqjiyEugQs0B+MPF4ooHCAmn4/M9kSptz6VxUATW91wp/wM7IeI0PAiiR 5qig== 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=d2w/jghx/Rqm9mT1Z9xpzhe5/Zw0d2YU0UIlwgQoEuk=; b=ZnMgWgSECFxjTX67Lo3gw75UNx/pWpnQyKTZI6ZIUK9nPeMMVUyHot7ug5HirLeFkN dV4htZ+gt6nZKQFNWElO8dYGkzQYLmd3UKrg1Vh+neR9pfhB0GEcfCpfXMsK923MVlcv TuhgjF+8h/Y662Mre5gjQoaGv89pX8h3WXR5AIb+zd1K5WSzeckC8KZs+SsV2ASoDtZL HtH+4c86tZ9M+29AlANavUZD1+C8Cm5vE89TuAs92Bd4bd6g8VnocBJ3pwISl8MEtY0J zcE95FtuFsbKII8eF1vi77noFdpIwPxitA+QIDAKeb9ciFhAobldAzMLM7cucKhdUxbi G+PQ== X-Gm-Message-State: APjAAAVYMx/nEuhgvpA0nPpURhEVC7cj5ECRI4vK/ZLe3ftWn5DV4sP9 Pd/q5w2H1ilnuo5vnLNfCtSy1vX9q3CnejL0A/WISQ== X-Received: by 2002:a0c:e58f:: with SMTP id t15mr22962206qvm.170.1553551845625; Mon, 25 Mar 2019 15:10:45 -0700 (PDT) Date: Mon, 25 Mar 2019 15:09:45 -0700 In-Reply-To: <20190325220954.29054-1-matthewgarrett@google.com> Message-Id: <20190325220954.29054-19-matthewgarrett@google.com> Mime-Version: 1.0 References: <20190325220954.29054-1-matthewgarrett@google.com> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e-goog Subject: [PATCH 18/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, Greg Kroah-Hartman , Jiri Slaby , linux-serial@vger.kernel.org, Matthew Garrett 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 Cc: linux-serial@vger.kernel.org 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.392.gf8f6787159e-goog