Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp3239719rdb; Thu, 16 Nov 2023 04:29:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IGTKrwqsAqm6d8u+/CRL0GuMC5aXhTcfUklWjg04KHIIqJWkAFfdw//1ROJGRoPRqntS/Hx X-Received: by 2002:a05:6a21:998d:b0:159:c07d:66f0 with SMTP id ve13-20020a056a21998d00b00159c07d66f0mr2225351pzb.6.1700137764124; Thu, 16 Nov 2023 04:29:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700137764; cv=none; d=google.com; s=arc-20160816; b=ExlBpAjzH67ee/GO5FB6nQuRLLd3AxzPmCkyIan8oLdpz0u9wH43cCzbUIDId77xg/ XkjxY37+DFpFEpFMFcfBmU1a8kB/8GrnGQMxXN0Fv0EkbfJ+lgAiTQWgyCVjr0XfQ4aX SHlOo9Kz84dTvVLFRpuEuEYpWqMWpOXcWLrzBYVaS9raR5ygLIwumA2LKHEco3JhukdW pDaascWWab+8C1ObTuunwcfnC5ejfYS3fU5hKGhTufJfbUZN4uVjngtIg/mLn8YBSxsQ MSi9VE+fSeA1F9zLjPMOxxbYb2N2zfcFp7PjSYfDaGb9AlYYMirz9RE0SuXOv7OfzTkj Pmvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=9hPIqMXoWvfcppxMdajShEzYF7R8FxwzqhaRuc88+UE=; fh=SBpw61mOVT4S9DSNa8wbPMWahoVI6l9aFsuZqyyM2PI=; b=EUFUR9DTEP8qEbusTn3ceD0c1v2kGIX/LioCzPPX2iCe1BXMVVCHfa37LL8VP+Gzob M40UuXYSgzn38DBaXR2RlyVUunRFoX+qWQbsriYQ43WhJYJpE+q3W2K3A8ZBGG5csLEI mWQEt7wkXAeG+Sj69pFKgWV/0+fEgREOg0aYamMegn5g6mVQ4OWTwh4oI5vpE7EiY9Hx tAfSbY+oM3PtSW4qN1TFZyPyFMeNWPNhJl5bBOFJNA3se9c9mxLvfb2avifiJnCyqD6N M1krbScqfGApSOp6MVg178+CR0Svzl7I73lF5uRGVEusiSftS6bLRDJC/RllJC8qIIac Noxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codesynthesis.com header.s=mail1 header.b=ERgrdYPG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id z125-20020a633383000000b005c1b27f8ef2si6301680pgz.49.2023.11.16.04.29.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 04:29:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@codesynthesis.com header.s=mail1 header.b=ERgrdYPG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id C0C2F817C3D4; Thu, 16 Nov 2023 04:29:21 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345213AbjKPM3D (ORCPT + 99 others); Thu, 16 Nov 2023 07:29:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345194AbjKPM3D (ORCPT ); Thu, 16 Nov 2023 07:29:03 -0500 Received: from codesynthesis.com (codesynthesis.com [188.40.148.39]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C007E1A5; Thu, 16 Nov 2023 04:28:58 -0800 (PST) Received: from brak.codesynthesis.com (unknown [105.186.92.249]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by codesynthesis.com (Postfix) with ESMTPSA id DBBED60B62; Thu, 16 Nov 2023 12:28:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codesynthesis.com; s=mail1; t=1700137737; bh=L8/2LumOofn84zXo/hfXIiuePhx2MJbJ78D9E/u+btg=; h=Date:From:To:Subject:Message-ID:MIME-Version:From; b=ERgrdYPGWBEfLSc7qvrMU5juoz3+g0RVHUNxX2DP6FtG8RIdyzAabyWzF7RAnseLg 93y6YMDpDr/EGrlOHVt0rzAvhIB8n3Ul53QT87WX/z0i9kaWn7aU8dTgDy3rdJoa/J 6dQDjHp6EZdwp0LXZbr7fCawWp+6Fbg/GWc/oMGhS7FGxFziP8oScx7KAATZXbByjY 9ClU96Li8prdToTs+nr9tuXQsaq0kDFHJPTcukHvBg85R1Cfzk4Ag8uo2iBCGmdrGl esd5oHhNCvAJNmlKT1anEwXtnRthHAi4EwpaHpXcZ4QXgaAJU/Pi7kibd9GnLoB5yj 0kI3DJUkhqLaA== Received: by brak.codesynthesis.com (Postfix, from userid 1000) id DC290146149; Thu, 16 Nov 2023 14:28:57 +0200 (SAST) Date: Thu, 16 Nov 2023 14:28:57 +0200 From: Boris Kolpackov To: Masahiro Yamada Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] kconfig: fix memory leak from range properties Message-ID: References: <20231115041653.810045-1-masahiroy@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231115041653.810045-1-masahiroy@kernel.org> Organization: Code Synthesis X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 16 Nov 2023 04:29:21 -0800 (PST) Masahiro Yamada writes: > Currently, sym_validate_range() duplicates the range string using > xstrdup(), which is overwritten by a subsequent sym_calc_value() call. > It results in a memory leak. > > [After] > > LEAK SUMMARY: > definitely lost: 0 bytes in 0 blocks > indirectly lost: 0 bytes in 0 blocks > possibly lost: 0 bytes in 0 blocks > still reachable: 17,462 bytes in 20 blocks > suppressed: 0 bytes in 0 blocks FYI, there are quite a few other memory leaks in Kconfig (as evident from the still reachable value in the above report). I believe I've fixed most of them in this commit: https://github.com/build2-packaging/kconfig/commit/cd9910e3636515b2980ce1d37d1984ccfd6b4cb9 In particular, I could load the Linux kernel configuration repeatedly in a loop without causing any memory leaks or crashes (which were common due to the state not being reset properly). I believe the above commit also includes a fix for the sym_validate_range() leak in question, though the way it's fixed is different. The potential problem with the proposed fix is that it may be impossible to decide who should free the shared value.