Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5621322rdb; Wed, 13 Dec 2023 14:23:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IE/riHYx30cL+WdU3/NpImVjx081Y1Tz6H4UDotvWV/91tH7p5zlNlBVqt8xlgwskqiRVkV X-Received: by 2002:a05:6e02:b4f:b0:35d:5995:798c with SMTP id f15-20020a056e020b4f00b0035d5995798cmr13231488ilu.38.1702506234214; Wed, 13 Dec 2023 14:23:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702506234; cv=none; d=google.com; s=arc-20160816; b=kHCXemMWJ/zExPUWyZTQAs4/i0aFeM7/2qm0Unv21+hJi/QyOc5oVc/P/0cuQrswXQ 8oOPRzhn5m96YeMJceWE1UUHTw3YKS7IgcnPXqgfN1N9ler6WYpTSU5VKzCtc6fYmn9p G2rPLklyPLRZtrcWminwachDOPOiWacWc/rypIvdM9u269HxtdSyMgw+7QCxJSPIf1Gw wmK/SorDxAj356HKuDpTfJ+Q6TM3/zzUTfzohjMIvjnbyFU22u55lhQIUjvQT4VFUPGb p40mKyYNBYmGl1Os7x4gAEgIq33W6u9fwevOhWyxal5JvJ2b8ErgJ3TU7rsHvNofC+If 5qNQ== 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 :in-reply-to:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=iwkXmo9XnruqwcVXOClccpmrGVndgKFAQIa6z98hjdc=; fh=SkD674BMIGfh2qToS4d/FKmfYwG/SWT/z5iPh3MCh2M=; b=s8nOdyu3hVzpOiLj8UTVdH+zYrN5vzWFtAI8YLtNRBYKkqa/HTVJo03FGgTwmO9aBa TLBEZoOrQTKfDAqx3l4KefrcR3MCo8/PJbLbZ921CmtwoSDhWc2ZVSkRVPGkBLWYUFY3 LDGdXu0z2JLPMmCzsEDdDxqxNmH45sx/n+6uSDVdM2fF7CFUvm6Pd378ecZcOESZV+zH lZ+jtWgSUaikONJqcl+/jKb+dd7zPLwLlxNyJdr6RgpX/zelKsP1XHH1Ier2d0F7nEPs OJoEA9vHpbKIcJeG3Ds2q4XHIhnhF0fvHSuDLlXeYAvd2L9YDHSmbKhUJnSqccuq0jdt QTDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=GJej2Go6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.de Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id mm8-20020a17090b358800b002851c699781si1893788pjb.154.2023.12.13.14.23.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 14:23:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=GJej2Go6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 949938031D4D; Wed, 13 Dec 2023 14:23:51 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230004AbjLMWXg (ORCPT + 99 others); Wed, 13 Dec 2023 17:23:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229772AbjLMWXf (ORCPT ); Wed, 13 Dec 2023 17:23:35 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB6D09C; Wed, 13 Dec 2023 14:23:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1702506186; x=1703110986; i=linosanfilippo@gmx.de; bh=DQ7xBBQCgcshkcRM262ggbnkjqtSZ6ncm89KuR3cYt0=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From: In-Reply-To; b=GJej2Go6lh4QHv8jJwR0EdstE3FwpWKqBmk6Jo47z1QpK8QJ4D980XgbFTeZo/C1 8Vp+yN4P2uCp+8TQDSm2dCveGp47KDflGeW2Q8IFgd+lF33OOGT9nU1HnppKQK6Td GeeKuaOiyPIxziGdex9PW543G8tmC+I9JBgxS8BiGGLq2Lr0o52kUP3aV8md+TMJb tbxtQtyFj7UpKPcZq8RNpGBoMfJpWyWbtdw6h5a1flXBLqkIERCWAYzIyp4TIBKbT Duh6SX5+Gr4pbmj+m3H2e5Id6SpnFzBWcSHLjRY5FAqm6HcQwOXCRvb9qgEobSBGY kktoK3+ud+mMVwkXlg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.2.42] ([84.180.3.177]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MfHEJ-1rg0cz1xVr-00gmKJ; Wed, 13 Dec 2023 23:23:06 +0100 Message-ID: Date: Wed, 13 Dec 2023 23:23:03 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 4/7] serial: core: make sure RS485 cannot be enabled when it is not supported Content-Language: en-US To: =?UTF-8?Q?Ilpo_J=C3=A4rvinen?= , Lino Sanfilippo Cc: Greg Kroah-Hartman , Jiri Slaby , u.kleine-koenig@pengutronix.de, shawnguo@kernel.org, s.hauer@pengutronix.de, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, cniedermaier@dh-electronics.com, hugo@hugovil.com, LKML , linux-serial , Lukas Wunner , p.rosenberger@kunbus.com, stable@vger.kernel.org References: <20231209125836.16294-1-l.sanfilippo@kunbus.com> <20231209125836.16294-5-l.sanfilippo@kunbus.com> <5a1f1e87-38c8-7f0-35bf-689ceff844ba@linux.intel.com> From: Lino Sanfilippo In-Reply-To: <5a1f1e87-38c8-7f0-35bf-689ceff844ba@linux.intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:p39tPFUa/8fO6Ycej9GbAUfZkBZXy6SSkJUWOqMehm4VB+hSPL1 QJaahOi7vSMYCcpsNhpzadNvK9BC6nypWxho1z26swS0FTlcOp7lhkUSIsoyE0KLpzzWJDV UPnrr9fjFDXTngSEGIQBvTp6hkiRjoNRooqBbJ+BqJ53xmERUofbj6kCHh6jNgrVdXS2egh /FCBDJF/lCJTxTGpsJ9Ag== UI-OutboundReport: notjunk:1;M01:P0:Vkt1SRPMJSg=;QUWY42ysatQmaTCuL3u4p5Uz5kA PFpGzR0gptWG9miTP/vOZuHJQKHGi8MBNyZ7unyt5eKtb5AxkyHpIlvW3ruaxU5cM+X2iVXf6 7QdDjx51eyEyabmjefn652e9eoQXu/xIRUCBPB9mJbFROaXXXgfp/KQ5sHDnjVPle0QRSzDWN jSZKvtbBB2vG/LrbcPvvVVvTxIGQCu7H6Fn6SqPcL40Km0XHQ+9hGz31ms4EzjOyWGeczc8Vg cI98nEOBHut0Q9yDYAwsAwiCCqMjEoZL30RkJWwoxJ+Q1pExoFS+7Tr0Sa5mylYdbQGCL03AE fX/piXa6R9K3w1OCfIpsLg5iNvuWa5myLCdo/DJM4zyMUXtLTxWBgqluKo7v2LBBu7tg8CNIY 4KfiVXJR3/k5Qsqo3YqnJeLO7gAkGnG+liv9rjFqXTXEhqpg42DAopx9mQWKvJkTZyP4wfTKG B7Fk8xILWBFWCgHxIzlZU+986CUUktq9W1TBUt6zr+1AKomDn4fzSj37XFexMwhrlSpru9SvT TAQGEkhFOCx6uyA5UFLkR0rXggIWVOw2OMLCTL7vbyI6xkj1+JxQiGSlO3Go9mWusF+l65VYE 2SVtCLE4fIP5VXIJayeKqYG7TLqQu9BxhxIGz3DfW7wyLOrlN+R0AZNHNeY7uarj2zGv+pE76 8Rk8UL28cZwx5fCmBZY9MTxVhrSLRZVxFct8lASHa3r45ZmD4DGvwzeFCnZhbUoc6sWRLOu0k +OuThidqVs4VxvTWY9mBiKQAl4V9F3s9v1Q4d4suwF3l+W6BkSRHL+SNwRrtcpgEiMMXRxU3k AZFZS9RowLOh8au1VeK5KrbZ93tH6/3OrqV8x7YP6NofN6ZYRBjJ4oaSmP1vkwrhsjes0QNn2 SooCO7GjsS0Cbzguo5+RbZR8ignrmXk54unA3X2XZLkuq/PKehi1XZ42AEwtMMqEFCi632br/ pfbw5BsBcRgI6PgDxVAKqBL0aBU= X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 13 Dec 2023 14:23:51 -0800 (PST) On 11.12.23 11:53, Ilpo J=C3=A4rvinen wrote: > On Sat, 9 Dec 2023, Lino Sanfilippo wrote: > >> Some uart drivers specify a rs485_config() function and then decide lat= er >> 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 n= ot >> set. >> >> Furthermore instead of returning an empty structure return -ENOTTY if t= he >> RS485 configuration is requested via TIOCGRS485 but RS485 is not suppor= ted. >> This has a small impact on userspace visibility but it is consistent wi= th >> the -ENOTTY error for TIOCGRS485. >> >> Fixes: e849145e1fdd ("serial: ar933x: Fill in rs485_supported") >> Fixes: 55e18c6b6d42 ("serial: imx: Remove serial_rs485 sanitization") >> Cc: Shawn Guo >> Cc: Sascha Hauer >> Cc: stable@vger.kernel.org >> Signed-off-by: Lino Sanfilippo >> --- >> 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/seri= al_core.c >> index 4eae1406cb6c..661074ab8edb 100644 >> --- a/drivers/tty/serial/serial_core.c >> +++ b/drivers/tty/serial/serial_core.c >> @@ -1448,6 +1448,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; >> + >> uart_port_lock_irqsave(port, &flags); >> aux =3D port->rs485; >> uart_port_unlock_irqrestore(port, flags); >> @@ -1465,7 +1468,7 @@ static int uart_set_rs485_config(struct tty_struc= t *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))) > > Looking through debian code search entries for TIOCGRS485, this might > actually fly... I'd suggest splitting this into two patches though. Ok. I will split this into two patches or maybe even leave the change for = uart_get_rs485_config() completely out of this series (which is only about bug fixes) for now. Tha= nks!