Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp824372pxb; Thu, 17 Feb 2022 15:52:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJzkNReez9ZgwCTFuujuczHcB63GpsAT40zgHcs9drztPxQ+Hxx3QV6nkWhYnDGZm4PjKDiD X-Received: by 2002:a17:90a:fc6:b0:1b9:1e81:a53e with SMTP id 64-20020a17090a0fc600b001b91e81a53emr5496371pjz.169.1645141959893; Thu, 17 Feb 2022 15:52:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645141959; cv=none; d=google.com; s=arc-20160816; b=EcdI7ej6Jo/g0JLdeFMoXoahN7ujOS9fORQyNUS+4fXaQ1G/f2G+mVdEdU+19KyO4E GqfxNV5Y/RXhCQH+wCJAvDpjfJs3WOErI9hQwxASBxMTlQ96zIo62sFsWHciAKfvgQBL iPMqD8PSEwf58IhWdcof4ieLUEkopjRgs9apre9pN2eu/D6AJRHTnrbZaE3QLt3tBnx+ Vbi0QLJAmXGOLACd3C0KzT5LIktkO13e5EMz1CEULdEZpjhqwkNhnJ/kgjF74Oa0WRsH jI8MGJjWZhB17qOzo4FNW+qEPHh49Taf2FXIEFtODXmMl8UsXFJot/IUh39tW9GgpdoF PIcQ== 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=9ikRVBzBT/FT2DEDw+8BeKqhzPIo0bpn2iXDMO301p4=; b=ODBUmVrvrVMnsr77SJa9FocrpyLIkLD7Gjl5YMPgY8MzyVRGBa99e3BHsaOLWWiaFZ jqKZP74SAeoP3pFTwMdx4Hza4DfBlmXF4PKMp47N42gOTOcngLf2vEx0Qr2l6apNbgXo AtBTjrXgsbmCNQFV9AX1ldmsUKvThMO0n4L5eXBxN7Aa/cKgLqnFYdwv0MvUHf+THZdH yGrujOSPO2NoJNolU5tzsqR1Vp1PNYhc+b60HyIyeRQUWfAg6PCwVu5ox+W9VIx4W2Qy mHW/YbABPhLDdc0fG6nFkI+NjOEdBvIX4QYXDaW/4F2V9MoG1Jde+NsuyNdLpFR9j+nQ /a4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=qFy+upxz; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id z25si9564350pgu.240.2022.02.17.15.52.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 15:52:39 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=qFy+upxz; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F367A2C5AB5; Thu, 17 Feb 2022 15:25:12 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244891AbiBQTC3 (ORCPT + 99 others); Thu, 17 Feb 2022 14:02:29 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:60716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243700AbiBQTC2 (ORCPT ); Thu, 17 Feb 2022 14:02:28 -0500 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23F9C8021E for ; Thu, 17 Feb 2022 11:02:13 -0800 (PST) Received: by mail-ej1-x62b.google.com with SMTP id p15so9464238ejc.7 for ; Thu, 17 Feb 2022 11:02:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9ikRVBzBT/FT2DEDw+8BeKqhzPIo0bpn2iXDMO301p4=; b=qFy+upxzo8ujjI4h3pWNkOcceHresXDg4chqjvXmO1gJOLQHTOmQiJp9M5nXqQA0i6 Y3AsL9Njs1xcoOEJDj02riua7dj8JMXn6+iHKCY4cpnREFJvlGan+/lVQTNvysmjIAp0 B7vTNa07K6DD5yVU7uB21jCxB0K+s0VlSQe0dAM8bhWsdtCi4eaK+VhVcwMl5fMvqqxY MLhQChU0xlQdzq2e+4ypchsozEWXWcq7m+Oe1ZyA8wSCDIcqbDo0QEOPebT4SbhwBtQy 9RmQ/FuXGoT2+ISuAQt1b3yLDoeaDwYp4j1sAq54DIjMiH9CRk5wG5q2nZi0QVUnNYS2 uxaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9ikRVBzBT/FT2DEDw+8BeKqhzPIo0bpn2iXDMO301p4=; b=eqrJ0Y6cGsFjrKPXifkgljEpoE2xc1VX7tWSUbAF7aq3vkH5BPsDJJO9kUaATNWzK+ md0f8eJRD23W2cC7SeDnoSVXH94+aBWtGgcTT/HhauQ0pEmu+eyYJW6XN0xseMIqUCPU U4Cwy7OkvvpyI/P5/A7s1QOlDrsDEGatMaw6Evb3+99irvO6u+KRlzgLdMRVLNDmGIrj baWdGcOx+K6bzu/msfeHo7GQ9+C0P/559Xbk/CIGbhnFwhWleuO+RPe1fvQcpkYylGVV A6upFrY+fmAFhu/zicsa5oCUuFt50q8m1MNllNA2qOtOZmnBUFdJGGsBoLZhdGlInsfT FviA== X-Gm-Message-State: AOAM532XH3DGlRmjtBzUnQLapfgWAYtZLFz6iTyY+VopRfCKXWGgrv0N HbV9OBQY4PoMbqdtYsfAbZFe2ZMVQMkJlOhWwQLYvi4L9rg= X-Received: by 2002:a17:906:ce23:b0:6cf:7203:ded6 with SMTP id sd3-20020a170906ce2300b006cf7203ded6mr3412467ejb.170.1645124531438; Thu, 17 Feb 2022 11:02:11 -0800 (PST) MIME-Version: 1.0 References: <20220216224153.2242451-1-keescook@chromium.org> <202202170903.E39554DF@keescook> In-Reply-To: <202202170903.E39554DF@keescook> From: Daniel Latypov Date: Thu, 17 Feb 2022 11:01:59 -0800 Message-ID: Subject: Re: [PATCH] lib: overflow: Convert to Kunit To: Kees Cook Cc: David Gow , Vitor Massaru Iha , Rasmus Villemoes , Nick Desaulniers , Arnd Bergmann , linux-kernel@vger.kernel.org, KUnit Development , linux-kselftest@vger.kernel.org, linux-hardening@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no 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 On Thu, Feb 17, 2022 at 9:09 AM Kees Cook wrote: > > On Wed, Feb 16, 2022 at 02:57:12PM -0800, Daniel Latypov wrote: > > On Wed, Feb 16, 2022 at 2:42 PM Kees Cook wrote: > > > > > > Convert overflow unit tests to KUnit, for better integration into the > > > kernel self test framework. Includes a rename of test_overflow.c to > > > overflow_kunit.c, and CONFIG_TEST_OVERFLOW to CONFIG_OVERFLOW_KUNIT_TEST. > > > > > > $ ./tools/testing/kunit/kunit.py config > > > ... > > > $ ./tools/testing/kunit/kunit.py run overflow > > > > JFYI, you can run this as a one-liner via > > > > $ ./tools/testing/kunit/kunit.py run --kunitconfig /dev/stdin < > CONFIG_KUNIT=y > > CONFIG_TEST_OVERFLOW=y > > EOF > > > > The above is taken from my own duplicate version of this patch > > [1] https://lore.kernel.org/linux-kselftest/20210503211536.1384578-1-dlatypov@google.com/ > > Ah-ha! I thought I remembered this conversion being proposed before but > I totally failed to find it. Thank you! I'll compare/adjust this patch > and add you as Co-developed-by. There's a lot that's already identical line for line. I think I pointed to all the places where they differed in any meaningful way down below. So you can probably save yourself the time of looking over. And yeah, I vaguely remembered that Vitor had worked on it, but somehow failed to find that as well. Something about this test :) > > > > ... > > > [14:33:51] Starting KUnit Kernel (1/1)... > > > [14:33:51] ============================================================ > > > [14:33:51] ================== overflow (11 subtests) ================== > > > [14:33:51] [PASSED] u8_overflow_test > > > [14:33:51] [PASSED] s8_overflow_test > > > [14:33:51] [PASSED] u16_overflow_test > > > [14:33:51] [PASSED] s16_overflow_test > > > [14:33:51] [PASSED] u32_overflow_test > > > [14:33:51] [PASSED] s32_overflow_test > > > [14:33:51] [PASSED] u64_overflow_test > > > [14:33:51] [PASSED] s64_overflow_test > > > [14:33:51] [PASSED] overflow_shift_test > > > [14:33:51] [PASSED] overflow_allocation_test > > > [14:33:51] [PASSED] overflow_size_helpers_test > > > [14:33:51] ==================== [PASSED] overflow ===================== > > > [14:33:51] ============================================================ > > > [14:33:51] Testing complete. Passed: 11, Failed: 0, Crashed: 0, Skipped: 0, Errors: 0 > > > [14:33:51] Elapsed time: 12.525s total, 0.001s configuring, 12.402s building, 0.101s running > > > > > > Cc: David Gow > > > Cc: Vitor Massaru Iha > > > Cc: Rasmus Villemoes > > > Cc: Nick Desaulniers > > > Co-developed-by: Vitor Massaru Iha > > > Signed-off-by: Vitor Massaru Iha > > > Link: https://lore.kernel.org/lkml/20200720224418.200495-1-vitor@massaru.org/ > > > Signed-off-by: Kees Cook > > > > Reviewed-by: Daniel Latypov > > > > Looks good to me, some minor nits/suggestions wrt KUnit usage. > > Nice to see this test converted over! > > Thanks! > > > [...] > > > index f6530fce799d..4cc27b9926a1 100644 > > > --- a/lib/test_overflow.c > > > +++ b/lib/overflow_kunit.c > > > @@ -1,9 +1,13 @@ > > > // SPDX-License-Identifier: GPL-2.0 OR MIT > > > /* > > > - * Test cases for arithmetic overflow checks. > > > + * Test cases for arithmetic overflow checks. See: > > > + * https://www.kernel.org/doc/html/latest/dev-tools/kunit/kunit-tool.html#configuring-building-and-running-tests > > > + * ./tools/testing/kunit/kunit.py config > > > + * ./tools/testing/kunit/kunit.py run overflow [--raw_output] > > > */ > > > #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt > > > > We can drop the pr_fmt now, I think > > My instinct is to leave these in place just so that anything weird that > gets inlined and sneaks a pr_*() call into the code will have a > meaningful prefix. Ack, sounds good. We've historically dropped it and assumed we'd use kunit_info() for all the pr_*()'s we cared about. But there's definitely concern that some macro might use it to print an important and relevant message, hmm.