Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8337DC282C3 for ; Thu, 24 Jan 2019 19:23:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 53702218D2 for ; Thu, 24 Jan 2019 19:23:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548357795; bh=c7ABTPHnUvdIWI6hbTHHcPlRHsYStvibjWY7l3osUNA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=UmCYDUGK2Fywi8ymbYSNFTfsc7k9qp7LYnZZZEtYAOMIGcVtaVe78k2QNFRGfRfDM fgFnsHdV3lxhzrKHPWLzsAkjfsXXgmqN46sb84gUuyMYn8VoW6zvqHklRw8fjPpW8Z 1xZfX27deeMCE+cQK3pplXuJwWkldREUyEZyAQuc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729794AbfAXTXO (ORCPT ); Thu, 24 Jan 2019 14:23:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:48040 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728388AbfAXTXN (ORCPT ); Thu, 24 Jan 2019 14:23:13 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E7B5F218EA; Thu, 24 Jan 2019 19:23:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548357793; bh=c7ABTPHnUvdIWI6hbTHHcPlRHsYStvibjWY7l3osUNA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HapcAzpMnnicYZfAqDgDawuU3QjhleWcfu2PN2wDvCMj2JfAEF/xKpCV+e/HdIC9z WuGerxkxr5zyv2gEvFN+gMxnm1VplWzegxFlMK61qHziqWh73zkE5R8RhRDrV2rsfF a/cMVrhQ9iXEyT1XmWJD/HK6xaPXWIni513sRho4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masahiro Yamada , Sasha Levin Subject: [PATCH 3.18 43/52] kconfig: fix memory leak when EOF is encountered in quotation Date: Thu, 24 Jan 2019 20:20:07 +0100 Message-Id: <20190124190149.792918931@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190124190140.879495253@linuxfoundation.org> References: <20190124190140.879495253@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit fbac5977d81cb2b2b7e37b11c459055d9585273c ] An unterminated string literal followed by new line is passed to the parser (with "multi-line strings not supported" warning shown), then handled properly there. On the other hand, an unterminated string literal at end of file is never passed to the parser, then results in memory leak. [Test Code] ----------(Kconfig begin)---------- source "Kconfig.inc" config A bool "a" -----------(Kconfig end)----------- --------(Kconfig.inc begin)-------- config B bool "b\No new line at end of file ---------(Kconfig.inc end)--------- [Summary from Valgrind] Before the fix: LEAK SUMMARY: definitely lost: 16 bytes in 1 blocks ... After the fix: LEAK SUMMARY: definitely lost: 0 bytes in 0 blocks ... Eliminate the memory leak path by handling this case. Of course, such a Kconfig file is wrong already, so I will add an error message later. Signed-off-by: Masahiro Yamada Signed-off-by: Sasha Levin --- scripts/kconfig/zconf.l | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 6c62d93b4ffb..485b19a461f8 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -180,6 +180,8 @@ n [A-Za-z0-9_] } <> { BEGIN(INITIAL); + yylval.string = text; + return T_WORD_QUOTE; } } -- 2.19.1