From nobody Thu Apr 16 08:24:02 2026 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (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 46008430BA7 for ; Sun, 1 Mar 2026 05:30:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772343044; cv=none; b=rOA+tWmcelzcvHQPjPDPm+fKL39dvTg88yiF+Q897OKZPy+G5tKndpddh8DlATOQ8q6JAEL/67BvbwjBJmzcve+0gLqjivYNMUDqpenNum9JUD0rZDm8JVd/e6CwrRMIkVII3eO00ap52Txv1AulxC8mRpzfp6HfQiOu7DNqxz0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772343044; c=relaxed/simple; bh=dq3QrScFzEiNuvFUoruuOOgE0AVxEBmjasRRXurv3s4=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=VdympQDzyu+wjS6I4dZGEm5tzfxJ5OS4/ozhK7wGHZ0nGcHfvKF6aCUKUWTaoH6MXL9xfjFIdiD/wYRm2XWJTeGOmvfkRsgE9rW6ksTU9JlDGXF50j+DxDHAZSwPZwDcdcLXXS8YpqUWbDLjJ+y0tVYxOpPGkKcNE3WA16Afo5c= 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=ILI2a3+Q; arc=none smtp.client-ip=209.85.210.177 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="ILI2a3+Q" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-82742aa5a3eso1507001b3a.1 for ; Sat, 28 Feb 2026 21:30:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772343042; x=1772947842; 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; bh=gphs6okg7ep3NbC+1/P/oiofsq+k/MlUJDmvkEjtKJE=; b=ILI2a3+Qi1kzJY6UlEt4QbWps+vFTEqoPJwBnMeMqTQdMDMp+VhV/HMq68ykLWoky7 WbSa4Ahk9Vw3RNVA+mv4smbfxgBGzGpAzAWSQxYd8bJBimFzj/lnNJXeL6zt3flD352V pUPKRvSkMReQfAd+QIsHV1Wkg1qmB4uLV2b+nF6CaFDrjNIaAAv1vmRfSANfCwGSEFPO 03VkdXK1coSyYgDQihNvIJwTZr8w09Adw4T5k7Kvwt/Z4/OKdHaJyv8sIAc4yp8t8kZ4 QZcfT98IrmwMVLncLY57kuT9snk6a0NmM9bNhHNGmt9a+wZrVXpDl/83KWDx/MgPt7GH 91vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772343042; x=1772947842; 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; bh=gphs6okg7ep3NbC+1/P/oiofsq+k/MlUJDmvkEjtKJE=; b=cBgMac6Um7vGUgjEYOEgtnywcbCdUuphchp/utZIVf0tGCUVQ1Y+o2JXOt2z0x2qOn tZ9ZLVZ2pTHldQsM2rSYxirwLzf4B/bYZhQVTezPQbELwyNVqq+tr076MyqUykpIf3/y TkY5Fr367enJMAyEeP2BHfoznw0utybu+ikwPMckz4kOpc2eGxcpkjeCPbANChcTkARZ 3C9AgNmNG+O1yqgM9CRvs7fClomBkywuDA6rVY04YGUXbGITbvieVA6XOstCAC20q6Y2 P0nIB32cqGnUzyUAx4Ysr4YIhd9II4gohbB65iexivdWTDHHmMEYUCv08TXauXieWLRl SnOQ== X-Forwarded-Encrypted: i=1; AJvYcCXkJ7W+8EnzYAPwobrfJNTqiFCZ1tHok9+4getaI5UjExWv8zUSGIUXt97ZniuWsE/wiTGw49J5tOl1cPY=@vger.kernel.org X-Gm-Message-State: AOJu0YznCtweAi/YlE05UEDtcGlKpWuz3Gn9AyGP7uEfDHcUyVV1D8n2 aTq+0JWlI1yYfXWcTWK4u+NmGe0ZGwe7DSQ8YK6xrRKIRj1NuSXf2uTc X-Gm-Gg: ATEYQzwYDmbHwgKIa9wE3xRMRqCCRPWbYGoERzdu0p4mNGtIOxIvqceMNw5LfyDoIs2 l1QcXfLeFXcA3iLAdC1D/Z7PWPTl8VrqZgCpO+t9S6N32B4OfoeNV09X5cFKghdBxB66l2BJWAC xmHDcMuzzxsnQj2xLvE5ZYqWrWxwE8In4/Cqu82sdm7gq3AhR8AYsEwzw7QT/IrGfY3GPq4287e 7rU0eTnSYimBjUeSZSHw+Zs5sMzAFDLqq67IndOWEX7rkNrc2BVrS/DSCEzuryAVm6Prip4N1Gm zFPE73z3IaEwMFsaaS5//B5OuxwyO0jlYFrGqIraBHYgem6DD0Ikg3DWHWk+bap3sps6/mHfz7o rjdb33oVVqKewpuon8diQMk8ObjDDjLqfvePkGEWfAuJ+hDpcTzWqa96Z8Xjs1vPoTgv3LTX94q c1RmMUGGsOCdp6uT9V5II2rsgHUq6GE7EHfhk= X-Received: by 2002:a05:6a00:189f:b0:823:3fc7:4c84 with SMTP id d2e1a72fcca58-8274d7b86aamr9068957b3a.0.1772343041521; Sat, 28 Feb 2026 21:30:41 -0800 (PST) Received: from localhost.localdomain ([36.112.120.108]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82739ff372fsm9584583b3a.31.2026.02.28.21.30.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Feb 2026 21:30:41 -0800 (PST) From: Xingjing Deng To: nathan@kernel.org, nsc@kernel.org, rdunlap@infradead.org, masahiroy@kernel.org Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Xingjing Deng Subject: [PATCH v2] kconfig: fix potential NULL pointer dereference in conf_askvalue() Date: Sun, 1 Mar 2026 05:30:35 +0000 Message-Id: <20260301053035.1950087-1-micro6947@gmail.com> X-Mailer: git-send-email 2.25.1 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" In conf_askvalue(), the 'def' argument (retrieved via sym_get_string_value) can be NULL. While current call sites ensure that 'def' is valid, calling printf("%s\n", def) is technically undefined behavior and could lead to a segmentation fault on certain libc implementations if the function were called with a NULL pointer in the future. Improve the robustness of conf_askvalue() by providing an empty string as a fallback. Additionally, remove the redundant re-initialization of the 'line' buffer inside the !sym_is_changeable(sym) block, as it is already properly initialized at the function entry. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Xingjing Deng Reviewed-by: Nathan Chancellor --- v2: - Change commit message and use fewer characters in modify. - Link to v1: https://lore.kernel.org/all/20260225072246.3475275-1-micro694= 7@gmail.com/ scripts/kconfig/conf.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index a7b44cd8a..0d32183c5 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -297,9 +297,7 @@ static int conf_askvalue(struct symbol *sym, const char= *def) line[1] =3D 0; =20 if (!sym_is_changeable(sym)) { - printf("%s\n", def); - line[0] =3D '\n'; - line[1] =3D 0; + printf("%s\n", def :? ""); return 0; } =20 @@ -307,7 +305,7 @@ static int conf_askvalue(struct symbol *sym, const char= *def) case oldconfig: case syncconfig: if (sym_has_value(sym)) { - printf("%s\n", def); + printf("%s\n", def :? ""); return 0; } /* fall through */ --=20 2.25.1