Message ID | 20230928221246.13689-6-LinoSanfilippo@gmx.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp3664040vqu; Thu, 28 Sep 2023 16:25:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFFMVT6tPbJykdNzPXtx3MVnp5AMSV1Zk3VTIeL/YxLI6jTk1bnNLE2dfkswcD0mk+uiFVo X-Received: by 2002:a17:902:cec7:b0:1bc:1e17:6d70 with SMTP id d7-20020a170902cec700b001bc1e176d70mr4640676plg.24.1695943502213; Thu, 28 Sep 2023 16:25:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695943502; cv=none; d=google.com; s=arc-20160816; b=t0WirquVjetT/GeDVNhwU8xcxJpbVXjeWcj5UnXqS0wmlGbUEklaEGaKyfhLn+iPrY /UPHwAbtpNATRzuqwVM5wWnsCZT7W0CzS2NptF+GlfGzm2C6DKaU+uNO5g5r3/m0HxPx SMeZUEKRwvYdrZSuoEIch6Fs1C+pKAJT6tsnaMV+BxyDdlcDY8rLrVoZMe2QSzLomn/P 6trsn1Sfps6WxQIr36kXSaRpUg3YEZKWD/W0cEdbDlWrFGIdyzxsna+/X2onUTIg5SU6 Z7Rns0D7ThPAUg4Niwu64pyMFQOW3sKigLJUI6D1KR87+m3r0GQonzbzfjbAxueu3ZVh PM3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hg8w75pV0e3pjbzQLJFWM+TM+iujlrT3Ta4nBCXoDzs=; fh=SKJaSS2M7npxXGrfckcylXltvqohHYqDZnbS6Cca1co=; b=lpNAKgnyi0KowkTeEGX/d2fMOPkIXmHNmwIy/uRQxdNSfcHvbdn6RDh2hPjJIRekTg AiwOT0x89ZDAms0Ad5aXDG//kSQhoekYAdzMhKnuoV6KXzAY076gYhrkjNqYpsDQraXf wqwZ8CkXb58B5nwp6ub04nnW9W60cvVuHeayaliDSTMofC96bX2jVsV3ghFmJvrryJn2 SZhvrCiuOfKb+aVsdpcGj9N0vEqPoegh0cVO8YI0Bc9dc7o9EkSwPVQvaEaPI5xyxPuE T9H51/s5sjWZegDR74+zeZcntAeIaehzkfKjPrMshsRKrC1wfGdvWN+Dt72S3aecMFzr 2nBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=im686yKF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id x9-20020a170902ec8900b001bf0b29d935si15367841plg.34.2023.09.28.16.25.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 16:25:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=im686yKF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id CF21082F7FB7; Thu, 28 Sep 2023 15:14:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232651AbjI1WOI (ORCPT <rfc822;pwkd43@gmail.com> + 21 others); Thu, 28 Sep 2023 18:14:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232570AbjI1WNx (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 28 Sep 2023 18:13:53 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53DA91A3; Thu, 28 Sep 2023 15:13:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1695939214; x=1696544014; i=linosanfilippo@gmx.de; bh=hg8w75pV0e3pjbzQLJFWM+TM+iujlrT3Ta4nBCXoDzs=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=im686yKF1Pr+8T9GT14YLKy2cCDauXeY+iT4ymje2THJJk7u9j7Uge8hyl3oEPMXJcAauQXmX91 AFDdVBb+GoRvcxTu/8Z+/sZWdYpJAuDUDLs8l3ZvEraTB25HeE+c2zKZpF16a+M8o002ZDwgXpKF7 nD3wPOHaLK+Y77jsEUGDMtf1hyrplNC9fCPi5ZmogKhgyzM+OG8C+CvHJjqWRd4EwiPuFDsmYp5Pv an0H6Og+HttTsjmC2b5ZvdzO5ffeXi3N5gRW7bTNwoo307Yvze2UNCOeFZDOPialnUFOSH0v8ZtV4 dgX33wM8Hq/ad5/AQUZ3Th2972O37BdVsZqA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from Venus.speedport.ip ([84.162.21.41]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1Mi2Jn-1rGM8d0T8j-00e39X; Fri, 29 Sep 2023 00:13:34 +0200 From: Lino Sanfilippo <LinoSanfilippo@gmx.de> To: gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: shawnguo@kernel.org, s.hauer@pengutronix.de, ilpo.jarvinen@linux.intel.com, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, l.sanfilippo@kunbus.com, LinoSanfilippo@gmx.de, lukas@wunner.de, p.rosenberger@kunbus.com, stable@vger.kernel.org Subject: [PATCH 5/6] serial: core: make sure RS485 is cannot be enabled when it is not supported Date: Fri, 29 Sep 2023 00:12:45 +0200 Message-Id: <20230928221246.13689-6-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230928221246.13689-1-LinoSanfilippo@gmx.de> References: <20230928221246.13689-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 Content-Transfer-Encoding: base64 X-Provags-ID: V03:K1:Od3l4xl/uII61q4WCOzbzrdpV4WzfRrpfpwW+63udSex6TYzbGi Yxm3kzO8B0/p69CY6IbF6VIwdpcOC33Yh2uLfiUs2hUzzB+NvbzOW9K2YruY4zacovT56Qp wL/RFiJJTxVqsTJyhS/Yoo3m+FZdjOkPZDyRzr8yEqSw7cWa5e5YcWFsyzcAe3qXgQ3pum4 pHQH9QaYtUL+pSUgFKF2Q== UI-OutboundReport: notjunk:1;M01:P0:RERU25vI7eg=;t4JI+TeEd/T7kk73bmESiZA6A3d e+nOfxVI8YqeYeQsHbIdBiVKShltFe6hCz0O3OHfJUgXga3s/L/1+YxP2bLkHWLgUmG/OT1mS 85HokF0MpWKcS1GPpiR5M9N/RwrKRtcWomL73hBQrIldlsLPCqH1hVpi7EI4Ty2kvzszI4frv RMic0di7sMBEKE/eZCC253W2uYY2438RJUUt5LOC13TqXEWWiuJdNEIvfC/HklzfBnQjuBokM a2nhL8W1DWZWAy/dPzKx7gHIP1XoT5ErCk6Ko+MgNRPiOqHHVrlKAapbTM2iAMO5HmeBHnEQx /jVqJfUan0e9tCw6ZYyfU67qrJu02q8E8x7D2JlwT7IB9h8dN6F7aRamWD8VWgD/0zjTa0LUG Bjs3XcSdH8btnkAkkrzZuVW7vGQH0AiN/QPkATOhmC8jNwX0NDxqgME0wN4v+NX38w4nrTg87 oyuwiZxDz1Cm0OlTRN1yfChU2qhpZ1H3BPtbQa4N64U/VXO6KHuDqExNpc+3Yig2pW9VZVN6c 7YCHKmPLq1Ptitz8p4S+4S2zY8IR0MAGcwB4uXG6PqIP9i3fFaxF7PqRdGSQuZrV/WRH/wNeZ zkhChi6kImrBx1ca/O1Sr4k2dUQpS0cLinZELGozGoG84xw+RpGncvtNhA5nqlIAl6YFu6kdY FUhi4JyEUY8GP79ZBl5xoD32lMEu8xrxvYfAHPgZ37dR06CT5nDCiciui79BEatfS4dL2gmdS m5X/UEkJzAbJiqumPWeHL4IHArpH6xpU3PsFUAyWo+LvmfLGU5WYj6MH0PNEGTI75OR01Gmel ncbbCyKwiEUjJsXhjAmpX/H589Sh6U3p8ucbCmxNT3yvVKmPH5jTCbVZ2kPmQP9Q0Gd6aKlV+ cC7Og39gUqsA3fr810DFj5a0P/vahgn67Q1dsAS3amoamgoi+/mQI3V66s+Qk0IC6m2Y6hUTg oxM+XA== X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,MIME_BASE64_TEXT, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 28 Sep 2023 15:14:18 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778325653407771455 X-GMAIL-MSGID: 1778325653407771455 |
Series |
Fixes and improvements for RS485
|
|
Commit Message
Lino Sanfilippo
Sept. 28, 2023, 10:12 p.m. UTC
From: Lino Sanfilippo <l.sanfilippo@kunbus.com> Some uart drivers specify a rs485_config() function and then decide later to disable RS485 support for some reason (e.g. imx and ar933). In these cases userspace may be able to activate RS485 via TIOCSRS485 nevertheless, since in uart_set_rs485_config() an existing rs485_config() function indicates that RS485 is supported. Make sure that this is not longer possible by checking the uarts rs485_supported.flags instead and bailing out if SER_RS485_ENABLED is not set. Furthermore instead of returning an empty structure return -ENOTTY if the RS485 configuration is requested via TIOCGRS485 but RS485 is not supported. Cc: stable@vger.kernel.org Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com> --- drivers/tty/serial/serial_core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Comments
Hi, remove superfluous "is" after RS485 in patch title. Hugo. On Fri, 29 Sep 2023 00:12:45 +0200 Lino Sanfilippo <LinoSanfilippo@gmx.de> wrote: > From: Lino Sanfilippo <l.sanfilippo@kunbus.com> > > Some uart drivers specify a rs485_config() function and then decide later > to disable RS485 support for some reason (e.g. imx and ar933). > > In these cases userspace may be able to activate RS485 via TIOCSRS485 > nevertheless, since in uart_set_rs485_config() an existing rs485_config() > function indicates that RS485 is supported. > > Make sure that this is not longer possible by checking the uarts > rs485_supported.flags instead and bailing out if SER_RS485_ENABLED is not > set. > > Furthermore instead of returning an empty structure return -ENOTTY if the > RS485 configuration is requested via TIOCGRS485 but RS485 is not supported. > > Cc: stable@vger.kernel.org > Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com> > --- > drivers/tty/serial/serial_core.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c > index f4feebf8200f..dca09877fabc 100644 > --- a/drivers/tty/serial/serial_core.c > +++ b/drivers/tty/serial/serial_core.c > @@ -1432,6 +1432,9 @@ static int uart_get_rs485_config(struct uart_port *port, > unsigned long flags; > struct serial_rs485 aux; > > + if (!(port->rs485_supported.flags & SER_RS485_ENABLED)) > + return -ENOTTY; > + > spin_lock_irqsave(&port->lock, flags); > aux = port->rs485; > spin_unlock_irqrestore(&port->lock, flags); > @@ -1449,7 +1452,7 @@ static int uart_set_rs485_config(struct tty_struct *tty, struct uart_port *port, > int ret; > unsigned long flags; > > - if (!port->rs485_config) > + if (!(port->rs485_supported.flags & SER_RS485_ENABLED)) > return -ENOTTY; > > if (copy_from_user(&rs485, rs485_user, sizeof(*rs485_user))) > -- > 2.40.1 >
Hi, On 29.09.23 14:17, Hugo Villeneuve wrote: > Hi, > remove superfluous "is" after RS485 in patch title. > > Hugo. > Indeed, I will fix this, thanks! BR, Lino
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index f4feebf8200f..dca09877fabc 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1432,6 +1432,9 @@ static int uart_get_rs485_config(struct uart_port *port, unsigned long flags; struct serial_rs485 aux; + if (!(port->rs485_supported.flags & SER_RS485_ENABLED)) + return -ENOTTY; + spin_lock_irqsave(&port->lock, flags); aux = port->rs485; spin_unlock_irqrestore(&port->lock, flags); @@ -1449,7 +1452,7 @@ static int uart_set_rs485_config(struct tty_struct *tty, struct uart_port *port, int ret; unsigned long flags; - if (!port->rs485_config) + if (!(port->rs485_supported.flags & SER_RS485_ENABLED)) return -ENOTTY; if (copy_from_user(&rs485, rs485_user, sizeof(*rs485_user)))