Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp7448301rwl; Tue, 10 Jan 2023 00:33:53 -0800 (PST) X-Google-Smtp-Source: AMrXdXu3uitpWJwOEXfnsNQyCvCvz9svkRbARRLFV9wJ+YXi1El1LAEnGHehOqDJMKu4TRUg74N3 X-Received: by 2002:a05:6402:1005:b0:47e:5b70:dea5 with SMTP id c5-20020a056402100500b0047e5b70dea5mr61108076edu.18.1673339632842; Tue, 10 Jan 2023 00:33:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673339632; cv=none; d=google.com; s=arc-20160816; b=QNRik2cwDqGDXv9zC4ChwyTVwUkSOt0ecVkz2OQorZRLbCYeF9DSuqpaNOhF5koc/Q vht/NIOZNE/5F5XEgPLg5ivKAl0atPc+1x/R0OBIR53INM2qfMC5hJrZSwqSuw82+f8e ewEU16QF3mG3FZSc9TC/OP2OK3ow59YDzLA3Bpq6TUTgj8b9JsURxkwhm86ac+0hyhrF jU5al4GmkbB5vfVtE6n/u4ULCidqKUCW82Zx8Jd4irPxE2ow/U9xqx1RIu2HnAiQHYET HmpKNAWqFXWp+nH667J1NAeAUadKcxJn2DFdOHcxWCkOwL+lv1CNDv0443AK6vfK4I5v 9s9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-signature; bh=/cbvjj95MLi+ox83pnz3idNl14zzkT1olk9CfjRT+DY=; b=lg8h/FudMFK85fg0a+7vNDewr5lUAYnTeXOlSSPd8J6+E0H2bj4iZ23FlWEp4+542r VeJ5rdCHGzVp0KgQtx/WSQnOc8w1u2G0m3g5Qj/Rkh6bMgwYzXx8D1rz+efWlVLeD4rF se2EhRkQiv9mqKaZ+XNYg8yCVAYhYgoZ1w9eCoZ5A0G/qN8noauZ8sEu7xTKg3AwcQIC jRfPnGf7xm/kEQ9cGgoqTYzt66oD8LS3W/mR7rpCEocMWQB1BtUjUqVzFmsZ+CAB2WfJ 42NlTFIfwClsCEPpNXxGy3mVIujxiNxEQyzygIAVBPZN3ZCBssjBRNHlzAXNo6bS1C8B m5yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=XZhwQMFP; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=3BS8mRyE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x14-20020a05640226ce00b004687eebac58si11542488edd.458.2023.01.10.00.33.39; Tue, 10 Jan 2023 00:33:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=XZhwQMFP; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=3BS8mRyE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237532AbjAJHvM (ORCPT + 53 others); Tue, 10 Jan 2023 02:51:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237209AbjAJHvJ (ORCPT ); Tue, 10 Jan 2023 02:51:09 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FB7CFD08; Mon, 9 Jan 2023 23:51:06 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 226B94E025; Tue, 10 Jan 2023 07:51:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1673337062; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/cbvjj95MLi+ox83pnz3idNl14zzkT1olk9CfjRT+DY=; b=XZhwQMFPmTqgjRcddpgf6wH9FL2iLJk3EQddEFO0hxzi7/cNyZBAC71jFZBZ4j5WnNjJz9 mFBWwjTqkta1VTwFtx8AeQ76SwZ2CrX0ORDULJMX1x5neEU12e5dyn4m7LwMR975bE+qGW ini1e1HcTFf7OnWoY/r3BDMNJwhswvs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1673337062; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/cbvjj95MLi+ox83pnz3idNl14zzkT1olk9CfjRT+DY=; b=3BS8mRyES+f2UwYlXmmxOoiuLcIfxpOpHW/kjQQjqzpD1HYTDP2Rn11q7xX/AqmM5dfZ6j BkHp7QXcOnFEoADw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id CDC711358A; Tue, 10 Jan 2023 07:51:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id kat+MeUYvWM0fAAAMHmgww (envelope-from ); Tue, 10 Jan 2023 07:51:01 +0000 Message-ID: Date: Tue, 10 Jan 2023 08:51:01 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [PATCH] kunit: memcpy: Split slow memcpy tests into MEMCPY_SLOW_KUNIT_TEST To: Geert Uytterhoeven , Kees Cook Cc: Guenter Roeck , Andrew Morton , Nathan Chancellor , linux-hardening@vger.kernel.org, David Gow , Nick Desaulniers , Josh Poimboeuf , Miguel Ojeda , Isabella Basso , Dan Williams , Rasmus Villemoes , linux-kernel@vger.kernel.org, Brendan Higgins , "open list:KERNEL SELFTEST FRAMEWORK" , KUnit Development References: <20230107040203.never.112-kees@kernel.org> Content-Language: en-US From: Vlastimil Babka In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_SOFTFAIL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +Cc rest of kunit from MAINTAINERS On 1/7/23 11:55, Geert Uytterhoeven wrote: > Hi Kees, > > On Sat, Jan 7, 2023 at 5:02 AM Kees Cook wrote: >> Since the long memcpy tests may stall a system for tens of seconds >> in virtualized architecture environments, split those tests off under >> CONFIG_MEMCPY_SLOW_KUNIT_TEST so they can be separately disabled. >> >> Reported-by: Guenter Roeck >> Link: https://lore.kernel.org/lkml/20221226195206.GA2626419@roeck-us.net >> Cc: Andrew Morton >> Cc: Nathan Chancellor >> Cc: linux-hardening@vger.kernel.org >> Signed-off-by: Kees Cook > > Thanks for your patch! > >> --- a/lib/Kconfig.debug >> +++ b/lib/Kconfig.debug >> @@ -2621,6 +2621,15 @@ config MEMCPY_KUNIT_TEST >> >> If unsure, say N. >> >> +config MEMCPY_SLOW_KUNIT_TEST >> + tristate "Include exhaustive memcpy tests" if !KUNIT_ALL_TESTS > > Why the tristate? > >> + depends on MEMCPY_KUNIT_TEST >> + default KUNIT_ALL_TESTS >> + help >> + Some memcpy tests are quite exhaustive in checking for overlaps >> + and bit ranges. These can be very slow, so they are split out >> + as a separate config. >> + >> config IS_SIGNED_TYPE_KUNIT_TEST >> tristate "Test is_signed_type() macro" if !KUNIT_ALL_TESTS >> depends on KUNIT >> diff --git a/lib/memcpy_kunit.c b/lib/memcpy_kunit.c >> index 89128551448d..cc1f36335a9b 100644 >> --- a/lib/memcpy_kunit.c >> +++ b/lib/memcpy_kunit.c >> @@ -307,8 +307,12 @@ static void set_random_nonzero(struct kunit *test, u8 *byte) >> } >> } >> >> -static void init_large(struct kunit *test) >> +static int init_large(struct kunit *test) >> { >> + if (!IS_ENABLED(CONFIG_MEMCPY_SLOW_KUNIT_TEST)) { >> + kunit_skip(test, "Slow test skipped. Enable with CONFIG_MEMCPY_SLOW_KUNIT_TEST=y"); > > So I can't make the slower tests available for when I need them, > but not run them by default? Indeed it seems weird to tie this to a config option without runtime override. > I guess that's why you made MEMCPY_SLOW_KUNIT_TEST tristate originally, > to have a separate module with the slow tests? On the other hand I can imagine requiring a separate module for slow tests would lead to more churn - IIUC there would need to be two files instead of memcpy_kunit.c, possibly a duplicated boilerplate code (or another shared .c file). So the idea is to have a generic way to mark some tests as slow and a way to opt-in/opt-out for those when running the tests. Maybe KUnit folks already have such mechanism or have an idea how to implement that. >> + return -EBUSY; >> + } >> >> /* Get many bit patterns. */ >> get_random_bytes(large_src, ARRAY_SIZE(large_src)); > > Gr{oetje,eeting}s, > > Geert > > -- > Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org > > In personal conversations with technical people, I call myself a hacker. But > when I'm talking to journalists I just say "programmer" or something like that. > -- Linus Torvalds