From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.50 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796310768; b=Y6e2CiBo/1XpDK2vJyawz+ByghSqhlD18sSuQR1VC3q1HoAxvdjEJqPCrsjRFDxNbnkG 6fVWbEYBdCihYk6jQ4g3dTvUPXal52n79hTcyXfWT3vRKqWEpNaXuCi+Q2A8JATB4P4P+ 4NOtWGkdIX9ewk5cHacBlKutVKgq5S2gpqTUCNDoQ/mSWONQhnKogLIfoXyD8Ox4eE5LD 7mbe8PMFNl+sUDKj1GrZJP94WqwFZt8piZgjz6IgOnt4/XjYdSmfjL77hPAOUMA/bzEAy fHINt8RX54yOwkxZQ4QXISJbG4m+OKefA5ScXV4u+WG+1hLSV8+MAyJvJ9MHMfcRjwA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796310768; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:Sender:Message-ID:Date: MIME-Version:User-Agent:Subject:To:Cc:References:Content-Language: From:In-Reply-To:Content-Type; bh=4HFr9el7Y6P8AWEKlCvon+0Ax6McoykDWAg/Q8ZDAyA=; b=4vTZSJxP+xg+RmK+aGvYceCtq9ABXPfNMRUL04m8SaGPLQDz06+wJijE9+SXoJLDGQS4 +pz8hY8zRkxm3mmAsE1GAnEbfHkD0pLysyoAaJ9aHJ+LU/9h7eJxbdh3E9isnz3FZ5naO TRIV5Z2j6VkpQR00rAcZw0A7PzbcWyhfyK9+B7bMJI6RaAtxURYWnciIJu3kcowNHAGNi 8O9NFpV9CZtMOBybICNh2rccXeXoZ0Gt5eakzi9GS23e3TExTsW0t4HgS0YtK8yGZtWPy N6+tlR6OImVzeuHXlUm7WDzllXU6/BjRxdEFKoTS+TFYBRJbSNlywyZm5bK/g14upZA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=jkMTattz; arc=none smtp.remote-ip=209.85.128.50 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F492606A683 for ; Thu, 3 Dec 2026 15:12:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8F492606A683 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.a=rsa-sha256 header.s=20260707 header.b=jkMTattz Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-4bb6057b333so74263435e9.3 for ; Thu, 03 Dec 2026 07:12:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796310766; x=1796915566; darn=vger.kernel.org; h=content-type:in-reply-to:from:content-language:references:cc:to :subject:user-agent:mime-version:date:message-id:sender:from:to:cc :subject:date:message-id:reply-to:content-type; bh=4HFr9el7Y6P8AWEKlCvon+0Ax6McoykDWAg/Q8ZDAyA=; b=jkMTattzMMeFRzeJsiupzWIBGB1UE3pRuDwh0qHqOFuS5IZA8TggT3NGHoSptq0ooN o9unGqgrF8m/QRSnn+pZlsUpfNcdbCpS8le4H5aAnZLsvsnyTTBuS5TGJz4yNmKmZazs CBLLlKxhVqZkX2DUyhHnN72QyjC0w3rNC75oDu5cQcjR7WfLC9tuVC5wdITfJcs/FREe xirKW2n5OSfi5MP6RpksOklnRgpydhXV4Xp3zw/S39pOrMfWGPpkQdf3NNNUaBZrjhaI KGPfNpIS+IsAod9z2jAxgH6Tukalvuf4adw1BHL9XQdNsXIlJYz8QKjAGxQpoTSiNDRX X6EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796310766; x=1796915566; h=content-type:in-reply-to:from:content-language:references:cc:to :subject:user-agent:mime-version:date:message-id:sender:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=4HFr9el7Y6P8AWEKlCvon+0Ax6McoykDWAg/Q8ZDAyA=; b=r5RuxOoqyKwuPp7C2lr+VAbU11wdNlrP3dmeAX832mXKrtC7T2yBfdk4enYH4JiA9S PcXHR2g+OrE0Kbzc+O7twdD+6W2bXbDjXDaoZrhZlhAhU3wNJmnbi1YhFjnehule3nBX 4YoGOfLhWc2LerjCpnXgYXom4YB2QrNkH/6is4wYEQv+zxgbxPEcBgHMpV3m/vqf4387 b6/T8VI9MSh5+yPsdFK67zSFs66FEj/79uKQKONULhXNZibEc6Xn1ZhEEx0Ftt2xdIWu 5a48BsMhOqPcGsXmjUrqnK4CkBYs2r8K3c9S3QURSUiZYTQRLOcIshCTU3AGJbD8v5H7 SIaw== X-Gm-Message-State: APuU4Z8rSFF84aZlxM70dMnyshna7R4Rc4RDMG+GckPCYTTMsDG2RkR5 CiJWg8gdZu2lglduzQjQApgFjuGAsnjKL0JUsqrWoCZe0GoVP81hGtuo X-Gm-Gg: AZFdTZdNn8gryxlY3g7ZeL8BDMWGXAUnO8AQERaBoX5q/OCpi6Cgvi1uk7xuGDhSQDZ dw3EpELro86UVQuAMrofHV7nVoUEt1OsR4ODUYzVaDGruwnvuHW33UCz7IiCHOjel+1d3NqKEpI ZUEtfebXA+Rp21hfTxmCp6O/G9E8+a8OLN5cGxYDyOnvKlsy5HzpgLyX6Qu6lsCdWc+r2zmuzK1 ZsEzTpIX74iplEBUWaIo2pjlbGH+gIEF0557B3E2K199/rWbejWOeeosYmp1VGXQQQLu1Jbc6Y+ AjJwzv/ql1c3xBqLkZt5iqu8c8Zq725fJ6lWDIcHcpFEUc451iKZG+B3Fd5Name3db7ii6p8jH+ LFMJkOPl1d3X+iSadn042PW6GA0DSg4QB9CGyw+/GCMjSj2/AZ5r0+yDVE9pHFzfX3TtgQV545W S4EzqAJ7wJN0o5msnL9S8HaI600HC7LgHwfqwqeiAWCR56b7T8oRqgCEp4yuSrE4/pdmYk8oWOb RPLQv80qPEanqTqptVPSd8mJmJAV03r7W+y6hC3zOQarKNr+LMJ14NN011Lc3TGeN+eEW+oY88G HJREp0c4xTRLDMb1ny5AcF1hjelhtH/iWdKqVMuU3l/jCk41X00tKwxDOgBExQpHBP8DvH+YBr0 Sm+F39gZpOEgoOkqaDUEH X-Received: by 2002:a05:600c:8b76:b0:4bb:b796:66f8 with SMTP id 5b1f17b1804b1-4bbb7966874mr360433075e9.21.1796310765704; Thu, 03 Dec 2026 07:12:45 -0800 (PST) Received: from [10.128.10.232] (195-23-151-163.net.novis.pt. [195.23.151.163]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bbe0066657sm66551935e9.11.2026.12.03.07.12.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Dec 2026 07:12:45 -0800 (PST) Sender: Julian Braha Message-ID: Date: Thu, 3 Dec 2026 15:12:44 +0000 X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] kconfig: tests: avoid mutating extra_env dicts in Conf To: pavee.zheng@gmail.com, Nathan Chancellor , Nicolas Schier , Masahiro Yamada , Ulf Magnusson Cc: linux-kbuild@vger.kernel.org References: <20261203-patch-kconfig-tests-extra-env-v1-1-e48cf80d6d59@gmail.com> Content-Language: en-US From: Julian Braha In-Reply-To: <20261203-patch-kconfig-tests-extra-env-v1-1-e48cf80d6d59@gmail.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------zDB4jDkGFmVAz0VhJBAhXYEx" This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --------------zDB4jDkGFmVAz0VhJBAhXYEx Content-Type: multipart/mixed; boundary="------------Lnu7F0DpNVVOTfT791pukXkY"; protected-headers="v1"; hp="clear" Message-ID: Date: Thu, 3 Dec 2026 15:12:44 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] kconfig: tests: avoid mutating extra_env dicts in Conf To: pavee.zheng@gmail.com, Nathan Chancellor , Nicolas Schier , Masahiro Yamada , Ulf Magnusson Cc: linux-kbuild@vger.kernel.org References: <20261203-patch-kconfig-tests-extra-env-v1-1-e48cf80d6d59@gmail.com> Content-Language: en-US From: Julian Braha In-Reply-To: <20261203-patch-kconfig-tests-extra-env-v1-1-e48cf80d6d59@gmail.com> --------------Lnu7F0DpNVVOTfT791pukXkY Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Pavee, It looks this is your first time contributing to the linux kernel. Welcome! On 12/3/26 01:39, Pavee Zheng via B4 Relay wrote: > From: Pavee Zheng >=20 > Conf._run_conf() and Conf._allconfig() both use a mutable default > argument (extra_env=3D{}) and mutate extra_env in place: >=20 > - Conf._allconfig() writes extra_env['KCONFIG_ALLCONFIG'] when > all_config is set. After any call to allyesconfig(), allmodconfig(), > allnoconfig(), or alldefconfig() with all_config, subsequent calls > with all_config=3DNone in the same pytest session inherit the stale > KCONFIG_ALLCONFIG entry from the shared default dictionary. > - Conf._run_conf() writes extra_env['srctree'], mutating both its > default dictionary and caller-owned dictionaries passed via > extra_env (such as warn_changed_input in > scripts/kconfig/tests/warn_changed_input/__init__.py). >=20 > Default extra_env to None in both methods. In _run_conf(), merge > extra_env into the local env dictionary and set env['srctree'] there > instead of mutating extra_env. In _allconfig(), build a fresh local > dictionary copy before inserting KCONFIG_ALLCONFIG. >=20 > Found with ruff (B006) and prepared with AI coding assistant help. > Verified with ruff (B006,F,E,W), scripts/checkpatch.pl --strict, and in= > a Linux container with "make testconfig" (35 passed) plus an end-to-end= > regression check against the compiled scripts/kconfig/conf binary > confirming no KCONFIG_ALLCONFIG leak across calls and no mutation of > caller-owned extra_env dictionaries. >=20 > Fixes: 022a4bf6b59d ("kconfig: tests: add framework for Kconfig unit te= sting") > Fixes: c9aa7d862144 ("kconfig: tests: support KCONFIG_SEED for the rand= config runner") > Signed-off-by: Pavee Zheng > --- > scripts/kconfig/tests/conftest.py | 16 ++++++++++------ > 1 file changed, 10 insertions(+), 6 deletions(-) >=20 > diff --git a/scripts/kconfig/tests/conftest.py b/scripts/kconfig/tests/= conftest.py > index d22c080a4e40..38e6ab2c264a 100644 > --- a/scripts/kconfig/tests/conftest.py > +++ b/scripts/kconfig/tests/conftest.py > @@ -37,7 +37,7 @@ class Conf: > =20 > # runners > def _run_conf(self, mode, dot_config=3DNone, out_file=3D'.config',= > - interactive=3DFalse, in_keys=3DNone, extra_env=3D{},= > + interactive=3DFalse, in_keys=3DNone, extra_env=3DNon= e, > silent=3DFalse): > """Run text-based Kconfig executable and save the result. > =20 > @@ -54,9 +54,6 @@ class Conf: > command.append('-s') > command +=3D [mode, 'Kconfig'] > =20 > - # Override 'srctree' environment to make the test as the top d= irectory > - extra_env['srctree'] =3D self._test_dir > - > # Clear all KCONFIG_* environment variables > env =3D { > varname: os.environ[varname] > @@ -64,6 +61,12 @@ class Conf: > if not varname.startswith("KCONFIG_") > } > =20 > + if extra_env: > + env.update(extra_env) > + > + # Override 'srctree' environment to make the test as the top d= irectory > + env['srctree'] =3D self._test_dir > + > # Run Kconfig in a temporary directory. > # This directory is automatically removed when done. > with tempfile.TemporaryDirectory() as temp_dir: > @@ -78,7 +81,7 @@ class Conf: > stdout=3Dsubprocess.PIPE, > stderr=3Dsubprocess.PIPE, > cwd=3Dtemp_dir, > - env=3Ddict(env, **extra_env)) > + env=3Denv) > =20 > # If input key sequence is given, feed it to stdin. > if in_keys: > @@ -176,7 +179,8 @@ class Conf: > defconfig_path =3D os.path.join(self._test_dir, defconfig) > return self._run_conf('--defconfig=3D{}'.format(defconfig_path= )) > =20 > - def _allconfig(self, mode, all_config, extra_env=3D{}): > + def _allconfig(self, mode, all_config, extra_env=3DNone): > + extra_env =3D dict(extra_env) if extra_env else {} > if all_config: > all_config_path =3D os.path.join(self._test_dir, all_confi= g) > extra_env['KCONFIG_ALLCONFIG'] =3D all_config_path >=20 > --- > base-commit: 799dd936553182df5770dde7f38d94c8337df75a > change-id: 20261203-patch-kconfig-tests-extra-env-02d8f573c5b0 >=20 > Best regards, > -- =20 > Pavee Zheng >=20 I like the code changes for improving readability, but AFAICT the problem in the description is purely theoretical, and the existing code cannot actually trigger it. Ruff B006 is part of the 'suspicious' class of lints and are more of a "best practices" thing, not guaranteeing an actual bug was found. If I am mistaken, please provide the steps of how I can reproduce a real issue. Otherwise, please remove the fixes tags and add an explanation of Ruff lint B006 to your patch description in a v2. - Julian Braha --------------Lnu7F0DpNVVOTfT791pukXkY-- --------------zDB4jDkGFmVAz0VhJBAhXYEx Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature.asc" -----BEGIN PGP SIGNATURE----- wnsEABYIACMWIQT6qjll++tIFxF8TUPElYPCBXNxIAUCaxGG7AUDAAAAAAAKCRDElYPCBXNxIG+F AP9zZAhoiN+k9/mOblLd9vnXbZtybo02ul87bdIjs5YmpQEAxSfpuITu0C+wJskSe07nB9gaOthu pourI4Pkj9nKkQo= =YUA3 -----END PGP SIGNATURE----- --------------zDB4jDkGFmVAz0VhJBAhXYEx--