Received: by 10.192.165.156 with SMTP id m28csp935097imm; Wed, 11 Apr 2018 09:30:49 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+Vyjqz5fOcvx6DWKJBXmkweSKup3ci1+BqosSJbQRL4JHRjPsehmtIYAF+mW2EwzXzTHhf X-Received: by 10.101.89.6 with SMTP id f6mr3885317pgu.178.1523464249245; Wed, 11 Apr 2018 09:30:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523464249; cv=none; d=google.com; s=arc-20160816; b=J01lgKvJpKU8R6N9WvwrP2Hp3jGT+BLiumlZbcckvyLn6ioyrACAi3W0Z/UZLqY3xz XPuBiQJGxZSEiQ6FscZHkr6S2/JnHKyMIMSFpy0dustRL0p3M4E1RqclcHrehtuz+y1T 4pqE7Uns/rWZZxf3gd9SwS5p204z0zfNXa4dEm003NpH+k9aGIaQvCmGGSlLpOihvZt+ qqleyD298wvvoPOUHQ0lbko0jiG1RlMQvvSnxXJBZ2KbHBRSyauaKK8bQw2p5FxXaDAS 9iOGtTXM8N3OCfRYQQZ0vGCPCLQMgdERdFder0LFQNz4ITKlbC6e3zo97SqCwPb2XRkM BTSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:organization:arc-authentication-results; bh=b8ikhAim71fyng5KIS7pUMpYhOqxHScrJI9/+XVak8A=; b=Zg3J0Y2Ed+aLVHPH9QjHEDKjfdzCjKYr7P7T37c75ESLR24K04cpthpN4/qAIoF4vz jeFbgkE2ZH8F0ku74WqIf4p7eo7j+jk/U1BJ0jkrilJ+gh53nR7QjPfRCfl+PWA0+8n+ IBMf9C7JC63ziSeB3dUzcp9nIqljMdQDRMSwVbb9HSYN59X2PLWsE4aR9Cab/FoRtCNK Txd98Sw3rlxtdZKzHCb7DfcQD7SV6z3KLAOzRKdqqbEbihIxk7NP1ZrEVdd4j8FUEBse MlmV0VJocJtsgRhGMY4sQUF6n5/OKBr7U1lChmFyILEutob4EIpGNElu8/zhPOy64Dl9 0EaQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q13si964908pgr.405.2018.04.11.09.30.11; Wed, 11 Apr 2018 09:30:49 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754267AbeDKQ0f (ORCPT + 99 others); Wed, 11 Apr 2018 12:26:35 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54078 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754248AbeDKQ0b (ORCPT ); Wed, 11 Apr 2018 12:26:31 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 246EB400ADC6; Wed, 11 Apr 2018 16:26:31 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-120-8.rdu2.redhat.com [10.10.120.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4D235215CDAF; Wed, 11 Apr 2018 16:26:30 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH 17/24] Lock down TIOCSSERIAL From: David Howells To: torvalds@linux-foundation.org Cc: linux-man@vger.kernel.org, linux-api@vger.kernel.org, jmorris@namei.org, linux-kernel@vger.kernel.org, dhowells@redhat.com, linux-security-module@vger.kernel.org Date: Wed, 11 Apr 2018 17:26:29 +0100 Message-ID: <152346398983.4030.3726814688073404489.stgit@warthog.procyon.org.uk> In-Reply-To: <152346387861.4030.4408662483445703127.stgit@warthog.procyon.org.uk> References: <152346387861.4030.4408662483445703127.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 11 Apr 2018 16:26:31 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 11 Apr 2018 16:26:31 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'dhowells@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 0466f9f08a91..360f8e4416c4 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -829,6 +829,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 ||