From nobody Thu Apr 9 20:25:12 2026 Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.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 EE7EA30C63B for ; Fri, 6 Mar 2026 02:17:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772763437; cv=none; b=RjsIA7MQ3+kE8tHz1kIzmsHJDCFh7DjPNnXcvIEupXq93kPWiQXcWCGDg9MPP7MgDOIoBXsz8zgfL/M44csMRDF87GiM2YpbKXDibGzg6UFjSS8bdjVQtSLYMP+NHF99b0X97DManLYMFNajtiBeGJrTaPXitaXsC37a+Gtfh88= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772763437; c=relaxed/simple; bh=j65gApWA27BQIdeGFn5i9iKCRaNJQ4DyC0qDkjxGBzk=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=TwdOD4968uE9Hxergl5G3F6Y/kvtHVtJHDJOY4QlyBC6GrjqYUxtmfr8XnYJCsHv84vRn5HsNWdmdbAyG/hF8mSnnLDaegnSApKB9QPJ1uhl3F3n7OzwAvVrshNDIdXTgC5C1hbLBZIrtCyN5i8MisDY6ZmBYDEqVjqiRZQd9bk= 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=BqmUrOVt; arc=none smtp.client-ip=209.85.215.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="BqmUrOVt" Received: by mail-pg1-f177.google.com with SMTP id 41be03b00d2f7-b6ce6d1d3dcso3064616a12.3 for ; Thu, 05 Mar 2026 18:17:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772763435; x=1773368235; 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=aComa1aLtd4u5sNYHRHFrAGjjOKe8ZcDgb4RgBRD3SY=; b=BqmUrOVtyCAo42bo0aq+dKCYa0jXo8iDY9zT+AFdmDoG5YYNrGzqGu/qPICb8t3/3J y+zqiW1sUkbbi/Cbu1/nYc7u2mDNtodCc4dtMUxaoQhdG/MftZ17OLGkoJvzsDgujY/I 0RwNiBR0jo4h4zJ3U33aXka9hInl+Os+CCVY6xJhZfqWDnFg6ATxZDFZUpuDvjTZNEEc oXlUGfwFYgjW/N0xqvJcIvc8zYaRFQHHe8rS7xkophMOZaCua2lSvAy0u7CUPwrugrCS jOpUAhJwwMi1AMlAgLBThGZXM8ssQo2uIjQR72tJmKWvOZO5ICmy0EQEmS8OMoga6Tra At9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772763435; x=1773368235; 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=aComa1aLtd4u5sNYHRHFrAGjjOKe8ZcDgb4RgBRD3SY=; b=XZzKMW0rjzeb7sqcT1PgXjbHMZ36XTBOU7doo+HJzXSOuTYfAbk3Q29icmsG3pASI7 BavYQAMwsDhs2w4XfIBRY07ANuh5D6lQyMoqCakasOGdoB3I7H7LraSYJVzPZtU2m7m+ aFnlrE4gqudGWKpbAGQVIPrFJOK5WPQV4lC4Pw4kggvY62Jn8TRP6ytOZ2zmCUhRExD2 5+2LFK8tiYsD2K0kf9xi2oAOkNQ9TCLrR4slowTZu0S89RtVUFx0ZzIcjyYR3JcsFlWc pgTUrAsTTGopKbUfIE3cJT0tY+5OvXyAJi0/qS1b+bshtNMqWy/GjdpUrj7xAFhDtHdu tJQw== X-Forwarded-Encrypted: i=1; AJvYcCVdVLfbKCnB93fFY++Jd+Wn2Y1qKLHTEANfcpnJf61ZJbUyeB8zehuwfYYDZ3PD01lFhUYjEMNPNvRXbv8=@vger.kernel.org X-Gm-Message-State: AOJu0YzelO80g5nJD3ZGDPHyLoIUiLwmXzeUTQ8ioXX5HKVzxSqACche mIEVTziYIvZgNMblAepkgA3Z+ymbKYMN3lMyhAxTDv/1VCGi6IeOtCP/ X-Gm-Gg: ATEYQzzE4js1+4/Wtv2aw+dt8ICT+PAVXoBQP4YcNQTM8Rv2jmzSVoJ1EEmqV9dOMux 7FLBsKw8+nJLXttzJf+Sul/CgEZnCd0clbe1BKPWP93imDFx6YGjOTBShQU4fQagZD0XfXZmFi8 RuZE/uUjoNFCusY54tt4WfIBJmZ7lV4CyJyZySdltM9VDokuQUsm40kfSsgCCuK6ALKnJQK/ktY hfGTBk5K5KmQuwt3IzvNsOGcwosQyUTzZhCn4Q82TTxCO30lYkMDkk4B2MsECJvRcvBdfaTMyZ0 p+/905m6/Ze19gbInWEd4mnxnUA0OizsfTiRmQUt4aIFxFCcgYjOnzsMqAFXrM74ziNpsKPM87V Cw3KRHgIQqHVhq0jHjA8xBfhujcAS/t9GiTVIkZRc7LTUKCCtdKcMU/eYIFGY28X+pAbPyXXUy+ ajTg0S2euVXnfv2/zyviJUebxBChGVxF+3cFJM X-Received: by 2002:a17:903:40c5:b0:2ae:6779:c8bb with SMTP id d9443c01a7336-2ae82362cf5mr6309595ad.5.1772763435205; Thu, 05 Mar 2026 18:17:15 -0800 (PST) Received: from localhost.localdomain ([111.202.175.108]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2ae83e57c1csm1134325ad.18.2026.03.05.18.17.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Mar 2026 18:17:14 -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 v3] kconfig: fix potential NULL pointer dereference in conf_askvalue Date: Fri, 6 Mar 2026 02:17:09 +0000 Message-Id: <20260306021709.27068-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 --- v3: - fix compile errors. - Link to v2: https://lore.kernel.org/all/20260301053035.1950087-1-micro694= 7@gmail.com/ 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..c368bec5a 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