From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A8061D7E5C; Tue, 21 Jul 2026 20:27:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784665624; cv=none; b=nQKoaygvvocQOtNs4iO1FE3tHILD+cAZs3+qq6pF3IjZJpLhAUlgmyHTPC2xCYZ5xbDO2KsPL3Cj/ngAiblkSJsGdWDUKUjSK20Fzs26WC/ZE0CfmPI17d/2wlGv6/EH/Sw1iVyI7X4oWeUIbFWhrqjpJqKIwNtC0QqD+3yISRg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784665624; c=relaxed/simple; bh=0LiHp40sm1nJDn6xRdt2icT+/ZzJtwvQFMNW6XnU2VQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V1xPvVVS79U+r5lKnF3HylYDsi91ZrI2c06QI8L379iEw59nA7PCY0PkEOPZiXfuqBxYyS0fE718X+0h2BZaL9/KVf96U0DLsVs4FxLUFAO9RghnVf4qi2wQBRRd92QNRUYoNXywStQ2qDbOMCXpYeAiqJDBWcOTyCCW5WqIc6E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=nB7qH2mp; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="nB7qH2mp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF7B41F000E9; Tue, 21 Jul 2026 20:27:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784665623; bh=QVEbPF9HruLNiZ+vvNV0fhdroLATvvXV7H+OlwSj2D8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nB7qH2mpbvuXlV8gJSHN55eQkaox5Zl4293Iln63qh0lpdy0hIqcWGv59azJfR5gi 1IFozLTZZZcoLs5YoXuMhndLxVkbRbk4jw84q53B5Ua6/W0t9JRiWtXKb8smGyQ3na LQeHDridXtEsDR6RnOwgw5iEIwfSLY/eyGI9CXrU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Xingjing Deng , Nathan Chancellor , Sasha Levin Subject: [PATCH 6.6 0375/1266] kconfig: fix potential NULL pointer dereference in conf_askvalue Date: Tue, 21 Jul 2026 17:13:32 +0200 Message-ID: <20260721152450.218714371@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152441.786066624@linuxfoundation.org> References: <20260721152441.786066624@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Xingjing Deng [ Upstream commit b9d21c32dca2167a614e66c9e27999b9e1c33d55 ] 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 Link: https://patch.msgid.link/20260306021709.27068-1-micro6947@gmail.com Signed-off-by: Nathan Chancellor Signed-off-by: Sasha Levin --- 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 662a5e7c37c285..6c4ff012a05ebd 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -323,9 +323,7 @@ static int conf_askvalue(struct symbol *sym, const char *def) line[1] = 0; if (!sym_is_changeable(sym)) { - printf("%s\n", def); - line[0] = '\n'; - line[1] = 0; + printf("%s\n", def ?: ""); return 0; } @@ -333,7 +331,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 */ -- 2.53.0