From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 528AA2E282B for ; Sun, 19 Jul 2026 22:10:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784499033; cv=none; b=aorzJjTgUUsFgv9E/01SYcWumOUT6J6TEHbbTPePaNdUj6BfTkVl0EmwrDevbMDyT2euQu/seGZFbyzrHWOXkXt2xdKRgrLVBRSMyhIj3vb4v2RK9wAx+o6fdyFQUShjfjs5OpVEFiNqFo/DnpvvWbWIKjIcZX12bBKTwejXAFU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784499033; c=relaxed/simple; bh=WKG4aYWvJjBpvDHeWFwlKSa+4vrtqttZ1i+2fGHy390=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=IWBYJ7w69iuXH8X8CiH7LShC0qZXaoCwRtlqow8yRNYItwtQhm0/CVKGuteM5qLEszVTBmdgjzxOzm3uvhKJDhseoBa/7QZKMilNEUU6AsSawh3sgTBgFsLUv4Vbh8uc57xSWlruR1wMjUTj8w34tN+4E1rhEv+8tILXnxSLTF0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Zqmh9wOq; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Zqmh9wOq" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-49547fc63a0so10501955e9.2 for ; Sun, 19 Jul 2026 15:10:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784499030; x=1785103830; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=uvinVPUoJhsV28WHeBTxSrSEvMvTNBW/BR+fiFjpbyw=; b=Zqmh9wOqwswtCaok+JlxkCnZuHy0FaHAGJhZWDuh0GGeAoCjYYFusPqcedsEsh7aC3 FkWT7SW/I7uG2+97nx67UMma6wdw/jecMmQlpxBlu74pOXjWNizU33/A7k9Bw8FWyIVN gQSGeYTajuBvkcv4UWLgpv591jDAzwBeNpZgMAm+NKsdlzeQGpLT0dELtV52wF8nueOY Um+CQ135Mt+2BBShuJM2dJWSZYDBky1B6UHVzxuVUeDrFXTSgcRswgBJg4KQQQS6Ma+u 2Z7cbPBdcsh8Uy0DM97oMYG+G2UAk5DlXRl9pRHMmhY78kUyxsmAGJXX0iGoYwlMPo0E 7ywQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784499030; x=1785103830; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=uvinVPUoJhsV28WHeBTxSrSEvMvTNBW/BR+fiFjpbyw=; b=MuJ5r0T5uL5guIosop/K8W6yky1u9ug0pR1wKa7mqcJjjWh9kcUth7F89Y+pu4oQfV DX6h6aRBI8PnhZp5HN/Xh31ukeBQ4s8881MW01Oofz5AvffAkBwmfTycPNyeLKQTsDo5 CxGDSY49+9fk5vMMkpWH6aFozR4foU4Dhhvrf1VgUIAnYnhhQXX6U48DgX/xAytKmNUs M0G0XfPIe/XyPV1kshMpnbIwrkqoLnprhzGZbNubMw3EPmb6WLlaCVeKZNplCJ40J6DH QyMcFKdLF6L3Bjpx0ud3yfPvXhidCY0tK0bGcxoFl2BTD3+4C39jJgyrAUU1xnkg1cuU gonA== X-Forwarded-Encrypted: i=1; AHgh+RpGIpQ/q7JaA/60GtRfm42Koa6pLUvE8CZ4YjK5PnTAouhBfJqBuv8bOZ8gUl5uwexn83mOoK00mbUGEdE=@vger.kernel.org X-Gm-Message-State: AOJu0YyojhIg0gBXfb2UHBrgVIzow2szlpHG8v8Qn8z15zV4mx2PQxX7 pq3jTKtNm9SIaE91hZMyqpvawIi5M5MgsqOKlPCXKsPG3fEblgFqx5tx X-Gm-Gg: AfdE7cme8apkeD8FvnT+sC28UM45umMQTYz29p3URKOKi5jbHMhYF8QidTeDLpS0aSk p56Gv5LnkrQ1xRyhyfaXHB5NhdFuEH/a8tMKJ6CR3il36uG9G7WiWC9VVxjy3SFXBHJB+Pg86WK ldKICukJBnSb9nxLKqy60REDQvQHeZ5NGYdl0INsXFVf6ClV9DYBoLe25vrH5r3q1rGPGdKMb3n IPgr4mwGIjxajas5w/cvaoNFgKDKszkx/jLHRif0LN3+ojSdnL3ZxzPIuhAGngDozObFULuFS2o a+ZTLT5ut0PkpUl+Fr23zKR/ysxtPRCRi9Z+M+eK1CrT2hL2cfjq+XsY5k2jV8wrQlwi6V/I7GG YpVbxh/bhqajvYxj9CjiQ8YeqjidEk130yD7l1h2Zvo50orno48BuYhI1ZYseqkoHvCP4RK4DaI MGI7lAZ5vCQ3lilslSCBL1TbT+7Fd+F18PQO7IJzuMagKB1JGVSOHdUvu9CJqSvbcurgBYQmcEI bqpQARIRhvI9YD3d538k3Ok4rhe3n3i/WyxpBVobNfJHefpsrMf57Fqq4jv3HbHhn16TCiyqvzj rChc0QSVa6ERqb/MUBw7Wfz6 X-Received: by 2002:a05:600c:c117:b0:495:4b1d:915f with SMTP id 5b1f17b1804b1-4954b1d91ffmr117504925e9.23.1784499030391; Sun, 19 Jul 2026 15:10:30 -0700 (PDT) Received: from MacBook-Pro-von-Karl.localdomain (dynamic-2a02-3100-aeaf-bd01-78a0-2a2d-507f-c97c.310.pool.telefonica.de. [2a02:3100:aeaf:bd01:78a0:2a2d:507f:c97c]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4955370d78csm114492445e9.12.2026.07.19.15.10.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 19 Jul 2026 15:10:29 -0700 (PDT) From: Karl Mehltretter To: Greg Kroah-Hartman , Jiri Slaby Cc: Karl Mehltretter , Frank Li , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 0/4] serial: fix console lifetime bugs on failed bind and removal Date: Mon, 20 Jul 2026 00:10:10 +0200 Message-Id: <20260719221014.44354-1-kmehltretter@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This series fixes three serial/tty bind-error bugs and an i.MX console port-table lifetime bug. The fixes were found with failslab fail-nth sweeps and sysfs bind/unbind sequences under KASAN on QEMU's raspi1ap and mcimx6ul-evk machines. Patches 1-3 fix shared serial/tty core code. Patch 1 moves fallible serial core allocations before console registration; patch 2 clears serial-core pointers after uart_driver registration fails; and patch 3 makes a non-NULL tty cdev slot mean that the cdev is live. Patch 4 clears i.MX's devm-allocated port-table entry on probe failure and removal. It keeps the entry valid through console unregistration and serializes the table updates against sibling probes. Backporting note: the probe-failure half of patch 4 relies on patch 1, which ensures that uart_add_one_port() cannot fail after registering the console. For complete coverage, patches 1 and 4 should be backported together. Validation for patch 4 includes reproducing the sibling-probe race under KASAN with and without the fix, a sequential unbind/rebind regression, and the same test with CONFIG_PROVE_LOCKING=y. The fixed kernel keeps the console unregistered and survives an explicit printk in each applicable run. Changes in v2: - Patch 4: serialize port registration and removal with imx_uart_ports[] updates to close the reported sibling-probe race. - Patches 1-3 are unchanged. v1: https://lore.kernel.org/r/20260719160812.35407-1-kmehltretter@gmail.com Karl Mehltretter (4): serial: core: do fallible allocations before the console can be registered serial: core: clear freed pointers on uart_register_driver() failure tty: don't oops in tty_unregister_device() when no cdev is registered serial: imx: serialize imx_uart_ports[] lifetime drivers/tty/serial/imx.c | 21 ++++++++++++++++++-- drivers/tty/serial/serial_core.c | 33 ++++++++++++++++++-------------- drivers/tty/tty_io.c | 6 ++++-- 3 files changed, 42 insertions(+), 18 deletions(-) -- 2.53.0