Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1587663pxb; Thu, 4 Feb 2021 17:45:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJzLZ7F0aVY8rC1ea8JoWC5brZ9Fl0cg5pzyVAXG220+KCgiFW/qAzQWfZgjsXLnZ5dFDPX6 X-Received: by 2002:a05:6402:ce:: with SMTP id i14mr1363821edu.42.1612489518873; Thu, 04 Feb 2021 17:45:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612489518; cv=none; d=google.com; s=arc-20160816; b=hvGN3LD/WxB+POeeF8B5aR6Xs+KknAjN3JMAlChGZB7wQIDdeIXU0iLILu3LjW1Lf3 namlTxL0HLE9uUEcy7vwOm94eXuodeuF4bsXsL5ZgU7ok4VWGI+Y0GilU3UzacbKKXcY x6Gk+xm09N1KcRfd3gL+Pgfzv+smMdV+9mCrkZLcl+WiCUn4LEMFItp2aUbMd04P3hsB RwjU+Yzq6IuJ2WpjoAz6yxEOHQZIgU8U7AtTi7752aTs8Req0mxR7SwuFQtCmH2lu6Ww DiRAviupbIkYkgPXiwaEixu/YPmrc3+u7ISjKTk/qOxshHwidaxbDcjkM7tiEelBD551 xxgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=NQqkRy6HT3Ec6uFrxpBIRxn1t4I6UJT6bne6q4G1RE8=; b=fcAzmsw7emzhG8qCKx1KjxsqSAH9w5fUP7ydg1eatwtkUi1UzNn28v6JPlsaKJPuq9 iToN25hiuRk3EZqHoZWrHAO7hpsJuWAuKo36o/2Fv+L7rfVWP76S/1Vecu97FvesgJgu 1ubsLDOFWrUyNS7ktNA28801muV/0uwFG6R0LCQJuIhDoZj0h9BKSLBVdiUd85TYk+2v fe+Ie3CD1TG4Y711Sq91RbRsXicJBO398gKpw8oLekAnFwUJdYbyXO5RQBhUTkMDp/iZ 0xNCW8FjQWpLjx2gGWzpHcLjGAsOslYbNAKveRcTB+nc98kSrPVyyVDro4SDWfh4RXSn C8UA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Jwh1SNmM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s2si4726700edj.13.2021.02.04.17.44.54; Thu, 04 Feb 2021 17:45:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Jwh1SNmM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239516AbhBDT6x (ORCPT + 99 others); Thu, 4 Feb 2021 14:58:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239537AbhBDTxK (ORCPT ); Thu, 4 Feb 2021 14:53:10 -0500 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66AC7C06178A for ; Thu, 4 Feb 2021 11:52:30 -0800 (PST) Received: by mail-pl1-x630.google.com with SMTP id 8so2310452plc.10 for ; Thu, 04 Feb 2021 11:52:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=NQqkRy6HT3Ec6uFrxpBIRxn1t4I6UJT6bne6q4G1RE8=; b=Jwh1SNmM09W0b2lds4FNFXFt5l4+5CqpnnDLabPHZxK3YUOmPyGtxewOfBhDc8kcBx lnEzfARtiB14vojJlUbJZe8EvC4dLUE9k9+qDL0veVMMKqCoBD+GOlU5cQD9GgeWrp+0 ZODGaVweUBY6zBbz9TRqY8UqgpIDNyg6+hgUd9ebvT3Vz30SN4ILrRAJjTMuXefE9hmS Z9RqU1MuyjMn4K46RHKHaSfivRFsWRWLCsZP0+psO2vwLhAUpIu39eW6NTgRshG0LW3g 4tVnCpl9CV5gKdQkX6o01H13DBjwUCRRcwUQlOmKruYeIRSbVcMGQNq7UetJwNlhNWDj L3Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NQqkRy6HT3Ec6uFrxpBIRxn1t4I6UJT6bne6q4G1RE8=; b=dXEvFrI9BGsszsp74e/CejGoGma1OlpK9qqWXUi287stcBIbLaw1Hl8p8hoZ+9LtzV ErPCJ57bWbf6XPDXxg6N8O4/xzqI3H8ZSuzxqeEJrlJD9v8ccnOOIRHhh9vaTFrXxFxA aObBatXmdkFx6KbsN/mFH5kqnUKEFRRFb0Jv63F7Bto+jfMPS5l+AYBmaSRTqjqYf0Os mNVZVDMwv2vGWXOf0v9MO3odrfO1UUoFOpcKzNHxi62Wl6H+reQTm6VxTwceET3HIRCU cm2yuaNYeD7Ka1FVQ2MkJvOutaLpa5JEVkwbiy3/ibrJrg8tYj+cnbLCD4OjyNi6Nsmf 3tow== X-Gm-Message-State: AOAM530Itd7978a3RUlZ1zYHN89ztpskr51VsO0Wn02jMh0iXKx8mqFU XQt5Lr3uFVOm0CnGacDktRtqWegYriQVR6zYuyPf4+nMEjGZmQ== X-Received: by 2002:a17:902:f686:b029:de:18c7:41f8 with SMTP id l6-20020a170902f686b02900de18c741f8mr891572plg.65.1612468349675; Thu, 04 Feb 2021 11:52:29 -0800 (PST) MIME-Version: 1.0 References: <20210204173045.1138504-1-dlatypov@google.com> <20210204173045.1138504-4-dlatypov@google.com> In-Reply-To: <20210204173045.1138504-4-dlatypov@google.com> From: Brendan Higgins Date: Thu, 4 Feb 2021 11:52:18 -0800 Message-ID: Subject: Re: [PATCH v2 3/3] kunit: tool: fix unintentional statefulness in run_kernel() To: Daniel Latypov Cc: David Gow , Linux Kernel Mailing List , "open list:KERNEL SELFTEST FRAMEWORK" , Shuah Khan Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 4, 2021 at 9:31 AM Daniel Latypov wrote: > > This is a bug that has been present since the first version of this > code. > Using [] as a default parameter is dangerous, since it's mutable. > > Example using the REPL: > >>> def bad(param = []): > ... param.append(len(param)) > ... print(param) > ... > >>> bad() > [0] > >>> bad() > [0, 1] > > This wasn't a concern in the past since it would just keep appending the > same values to it. > > E.g. before, `args` would just grow in size like: > [mem=1G', 'console=tty'] > [mem=1G', 'console=tty', mem=1G', 'console=tty'] > > But with now filter_glob, this is more dangerous, e.g. > run_kernel(filter_glob='my-test*') # default modified here > run_kernel() # filter_glob still applies here! > That earlier `filter_glob` will affect all subsequent calls that don't > specify `args`. > > Note: currently the kunit tool only calls run_kernel() at most once, so > it's not possible to trigger any negative side-effects right now. > > Fixes: 6ebf5866f2e8 ("kunit: tool: add Python wrappers for running KUnit tests") > Signed-off-by: Daniel Latypov Whoah, nice catch! I didn't even know that was a thing! Reviewed-by: Brendan Higgins