Message ID | 20231018174840.28977-5-l.sanfilippo@kunbus.com |
---|---|
State | Superseded |
Headers | show
Return-Path: <linux-serial-owner@vger.kernel.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0FF1DCDB47E for <linux-serial@archiver.kernel.org>; Wed, 18 Oct 2023 17:49:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230437AbjJRRty (ORCPT <rfc822;linux-serial@archiver.kernel.org>); Wed, 18 Oct 2023 13:49:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231293AbjJRRtp (ORCPT <rfc822;linux-serial@vger.kernel.org>); Wed, 18 Oct 2023 13:49:45 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2047.outbound.protection.outlook.com [40.107.22.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 381C5111; Wed, 18 Oct 2023 10:49:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c2gQQChVxGzC6HUdhwdjwJLe92l0XLbgCSLxjXtcJowjFKwDi4x7E57tcMzl8TuQStOkDs/40o7eSsf3Q76rP3NxSXPCJ8mwsPiTPBdeOsZqyTCoN2tIiAZMX35rbO8lIHst+jN4PDYWmnMYX30UawCtwiWXddAUgsyx11JirNGw2oi7dANboY1xg40AEDzWehr+maV6m+V6lhK/z1AsQP8qZ5h78jTm9VvD/511FeO99cR45+20PYAQmGKekJIW39rj5pqWwyliJPoIUnCKYG27S8id4m0wd5xqt3hwFkUXOPmiO94ASYWr5ZpawCGsp9phnAJeGlPKhrQ4seOyOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=w4GqqAu1YpbERiRD53HRt9O/SyEoX2/kmKWMxhgAsE8=; b=fU9VEmhv41xMBgB/IShPS6QFGJz2VfHdpc5ORnWlhsy8EWNreiAO4nmPJxij/2G7DTH/Y+KHUpbrwHhaqV/4H+GlOhOAV2eHbPa2dU1u9RC9OaXTZfOU4vk6abuu9aYzDjcbayN6ZHPveJ2ASByAO7NSBvUhyFE4sAx2kz3m9oNCwDwRPAjiXGwkwXjq1biCyO8wXdg2U8M/c3dns/uyxrUJt2VK2LmtrONL8uXMyEYCmV4SjRTN0QTUjPDmztaJ30PIdEBcY/1y1lLX7YwXNq9kXC7qhsrqrxgIIKp2JUvpU7itUz4tD0KVJHZd9RHSq7Ig05UVAE/L95Wu6Srn8Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=kunbus.com; dmarc=pass action=none header.from=kunbus.com; dkim=pass header.d=kunbus.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kunbus.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=w4GqqAu1YpbERiRD53HRt9O/SyEoX2/kmKWMxhgAsE8=; b=VpQJ+1cXGAjHN/rUQW6HSGGQxPC0FrYAMAsXArNpCvjliGscg2SHW5Y3CemmpqdGMQBjnYRCdi87t0YdlmVzBRgqOHSM4efWyDsS/HeAxgKmboj54hdELSzTrioOy+z/F5S8VA6pEKyaVPMv8xoDm2eZE6uWBiMJuepqIS4hyg4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=kunbus.com; Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) by AS8P193MB1478.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:350::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.23; Wed, 18 Oct 2023 17:49:39 +0000 Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::550d:2425:c0ed:3e59]) by VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::550d:2425:c0ed:3e59%3]) with mapi id 15.20.6886.034; Wed, 18 Oct 2023 17:49:39 +0000 From: Lino Sanfilippo <l.sanfilippo@kunbus.com> To: gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com Cc: 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, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, LinoSanfilippo@gmx.de, lukas@wunner.de, p.rosenberger@kunbus.com, Lino Sanfilippo <l.sanfilippo@kunbus.com>, stable@vger.kernel.org Subject: [PATCH v4 4/7] serial: core: make sure RS485 cannot be enabled when it is not supported Date: Wed, 18 Oct 2023 19:48:37 +0200 Message-Id: <20231018174840.28977-5-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231018174840.28977-1-l.sanfilippo@kunbus.com> References: <20231018174840.28977-1-l.sanfilippo@kunbus.com> Content-Transfer-Encoding: base64 Content-Type: text/plain X-ClientProxiedBy: FR0P281CA0130.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:97::17) To VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1P193MB0413:EE_|AS8P193MB1478:EE_ X-MS-Office365-Filtering-Correlation-Id: 0b4caad4-19ef-4727-e8b1-08dbd00299c0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: svjy0K3wb7yzn5wApTnwDw5STDiJKfNnI73LjKOy73hMJlfYnAQZhbMP9j+6tX6KpCV9QbiDJrWVrJdSAnQtzPoaS3Leio5oaUctqpPOvGfXjpsYWR1exbIPzx16AWkuqnczbpw+kkkK8RY+x3vIgcBAvCZl4TdWTc+oRcysdVrZ9am7u31M+ztz3SjCIBUsrpGqWquy/RKbMdidoUYO+F5TiqSosePJeCkNlDiNwYDemH60ZC60vnEIA3U/bRdkqHSj6mOXmb4E3cxiyRvIbJpY/tlrHtg63cOfAl49DKkKc4PG5JdASyOw/mUU7aSOzrIcuJnGudFKLuMapLujcD52ZoVgDuoERwDWrP3R5bZeUtTSB6Vc8gKgiYnq7W4oUwgDmxl3ad/IJubkKHKEZtDyFE1jx0i+eUyYqn67IfvGmse2Wnl0zCCnO7tsXB7hIGEvS0h1BQeamNN9VyYIEOJyLSBjA0xiNll9J+zluKD5/VHtNZNWUmvlzzreyKiOj+pGlDBE8AqgXpkcOjyibDXDsA3hxv6+UdFljxdHTdUFFcv2NBCmxHFPn03uO7yl X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1P193MB0413.EURP193.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230031)(396003)(39840400004)(376002)(346002)(366004)(136003)(230922051799003)(186009)(1800799009)(64100799003)(451199024)(36756003)(66946007)(66556008)(66476007)(86362001)(38100700002)(1076003)(2616005)(83380400001)(6512007)(52116002)(6506007)(7416002)(6486002)(316002)(478600001)(5660300002)(4326008)(8676002)(41300700001)(2906002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: u2uscTQ6tODp/oVuSdzy5OPWtfbQLid62kem5zmpQoSzxx157DkkNC4Ef2iuXcjKE46EkxQBUPpDm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+1Uj4BOFySaUnj0JweI5N91xhFvnPq3s9hdwcNZGrEwIhiEWO333pPf06qbbbsAf4kIVc/bpep2QahrRknvwKwleo/WNY3FWUX5T5aQ31FInbUyct35rtnZboGs3s2vOcC0VW7/rx/kL6zGgCzw/x4abr+hXFcOK2gZ3CThsWGIh6nEea90cVCcxdGMGUmS4AOUYDEW9v8vlfPZ2yle1+yd6cVEKnBKuNkJFz/bn9UrDyhtdcCW8FcHA2L8nrEgK8+do/3zG1/o6P8e5K6qQli77X3Zo1UKlTdJwnCrLrE4ufsdiGaYoov1Z7elO+9D2trxSpKPj6r2cezpLuZJRnpxvpbfQUEN60cRB1ZiuSZLgeKZe5J6zYbjsBMH3eg9qCb88I8qCiOjVA7phNWb8SmIDsxZXC+pyXitgRaLLKzo8PCFj7M8kWsbHC8Kh5IWm6zm1c45qR7Rz/WzE5YBESWFdxszt697Rfs2xjOsPwuKV+/siR1aBv3/WFUIbtqdLE0dGU X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0b4caad4-19ef-4727-e8b1-08dbd00299c0 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2023 17:49:39.2625 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: aaa4d814-e659-4b0a-9698-1c671f11520b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: uQaQsd7nbtBLqbD64cqci+u1b2lhwe6JQKcwQn3DTh1/d5pUYQIOWy0R+fPePTFK51lekSrsTWTpqrPPCi7Tgw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P193MB1478 Precedence: bulk List-ID: <linux-serial.vger.kernel.org> X-Mailing-List: linux-serial@vger.kernel.org |
Series |
Fixes and improvements for RS485
|
expand
|
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index f1d889f9fd6e..49dd5e864719 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1443,6 +1443,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); @@ -1460,7 +1463,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)))
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. This has a small impact on userspace visibility but it is consistent with the -ENOTTY error for TIOCGRS485. Fixes: e849145e1fdd ("serial: ar933x: Fill in rs485_supported") Fixes: 55e18c6b6d42 ("serial: imx: Remove serial_rs485 sanitization") Cc: Shawn Guo <shawnguo@kernel.org> Cc: Sascha Hauer <s.hauer@pengutronix.de> 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(-)