From mboxrd@z Thu Jan 1 00:00:00 1970 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=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,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 8BA77C0650F for ; Mon, 5 Aug 2019 13:10:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5D5672067D for ; Mon, 5 Aug 2019 13:10:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565010630; bh=rVdNOYNZGUrED489nDxiAoFBEAt2PWzy6ZMn4bS+Tng=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=TXkHCLFZoJ/LZhXwbiAu/oFKRrkWRAsbQvjUptMAJq4DvCp3fWCxJGCW35MBjrw7R r8myirqadvkHp7sp0cQ/gmx8R5Ou4FfcpvTlK28MEBCXWcBFRvn6qjLTVJBCGAOyLu 9n6J/kOX9/OcmHOp2ACV2HvAM8CmOevHdwGRlCIM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730329AbfHENK2 (ORCPT ); Mon, 5 Aug 2019 09:10:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:49380 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729988AbfHENK1 (ORCPT ); Mon, 5 Aug 2019 09:10:27 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 03B872067D; Mon, 5 Aug 2019 13:10:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565010626; bh=rVdNOYNZGUrED489nDxiAoFBEAt2PWzy6ZMn4bS+Tng=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GKHOcU5uKZHOVEPDe6KtmFri55Ugh6ShcYfeX0rBw6qIkTME0CRCjOOXPVLRGGyN8 uiOLFeqfXtzKC6HHblrZN5t1VWWP4SELiBpKH94Xdlmzx8wCyuFfbLxmO6HC2pY9yG 65P/DhydnLFRYAskQRrSqGxLSmJu1wvSRbDPNBFk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "M. Vefa Bicakci" , Masahiro Yamada Subject: [PATCH 4.19 42/74] kconfig: Clear "written" flag to avoid data loss Date: Mon, 5 Aug 2019 15:02:55 +0200 Message-Id: <20190805124939.270100307@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190805124935.819068648@linuxfoundation.org> References: <20190805124935.819068648@linuxfoundation.org> User-Agent: quilt/0.66 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 From: M. Vefa Bicakci commit 0c5b6c28ed68becb692b43eae5e44d5aa7e160ce upstream. Prior to this commit, starting nconfig, xconfig or gconfig, and saving the .config file more than once caused data loss, where a .config file that contained only comments would be written to disk starting from the second save operation. This bug manifests itself because the SYMBOL_WRITTEN flag is never cleared after the first call to conf_write, and subsequent calls to conf_write then skip all of the configuration symbols due to the SYMBOL_WRITTEN flag being set. This commit resolves this issue by clearing the SYMBOL_WRITTEN flag from all symbols before conf_write returns. Fixes: 8e2442a5f86e ("kconfig: fix missing choice values in auto.conf") Cc: linux-stable # 4.19+ Signed-off-by: M. Vefa Bicakci Signed-off-by: Masahiro Yamada Signed-off-by: Greg Kroah-Hartman --- scripts/kconfig/confdata.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -784,6 +784,7 @@ int conf_write(const char *name) const char *str; char dirname[PATH_MAX+1], tmpname[PATH_MAX+22], newname[PATH_MAX+8]; char *env; + int i; dirname[0] = 0; if (name && name[0]) { @@ -860,6 +861,9 @@ next: } fclose(out); + for_all_symbols(i, sym) + sym->flags &= ~SYMBOL_WRITTEN; + if (*tmpname) { strcat(dirname, basename); strcat(dirname, ".old");