From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796374924; b=Ucp0+qQCesRZUl8TsLu2rsJ3J/i5/WKvNLKGKwZTjRoHv+zHhmHGWmhL+4ye7MOFUwJv NsE4LPlgwSK90M/qW9UP9e5Y4CqpwLhteZ9qgntFxzgRVOPE7spO9CqHECteSfpBnimOs e62SYLqTRv1W48n2ro8okkV1d3/6/3M5aSd3SiNVdyU/zDqWEQBuY+7/Z4B3mkJJeXJDb 4WjecpdWoZHFk8GKKxN2ijAp0Hl9+u4f8mOE8LaIb9g1TIXFB1HVGKi7gbwxC/ZVqkL83 maCqNDnFW+Xh/I+QTZcvFSvn1akGbMQQKokmSs/3RuPGkKlN/zeLZM4GGet/huZVgCg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796374924; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=AD1i7Wsm+QSI6JidPY+HPNbQPBz82ht3TSmIaGLs5to=; b=Vu5Zu2i1IqjEls1ugQWjubLlfUxyKbnOVsIKKqXvwStkKrHS/4avSIvpeSD7nuJgj/5E dASxomBfPoCnQc58qfKs93Sm148+AZ3pfglXTPeo469fUB62yeIoCj0ZoISipTHaoqoUy dU/Oc7xkPQ4hD4SFc87oT+1lTqfUpJSJTcfWMgWpGtmkPRrn+B53c14HRtPkRBwO8/u+a 1jLsIhkua8Lv9cMa3JXNrYqDOfY9C5t6+XX9zrlMBZSFK9g5tgu+dPwpzf0NCX40LxhcP A44JU/U+cQwTxSXUNHKlJsdaEOHNnxIp2KnxB9FKwHseATt9hKKovZLl9Ap58COhTOg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=hpTDKZIJ; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D1FA606A6AE; Fri, 4 Dec 2026 09:02:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=hpTDKZIJ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 733EA1F00934; Fri, 4 Dec 2026 09:02:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796374923; bh=AD1i7Wsm+QSI6JidPY+HPNbQPBz82ht3TSmIaGLs5to=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=hpTDKZIJlwSbscLCR3BmaRdFqxOeyVyzoA4MmOLuR3b6zkZqwNRsuBODP+6IHG6pk X09YTM1N9AV/fB4/wUKFE9Mz8i2go9xN6tLyDZlfecO1o17z6wD4p7rFT4vExeo/uQ VVpGSvtQx6FJuX+hnCiLyXJxZdoRG4ZV9eBXAIL4= Date: Fri, 4 Dec 2026 17:50:10 +0900 From: Greg KH To: Yingjie Wang <1075151112@qq.com> Cc: jirislaby@kernel.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] serial: 8250: Disallow runtime changes to nr_uarts Message-ID: <2026120435-emphatic-renovate-e3bd@gregkh> References: X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Sun, Oct 25, 2026 at 10:06:09AM +0800, Yingjie Wang wrote: > nr_uarts is clamped to UART_NR while the initial 8250 ports are > initialized, but it is also used as the iteration bound by the remove > path. serial8250_get_port() assumes that the index is within the > serial8250_ports array. > > Allowing nr_uarts to be changed through sysfs can therefore make the > remove path access beyond the end of serial8250_ports. The value also > describes the number of initialized or dynamically registered ports, so > changing it after setup is not safe even when the new value is within the > array limit. > > Make the nr_uarts module parameter read-only through sysfs. Boot-time and > module-load parameter parsing remain supported and still go through the > existing clamp. > > Tested on x86-64 with CONFIG_KASAN=y under QEMU: > - 8250.nr_uarts=5 is honored at boot. > - Writes to /sys/module/8250/parameters/nr_uarts are rejected. > > Signed-off-by: Yingjie Wang <1075151112@qq.com> > --- > drivers/tty/serial/8250/8250_platform.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/tty/serial/8250/8250_platform.c b/drivers/tty/serial/8250/8250_platform.c > index 9d9dba4e0439a..2b07337407fd1 100644 > --- a/drivers/tty/serial/8250/8250_platform.c > +++ b/drivers/tty/serial/8250/8250_platform.c > @@ -385,7 +385,7 @@ MODULE_DESCRIPTION("Generic 8250/16x50 serial platform driver"); > module_param_hw(share_irqs, bool, other, 0644); > MODULE_PARM_DESC(share_irqs, "Share IRQs with other non-8250/16x50 devices (unsafe)"); > > -module_param(nr_uarts, uint, 0644); > +module_param(nr_uarts, uint, 0444); > MODULE_PARM_DESC(nr_uarts, "Maximum number of UARTs supported. (1-" __MODULE_STRING(CONFIG_SERIAL_8250_NR_UARTS) ")"); > > MODULE_ALIAS_CHARDEV_MAJOR(TTY_MAJOR); > > base-commit: 1184f87e2790e8af9be3116f608d2e86b4792d7d > -- > 2.43.0 > You are breaking an existing userspace api for no good reason other than "root did something that broke the system", right? Why not properly fix the issue instead of papering over it this way? thanks. greg k-h