From nobody Mon Jun 15 02:46:01 2026 Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) (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 272D32E2EF9 for ; Tue, 7 Apr 2026 18:15:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775585741; cv=none; b=IsRJUGuQ5Fk+K3wU7KWsmeLoKCWn2TjhXtuVGjfNjpy78LlMeXXir3lgZM/1o5UBsl55ywKrfoHrbIR4320F0tXjmXEwswwK6YewJk1232ubmfFlXnAO7yodA2m2e5PjVAGf60v2Y1qOGItjYVBImWKCgen5B3Uzdzqt3ILYrRg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775585741; c=relaxed/simple; bh=MyhOVEiw/qMJA/HKOs18Ls9TDPdBBtMhop+aDAFUy/Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=saI243/GVndx4vUyjAvCuEbq9SJNqMkH4ySyw+R5GUiWXSPeC0H2SgrzdTgXjHuaqQZuCXMo/aNztsZrvYoJ5hT7sW9ylLFK5w/84GLstojSaUUN5RD9p2qARyB0XMo1vJ2Vmkqb/zXJ0bOayH9iKPcwM+dEpqhrVru/FeEW3cI= 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=osLfkc7R; arc=none smtp.client-ip=209.85.160.181 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="osLfkc7R" Received: by mail-qt1-f181.google.com with SMTP id d75a77b69052e-50d59d249fbso55441851cf.0 for ; Tue, 07 Apr 2026 11:15:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775585736; x=1776190536; 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=Vl0fSOLNOL0VYWbHLlMdkEjeY0mPmotcIP2HiCQA9z8=; b=osLfkc7RD01PrCFneYJN1JLUFIirbUB1nuZoQoQejJjhQVji1hWwC+iZTbrO7MOHG8 2CJniYtnQsuklHJtladBifbYUxgznMD5Kc+2V40JjXNcC/jhn9fHwPIQK5VQ0a+rcRvC xseaYACzV/Fmtp2Y0pg2ZRKUR3ZHcEQ7bHOIdb4JNuDLTSWsvjmkTF8tE897Wd9EOy+T rhn0zjsnEs762+IuHmted5fuW/vafO7cpiSeq3iZFQoanYaipHNaKNCdwwZ2FicjUcg0 x+7J2LIXXCLnmzWQO/VKF7AqoLxpLgSLTFobks78E5EJOHdF2fOwEvV2iZWtqNWwlUT6 +WXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775585736; x=1776190536; 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=Vl0fSOLNOL0VYWbHLlMdkEjeY0mPmotcIP2HiCQA9z8=; b=LTLrLJGdsmLMMqVnTQj/rezHPpaZIN+58Le10iMdKEoR4uI/8HzBfSS6XgpnzwXjsa wzaeK6ZUsCIUSrQxBmBa3ZGKPgg3isFDzIL4YydVuLFRMn17SblVkAIH6DQX7A7Hfpav h+DAkhFNr/8uYASw1vifAkx9O2Wj0aP+JDTqmzkPGaM4ezpO5SY98sY7A5kCiIBWmTVj CdieTyC+7dVRQRIRG2VyxjOrMe0kWkd/8sXBYZg+aigF5h3wxhlnBCHR/l0UmhVbHchX h5uM7l+PnA4WZFVqXf7mU67PEgoE8rhiBFocGObt4P3D8cfQC6q2LMG0CzgvKs3N0Ouw KipQ== X-Forwarded-Encrypted: i=1; AJvYcCWHs98DAp+l5pnqq0GEyyCp9y1+GYlZxTqKEYWhfSYaleKjXqFlxJ+MgmqyES9pqV8U+mcHm+O82X5gqY4=@vger.kernel.org X-Gm-Message-State: AOJu0YyUEYqktKV1vMybqQqUKCJUKq+qTlHOcUpNmLJz37w/7xpYLLLn OVsEkUu5qGjoEZgUb0RDUppud8FobnNTo7vflUWGDTz3+F00OzRtnNI1 X-Gm-Gg: AeBDieuZjCn3Tsf3XARFsiR/X+ONzvN4vqfO8gbquUZWiaRVmUzL3bqPHihsy6dM8Lz g/9tdbpbPLHtN4orAoFQzD8ZQNWVvhkbzFvKYI8ujEKr8Mql0hGDTcRgYmscqRZDF/8O7YLxmWA Cz9CRtbx1P5RyRCGwh2XiZNgDaWLemLqBbyJ2YsuGMFBasCZ4TA8nSdcxhaDPDpZ6njD/J3KN8o CZlZ9DlH8x0E5cKUPaT7VD6UdLkpmOgyjBrWUURfDJuMpJ82nOlde4m1mFUwzSMDL3SdRUQo1Ix vkAay/yo8eGIsV0s4QDRl886733tx2tFmVBL/5mYcz+hq3yZpks33OCQPITkLXXYswF/ZSP8P1G F4IHteJndVJ4wvxE0onxEdl4grk4+zENO+RpEVCGrdaIlbptFg7amSKhauLlrCKN/wnMFmisP0P 5/sEQnb2koE3T8tPzuoR/CSVdmVA6/YwRCBbvHFg0JzLvBIHQJGJRF+SRG8UeKHXrG1MLGdFx4G 4S2gu1qG7ReAnEhrcROElAOvZG7E0F8Tz48FA== X-Received: by 2002:a05:622a:8d06:b0:509:15aa:cf01 with SMTP id d75a77b69052e-50d62b57d4cmr246252501cf.61.1775585736146; Tue, 07 Apr 2026 11:15:36 -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-8a593908b47sm186312926d6.11.2026.04.07.11.15.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2026 11:15:35 -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 v2] um: drivers: call kernel_strrchr() explicitly in cow_user.c Date: Tue, 7 Apr 2026 14:15:28 -0400 Message-ID: <20260407181528.879358-1-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: quoted-printable Content-Type: text/plain; charset="utf-8" Building ARCH=3Dum on a host with glibc >=3D 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 strrchr(). It inherits the global -Dstrrchr=3Dkernel_strrchr remap from arch/um/Makefile, which is intentionally kept in USER_CFLAGS to prevent libc/kernel symbol clashes. 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 global -Dstrrchr=3Dkernel_strrchr 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 and updated the comment in arch/um/Makefile to explicitly call out -Dstrrchr=3Dkernel_strrchr as one of the remaps that still prevents libc symbol clashes. That global remap stays in place. Rather than exempting cow_user.o from the remap at build time, call kernel_strrchr() explicitly in the source. This is slightly more honest about which strrchr the code wants (the kernel's, as it has been since 2011), sidesteps the interaction with glibc's C23 macro entirely, avoids adding a new libc strrchr dependency to the UML binary, and is robust to future C23 const-preserving macros for strchr, memchr, strstr, etc. cow_user.o is built whenever CONFIG_BLK_DEV_UBD=3Dy (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(), so no other translation units need changes. Standalone reproducer (fails on glibc >=3D 2.43, succeeds on older): printf '#include \nvoid f(void) { char *p =3D strrchr("foo", 47= ); }\n' \ | gcc -c -Dstrrchr=3Dkernel_strrchr -x c - -o /dev/null Tested on: - Host: Ubuntu, glibc 2.43-2ubuntu1, gcc 15.2.0 - Kernel: v7.0-rc6 (3aae9383f42f); verified that neither arch/um/drivers/Makefile nor arch/um/drivers/cow_user.c changed between rc6 and rc7, so the fix applies and behaves identically on both - Build: ARCH=3Dum defconfig + CONFIG_BLK_DEV_UBD=3Dy, clean compile with no warnings - nm: cow_user.o references 'U kernel_strrchr' (not libc strrchr), and the final linux binary has no strrchr@GLIBC_2.2.5 symbol anywhere; kernel_strrchr is defined exactly once by lib/string.o and EXPORT_SYMBOL'd - Boot: UML boots to Debian bookworm multi-user and graphical targets with a COW overlay (ubd0=3Dcow,backing), which exercises the patched absolutize() -> kernel_strrchr() code 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 was posted with v1; a shorter summary is in the Assisted-by: trailers below. Fixes: 2c51a4bc0233 ("um: fix strrchr() problems") Suggested-by: Johannes Berg Cc: stable@vger.kernel.org Assisted-by: Claude:claude-opus-4-6 Assisted-by: Codex:gpt-5-4 Signed-off-by: Michael Bommarito --- v1: https://lore.kernel.org/all/20260407164435.726012-2-michael.bommari= to@gmail.com/ Review: https://lore.kernel.org/linux-um/1e15d25c23b444eae1dcfc01432e7ec1e1= 9e25a0.camel@sipsolutions.net/ Changes since v1: - Per Johannes Berg's review (link above): rather than exempting cow_user.o from the global -Dstrrchr=3Dkernel_strrchr remap via -Ustrrchr in arch/um/drivers/Makefile, call kernel_strrchr() explicitly in cow_user.c. This keeps the existing semantic that cow_user.o uses the kernel's strrchr (no new libc dependency on the host side), and the source no longer relies on the build-time rewrite at all. - Reverted the arch/um/drivers/Makefile CFLAGS change from v1. - Verified locally on v7.0-rc6: clean build, cow_user.o references 'U kernel_strrchr' (no libc strrchr), the final linux binary has no strrchr@GLIBC_2.2.5 reference anywhere, and the kernel boots to multi-user with a COW overlay that exercises the patched code path. Full boot log captured locally. arch/um/drivers/cow_user.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/um/drivers/cow_user.c b/arch/um/drivers/cow_user.c index 29b46581ddd1..ec8e6121b402 100644 --- a/arch/um/drivers/cow_user.c +++ b/arch/um/drivers/cow_user.c @@ -15,6 +15,12 @@ #include "cow.h" #include "cow_sys.h" +/* + * arch/um/Makefile remaps strrchr to kernel_strrchr; call the kernel + * name directly to avoid glibc >=3D 2.43's C23 strrchr macro. + */ +extern char *kernel_strrchr(const char *, int); + #define PATH_LEN_V1 256 /* unsigned time_t works until year 2106 */ @@ -153,7 +159,7 @@ static int absolutize(char *to, int size, char *from) errno); return -1; } - slash =3D strrchr(from, '/'); + slash =3D kernel_strrchr(from, '/'); if (slash !=3D NULL) { *slash =3D '\0'; if (chdir(from)) { -- 2.49.0 From nobody Mon Jun 15 02:46:01 2026 Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) (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 4D94E351C0D for ; Wed, 8 Apr 2026 07:01:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775631683; cv=none; b=Th9+xypQPx5nHkvsF5yKH6RhVPv1285rAoEQ4XUPn76sWViPv2yeliIMn+Xvx3HcbN7hPD28A+w2SBjefB+JlolL7Bx7T6IV/jshMGzOkC1eD+Xy1JFmAQzomIv6QBUZNbPxHfmpVJkFfsg/HjE9ODbM8RJhSwgPhxnCKMw1n8Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775631683; c=relaxed/simple; bh=edO3BFPXlea+cqJl8XCSCE52FEybAwQLAS/TDfDiH+Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kyC+0FtkA9F20M8pAVY0CnXQVNqbOSCfZc7tAUPYgtx7h6NRpm3DEmV16rX7D+5BbpxsqcA7cRQp7znx+/C2mcdU/qeAtjOcJ1Gb8yCbqFOD7sP47vz3nhSZvC08BKPLvdrsK3nuU2hJi6+Dk+nWVYwoDPT9y98eGU5O1nw5FSQ= 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=LP1JMrUW; arc=none smtp.client-ip=209.85.219.43 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="LP1JMrUW" Received: by mail-qv1-f43.google.com with SMTP id 6a1803df08f44-8a4b8c3a30bso76765586d6.3 for ; Wed, 08 Apr 2026 00:01:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775631681; x=1776236481; 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=KgVbyVFvTMOOobCmboEzJiSzpNTMaTKxGh/qViShvW8=; b=LP1JMrUW5lFqL5C6DxLDla6u4HAe6BzHhP3cZCj2JpxZz2yecROh/yh9vMdHeHrQ2q TO9nJdQzIkDOsGOUJx8cnjEhnglTiU0aFrW1Mi5idI5MAuJW3Xpub+zkzszTA6LOHENg 3HR77i5GO0wuVYVWJHHCVzuIn8IpSH/Ca9UdbN7Df/srFKx/TrLxxd43nR498OxlkQnS IQGSTF+N8uxnWTbgPRA3FtHiiVOxW+A1f+S+zgdJ3K/GUK1wBSHbesZdVpejbKwM9oXy BcPm4yICYFFViX9tEDPYCf6HBWpvWo7Iu6++BSWzWfi7OJD176Grm0tizK5kGsdof+WU ruUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775631681; x=1776236481; 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=KgVbyVFvTMOOobCmboEzJiSzpNTMaTKxGh/qViShvW8=; b=OMp6xzCwG4mgsf61xZA/gsxb7zFz5NREyuIemDvHUYfzgFS+TOHhSA+wI/R4SifpmP IbE1oZO36Uf2DmUhB5YIEkhnr3gVZ6aco6NOnhlm4Uxuxc51ug9dOp+dyaX/84SyRKdL keSeT2H5Y9f/1IgDhFp6hkkviw68Nc3BWeVfRp3ccnMCVzt4mcb78ROzK321FibqHW90 S6mXPgi6//BVTB5iTDOwp6QOCQlg5EHZGwvsY/gc5y6nlCD0zj9p7cqEsfbiilk2z2WZ 173uygQ8IZiIwgShCAavpRLovU08ZUIJQUxny9yRjmk/vmIlFwHsqIilSTgG5066yoXA DgBQ== X-Forwarded-Encrypted: i=1; AJvYcCUOZDIEIzDss04pzV4uJ02/Dxiyb8A3HQ2VHHG4oaS3ZuOp1aZMxVqV0JQDhfvPyUFcJQBDAIDUfVbU94M=@vger.kernel.org X-Gm-Message-State: AOJu0YzejIw5PQcwMmXFkTjamt5spoDUg53k/11/oQ2BfHm+8IQDCZL2 2zRGrFVcpRSofoSt1PUUVWc0TFTZrS5chs1ytNCll5oM9a/w2/J9/MHO X-Gm-Gg: AeBDiesZdLH9NvPw8XKpML8AJS/UJUcxtNY/NKCgrfgN3mFiI/7Yzxt0c2cMmYV5pMs n3sn7GOh9kXynxBLnjHL8EDQxgv+DFgmWHm5KEuzXOpN8oBzW2WFw6YuP8uf4utpo/alQ35vgoK Q9UBQ0Ei2UMRfY580F8sIlHhnIXdB7RTIvczucml54FagXjwSYrKCTqgpi/3yWE21UJI1aZbpIo +tdyM+j15KLUe2aXayUlpfMx7EWhU4W7v7WQ5XFL7Z+M8MYImT1/1/RGWvZzDAvBlNKoKOj+xZb /JSRN+K7wxB/G3LQHWwcuoQAP6WF6F57K5xPL5ud4Kiw3m2VBZHwuM9uNadNFP5uPlhmKJLagsv 3qFmw64L1Kq8XvHfrq9Pjh40aATP9e2TR76RF9n2A+hGcVo+o3gUbDZwLjlXi7pm8diS2/AS5pt 3pHo4E7g4TIMfCfuzzDvEZ0m9Qx2l6zO34mcuaU0QHmuMvkiHZpboXZFkwG+qT+6ncSuTnISXl4 6G9o4hsLuvgkG91Okys2DHvSnM= X-Received: by 2002:a05:6214:c26:b0:8a6:d318:4909 with SMTP id 6a1803df08f44-8a7020bf953mr327652746d6.2.1775631681042; Wed, 08 Apr 2026 00:01:21 -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-8a596a0a522sm163454596d6.32.2026.04.08.00.01.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 00:01:20 -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 v3] um: drivers: call kernel_strrchr() explicitly in cow_user.c Date: Wed, 8 Apr 2026 03:01:02 -0400 Message-ID: <20260408070102.2325572-1-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: quoted-printable Content-Type: text/plain; charset="utf-8" Building ARCH=3Dum on glibc >=3D 2.43 fails: arch/um/drivers/cow_user.c: error: implicit declaration of function 'strrchr' [-Wimplicit-function-declaration] glibc 2.43's C23 const-preserving strrchr() macro does not survive UML's global -Dstrrchr=3Dkernel_strrchr remap from arch/um/Makefile. Call kernel_strrchr() directly in cow_user.c so the source no longer depends on the -D rewrite. Fixes: 2c51a4bc0233 ("um: fix strrchr() problems") Suggested-by: Johannes Berg Cc: stable@vger.kernel.org Assisted-by: Claude:claude-opus-4-6 Assisted-by: Codex:gpt-5-4 Signed-off-by: Michael Bommarito --- v2: https://lore.kernel.org/all/20260407181528.879358-1-michael.bommarito@g= mail.com/ Changes since v2: trim commit message per review. arch/um/drivers/cow_user.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/um/drivers/cow_user.c b/arch/um/drivers/cow_user.c index 29b46581ddd1..ec8e6121b402 100644 --- a/arch/um/drivers/cow_user.c +++ b/arch/um/drivers/cow_user.c @@ -15,6 +15,12 @@ #include "cow.h" #include "cow_sys.h" +/* + * arch/um/Makefile remaps strrchr to kernel_strrchr; call the kernel + * name directly to avoid glibc >=3D 2.43's C23 strrchr macro. + */ +extern char *kernel_strrchr(const char *, int); + #define PATH_LEN_V1 256 /* unsigned time_t works until year 2106 */ @@ -153,7 +159,7 @@ static int absolutize(char *to, int size, char *from) errno); return -1; } - slash =3D strrchr(from, '/'); + slash =3D kernel_strrchr(from, '/'); if (slash !=3D NULL) { *slash =3D '\0'; if (chdir(from)) { -- 2.49.0 From nobody Mon Jun 15 02:46:01 2026 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: quoted-printable Content-Type: text/plain; charset="utf-8" Building ARCH=3Dum on a host with glibc >=3D 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=3Dkernel_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=3Dkernel_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=3Dy (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=3Dkernel_strrchr. Standalone reproducer (fails on glibc >=3D 2.43, succeeds on older): printf '#include \nvoid f(void) { char *p =3D strrchr("foo", 47= ); }\n' \ | gcc -c -Dstrrchr=3Dkernel_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=3Dum defconfig + CONFIG_BLK_DEV_UBD=3Dy, clean compile - Boot: UML boots to Debian bookworm multi-user target - COW: UML boots with COW overlay (ubd0=3Dcow,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) +=3D vfio_uml.o # pcap_user.o must be added explicitly. USER_OBJS :=3D fd.o null.o pty.o tty.o xterm.o vector_user.o CFLAGS_null.o =3D -DDEV_NULL=3D$(DEV_NULL_PATH) +# cow_user.o is a host-side helper that uses libc strrchr(); undo the glob= al +# UML remap to kernel_strrchr for this translation unit. +CFLAGS_cow_user.o +=3D -Ustrrchr CFLAGS_xterm.o +=3D '-DCONFIG_XTERM_CHAN_DEFAULT_EMULATOR=3D"$(CONFIG_XTER= M_CHAN_DEFAULT_EMULATOR)"' -- 2.49.0