From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f42.google.com (mail-qv1-f42.google.com [209.85.219.42]) (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 3C0EB3B0AFB for ; Tue, 7 Apr 2026 16:45:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775580331; cv=none; b=KfC63apSJvYXSnSGcDhkPeETMiLuq7xsQVfDtX5EmwWo/fABvM/aaD+lDQffIKm7rOx64RczdMX5OAbU0UX6EYzj1SD5OWJYipCyvhNFx0CfUSLFCdXKBtOKGQ/c9sqZ0bZVpb+vHXJw4E8MpA45rLeqVnRZcxJmP0C+tnhTjLA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775580331; c=relaxed/simple; bh=f5xgWFoHlxDGIzM61JqlzIzWWv8eJwK0O4pMM5aCB+o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n+1rHwUFc0VwhEOM2K/kTaZHGK7aLTMwacFf1MkkeNs/kNO8mDSDLADc6MaYgjmwAlrSmL/kQA/lYLTbJqcMcIf7zH8ytgrBCC1/x7boHvMw808fjTAH77J2oayUUQafxLZ6xVMPYKkhFj11zahUOv+uXoH1448d8Ta3sjsm2Ys= 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=HwKpMidJ; arc=none smtp.client-ip=209.85.219.42 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="HwKpMidJ" Received: by mail-qv1-f42.google.com with SMTP id 6a1803df08f44-8a154cc6a48so66930626d6.0 for ; Tue, 07 Apr 2026 09:45:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775580329; x=1776185129; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EVD3gsLs5pyKc/GN8/ouN0bgbaQzwLmJCimCeB/EV+Q=; b=HwKpMidJRnNdNtG3qGmAuXrCcZphHzBWIVDcYP4vFE83N9ro/BZ/DfQwDwqOz3lhY9 CVv8UIb/LXWWuwCy1ekWx47zzObKPT2gw4CKZXr7RgM0tmbfrHoJDKLzRbCC16mNeeY4 jEsHoLVlGZloQDQJUeW/Prrqh9uXdePho59W9V6ykr/E29EixkZ3RJuGkZW56c6obGT3 +g9QMphOU2sNN3y8drvf57ctdE4J9SESJKZeAvfKdFa0/iGAsEeRrMZmmxrtoXICGUgG HgqiF9ZhqEDCvf+7tApH5WesmHoITjgIsxyD+Vnra8pYeNNcE08q+5GmDzca+amo2NMl hLEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775580329; x=1776185129; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=EVD3gsLs5pyKc/GN8/ouN0bgbaQzwLmJCimCeB/EV+Q=; b=OOauPoa2y/rzAlpFmGDQWnqQO4tj4RxWOgqHnzcuEn4GeMl2lsVTnFYdaKryhkB5lf 4KMn4t+dDd3/vR1Z3d8nR4wHn6MW2KR3YWaQk70oFaYZ1V0IhUFw5YgxAYheGjbeJwlF J3tI7fxj7z5cduxbQFaR5OJ9uJ0Ty8R28SaoKBbzZRCaT0i1XsT18UXsOunn9UFLWFB/ JMKWhMBOKOig/IiPKECERGCBE/RqN9iGgAgg/3KIekhNrIHewa4XZ87CPwfJyBhJMWWE yR+CueVMyAAlKb+UCp3sXKWowU/KxrwNtSMLtRHTc1IyJ9+6ufCyvusz1lTE+fJiRbi+ Jw4w== X-Forwarded-Encrypted: i=1; AJvYcCWTLqR2p2I/K+HCwJnlQiqiAUL2KhZKs+onQsT+rwo3N2aZiWXD6pBc/DfdabV5Cg9XGrvkGL7JBvs7rGc=@vger.kernel.org X-Gm-Message-State: AOJu0Yw0QHj1qj9TYZ8RwUbsevUQ1RxJ0saaXCG3DtuDM43YggTwiRey TB8pT6lzUahhQq4VLdcVF8q4ZD0CME0CLnS9TQLaKEG1lVdQYCrmdTWS X-Gm-Gg: AeBDievVOIldPBLiu1YRBuNLiqVl7KZ+XiSMW6wDChlWLAS5y3j//BxQzHh0/GDeHBn +5e1w9GTBpcj2Zm7BfUdqQG0guMBm36OopND2AR/2gNLURPGbL9LMPI66M2VsOETHbZdYzopkFB iLUW8U2fOMOh5AcEUxvsUKRNW+pK6W4zvIEgJJc12bxg/zyBiVa2LUXimerssmPb9eUqo9s1iwK jrvO5NBmvEnC4MTEdiuwfecBOYhRRDgH6ideSpM9Pkm1/i7TY5MJfZEv/FrtNQX04cLRunlRFi6 UwsSFhtWPQ8TBqIOjs/qdwH6nu/NGGQtHJ0ptiDoaZkDbLIqfJMQeW7/H5uNlNeYlvyI+r3BfSA WlkIFxH1ah2RuB9kNG5RozK1cge0IG52oRypZaZQY/sKtOh6+HCk2rDr7/3vlysyqXIn9N3u1tA O2sKXtbV53oz3ZNCUu9Kt+YZO5AmVyoEHtPfur2xqcM/kM3cs9myjhRdnV323zSWauXv8DZDq+I qJ2wIY5DpPLYyjgiV3NKnlJ9iw= X-Received: by 2002:a05:6214:258c:b0:89c:d50e:b57 with SMTP id 6a1803df08f44-8a7023c032dmr293344546d6.15.1775580329106; Tue, 07 Apr 2026 09:45:29 -0700 (PDT) Received: from workstation1 (c-68-48-65-54.hsd1.mi.comcast.net. [68.48.65.54]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8aa70136e87sm62044156d6.22.2026.04.07.09.45.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2026 09:45:28 -0700 (PDT) From: Michael Bommarito To: Richard Weinberger , Anton Ivanov , Johannes Berg Cc: linux-um@lists.infradead.org, linux-kernel@vger.kernel.org, Michael Bommarito , stable@vger.kernel.org Subject: [PATCH] um: drivers: use libc strrchr() in cow_user.o Date: Tue, 7 Apr 2026 12:44:35 -0400 Message-ID: <20260407164435.726012-2-michael.bommarito@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260407164435.726012-1-michael.bommarito@gmail.com> References: <20260407164435.726012-1-michael.bommarito@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Building ARCH=um on a host with glibc >= 2.43 fails: arch/um/drivers/cow_user.c:156:17: error: implicit declaration of function 'strrchr' [-Wimplicit-function-declaration] cow_user.o is a host-side helper (compiled with -D__UM_HOST__) that calls libc strrchr(). It inherits the global -Dstrrchr=kernel_strrchr remap from arch/um/Makefile, which is intentionally kept in USER_CFLAGS to prevent linker clashes between libc and kernel symbols. This combination was harmless until glibc 2.43, which added (glibc commit cd748a63ab1a, "Implement C23 const-preserving standard library macros"): #define strrchr(S,C) __glibc_const_generic(S, const char *, strrchr(S, C)) The glibc function-like macro replaces the -D object-like macro. The inner strrchr token in the expansion is protected from recursive expansion, so it refers to the bare symbol strrchr -- but the header declaration was already rewritten to kernel_strrchr by the -D. The result is an implicit-declaration error. The remap was originally added in commit 2c51a4bc0233 ("um: fix strrchr() problems") to resolve a linker clash when both CONFIG_STATIC_LINK and CONFIG_UML_NET_VDE are set. Recently, commit a74b6c0e53a6 ("um: Don't rename vmap to kernel_vmap") trimmed the now-obsolete vmap remap from arch/um/Makefile and updated the comment to explicitly call out -Dstrrchr=kernel_strrchr as one of the remaps that still prevents libc symbol clashes. That framing is kept here: the global strrchr remap is still needed for kernel-side objects, but cow_user.o is host-side and should use libc strrchr directly. cow_user.o is built whenever CONFIG_BLK_DEV_UBD=y (the standard UML block device), so this affects most non-trivial UML configurations. cow_user.c is the only file under arch/um/ that calls strrchr(). Fix this by undoing the remap for just this translation unit via per-object CFLAGS. In UML's Makefile.rules, CFLAGS_$(basetarget).o is appended after USER_CFLAGS, so -Ustrrchr correctly overrides the earlier -Dstrrchr=kernel_strrchr. Standalone reproducer (fails on glibc >= 2.43, succeeds on older): printf '#include \nvoid f(void) { char *p = strrchr("foo", 47); }\n' \ | gcc -c -Dstrrchr=kernel_strrchr -x c - -o /dev/null Tested on: - Host: Ubuntu, glibc 2.43-2ubuntu1, gcc 15.2.0 - Kernel: v7.0.0-rc6 (3aae9383f42f) - Build: ARCH=um defconfig + CONFIG_BLK_DEV_UBD=y, clean compile - Boot: UML boots to Debian bookworm multi-user target - COW: UML boots with COW overlay (ubd0=cow,backing), exercising the absolutize() -> strrchr() path in cow_user.c AI coding tools (Claude Code with Opus 4.6, and Codex with GPT-5.4) assisted with debugging, test design, and drafting; the author manually reviewed every line and executed every build and boot test on the host. Full disclosure in the cover letter. Fixes: 2c51a4bc0233 ("um: fix strrchr() problems") Cc: stable@vger.kernel.org Assisted-by: Claude:claude-opus-4-6 Assisted-by: Codex:gpt-5-4 Signed-off-by: Michael Bommarito --- arch/um/drivers/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/um/drivers/Makefile b/arch/um/drivers/Makefile index 36dc57840..e387ae33f 100644 --- a/arch/um/drivers/Makefile +++ b/arch/um/drivers/Makefile @@ -49,6 +49,9 @@ obj-$(CONFIG_UML_PCI_OVER_VFIO) += vfio_uml.o # pcap_user.o must be added explicitly. USER_OBJS := fd.o null.o pty.o tty.o xterm.o vector_user.o CFLAGS_null.o = -DDEV_NULL=$(DEV_NULL_PATH) +# cow_user.o is a host-side helper that uses libc strrchr(); undo the global +# UML remap to kernel_strrchr for this translation unit. +CFLAGS_cow_user.o += -Ustrrchr CFLAGS_xterm.o += '-DCONFIG_XTERM_CHAN_DEFAULT_EMULATOR="$(CONFIG_XTERM_CHAN_DEFAULT_EMULATOR)"' -- 2.49.0