Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2471823pxb; Mon, 20 Sep 2021 23:58:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKrIPku5FXf5QyN7muXJaYMZyL4rCVmbfCbJpsq0tJYeajVOEXRv203XxYhw7J9MgHesLH X-Received: by 2002:a5d:9601:: with SMTP id w1mr4113061iol.209.1632207491032; Mon, 20 Sep 2021 23:58:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632207491; cv=none; d=google.com; s=arc-20160816; b=bqB3yasLZzZjQdc4HFFDSv5EQKV2mLt3lk8UkzNZloY+4efRH9+0dYSC13mEDiHNzP XeA9l1hYovmKCoVT1vBadfKCx4Ujl0VYBCOIXlRSauhm4izE1bC4Y2unF3/YYJJWp1LI LSgT6Ab5GG9pLrKsX4Vl+lNPs67FGSguOC1GvuQOsdADTuw2jKXYHghypnTe/AMQbNZ8 hQiuvfvGIPw1vbsICWtxT3WX1ph/zZcaUR4UKaF+PvekCkyxa3eKnlo0Bwgoz4HWrHfL 0yoxn5JICGZT6FeIJo+bf+L1cBCZGINeA/wt7Nm8q06kddr51PctBqy8Shoo+A0i19SH /2CQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=2lP0KhRVUvQyWZhQ488eOsEIqUPPJSp/sF1BR/yQXNA=; b=vcs2P499nEo+2laoENps1EWXfbjANlRxulDIttf9dvNyp7JGiiRV8iVbTz0SDyM+KS u1kNjQ3brnGBo0AGCEv8vQp1WD403RUFJxf5MG6hbXdh5wOrqLmTcWQ0gb7LlD2kx1L7 2MsdHycM1zetzSdqz+recuYag0UPm3OsvdTZkjr4rSo9GWCLN1eG3pexbRlxMyH51egy 659ILYMiBhmiz4BOJvT95XyD5Vpqk579HplCQ10j33MQt8UFY+y3qQd55GtSBC1mzqYU TL0a+5JeFCfsKxIScAuKzBrMoPtdX6JoeBnxePZSbCBaVxsshZ8/GwHmdWhV1EtaBw8C NV7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=NEpQsDXX; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k33si7244820jac.101.2021.09.20.23.57.59; Mon, 20 Sep 2021 23:58:11 -0700 (PDT) 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=@rasmusvillemoes.dk header.s=google header.b=NEpQsDXX; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229990AbhIUG5w (ORCPT + 99 others); Tue, 21 Sep 2021 02:57:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229755AbhIUG5v (ORCPT ); Tue, 21 Sep 2021 02:57:51 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBB29C061574 for ; Mon, 20 Sep 2021 23:56:23 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id g41so44959672lfv.1 for ; Mon, 20 Sep 2021 23:56:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=2lP0KhRVUvQyWZhQ488eOsEIqUPPJSp/sF1BR/yQXNA=; b=NEpQsDXXuNMWEsogXhwZXw4ypkov14vzvRBxhT2TQD+U5CiVQ5t64wtt0SugLK5OQs HYua+NHNtV34Js5j1qfF3xrqCpUs+dG1ZvRltYVj6DokNycwnox+8LhdumLUL4S2Zx1N i5+CtjaG4+43ZCjC1Pdc/+supfjsgYP3RXW70= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=2lP0KhRVUvQyWZhQ488eOsEIqUPPJSp/sF1BR/yQXNA=; b=v2OrnMEpdPkutbtR3T8VuYeBTC5Ec9og2Krqtn86eyjzJKCLQwsv1il9GqgNMHrrvi mmL6Fe3EXP6E466z2XJsp/fNAJf/nhGiVYK/zXLU6HL1AwaWppC+CnMOIjA5q87Bo1Qs Kg4D+HAMvX3bHgAYzxSb9NJ8BGsDQ/oyseV1/yiGfpwDcKYZy/MiuCxz6blbgsapno5i +HZrGEkQ5zvrMryh74pVF3CTRRK/vPJ+lBa4f0xuM/wfjF9kBCE0/SJWb9HobNZiLzRa DJeZP3ker4N0MQF1akX4U0TIxFxxPgxQlS+rFQrKU2lQc3D98hB+EzryZxTF+Dy2P9O3 C+fg== X-Gm-Message-State: AOAM531lsRTxSEk0wpxqAi8yEqoF4nfqqLilF+B2+ehL6H33sswR32vV LJ8THKwwgdBHbHpEowA6NZ1Mhw== X-Received: by 2002:a05:6512:110a:: with SMTP id l10mr9411631lfg.550.1632207382109; Mon, 20 Sep 2021 23:56:22 -0700 (PDT) Received: from [172.16.11.1] ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id p19sm656144lfr.210.2021.09.20.23.56.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 20 Sep 2021 23:56:21 -0700 (PDT) Subject: Re: [PATCH 2/2] test_overflow: Regularize test reporting output To: Nick Desaulniers , Kees Cook Cc: "Gustavo A. R. Silva" , Nathan Chancellor , Jason Gunthorpe , Leon Romanovsky , Keith Busch , Len Baker , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org References: <20210920180853.1825195-1-keescook@chromium.org> <20210920180853.1825195-3-keescook@chromium.org> From: Rasmus Villemoes Message-ID: Date: Tue, 21 Sep 2021 08:56:20 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21/09/2021 00.10, Nick Desaulniers wrote: > On Mon, Sep 20, 2021 at 11:09 AM Kees Cook wrote: >> >> @@ -544,10 +544,7 @@ DEFINE_TEST_ALLOC(kmalloc, kfree, 0, 1, 0); >> DEFINE_TEST_ALLOC(kmalloc_node, kfree, 0, 1, 1); >> DEFINE_TEST_ALLOC(kzalloc, kfree, 0, 1, 0); >> DEFINE_TEST_ALLOC(kzalloc_node, kfree, 0, 1, 1); >> -DEFINE_TEST_ALLOC(vmalloc, vfree, 0, 0, 0); >> -DEFINE_TEST_ALLOC(vmalloc_node, vfree, 0, 0, 1); >> -DEFINE_TEST_ALLOC(vzalloc, vfree, 0, 0, 0); >> -DEFINE_TEST_ALLOC(vzalloc_node, vfree, 0, 0, 1); >> +DEFINE_TEST_ALLOC(__vmalloc, vfree, 0, 1, 0); >> DEFINE_TEST_ALLOC(kvmalloc, kvfree, 0, 1, 0); >> DEFINE_TEST_ALLOC(kvmalloc_node, kvfree, 0, 1, 1); >> DEFINE_TEST_ALLOC(kvzalloc, kvfree, 0, 1, 0); >> @@ -559,8 +556,14 @@ static int __init test_overflow_allocation(void) >> { >> const char device_name[] = "overflow-test"; >> struct device *dev; >> + int count = 0; >> int err = 0; >> >> +#define check_allocation_overflow(alloc) ({ \ >> + count++; \ >> + test_ ## alloc(dev); \ >> +}) >> + >> /* Create dummy device for devm_kmalloc()-family tests. */ >> dev = root_device_register(device_name); >> if (IS_ERR(dev)) { >> @@ -568,23 +571,22 @@ static int __init test_overflow_allocation(void) >> return 1; >> } >> >> - err |= test_kmalloc(NULL); >> - err |= test_kmalloc_node(NULL); >> - err |= test_kzalloc(NULL); >> - err |= test_kzalloc_node(NULL); >> - err |= test_kvmalloc(NULL); >> - err |= test_kvmalloc_node(NULL); >> - err |= test_kvzalloc(NULL); >> - err |= test_kvzalloc_node(NULL); >> - err |= test_vmalloc(NULL); >> - err |= test_vmalloc_node(NULL); >> - err |= test_vzalloc(NULL); >> - err |= test_vzalloc_node(NULL); >> - err |= test_devm_kmalloc(dev); >> - err |= test_devm_kzalloc(dev); >> + err |= check_allocation_overflow(kmalloc); >> + err |= check_allocation_overflow(kmalloc_node); >> + err |= check_allocation_overflow(kzalloc); >> + err |= check_allocation_overflow(kzalloc_node); >> + err |= check_allocation_overflow(__vmalloc); >> + err |= check_allocation_overflow(kvmalloc); >> + err |= check_allocation_overflow(kvmalloc_node); >> + err |= check_allocation_overflow(kvzalloc); >> + err |= check_allocation_overflow(kvzalloc_node); >> + err |= check_allocation_overflow(devm_kmalloc); >> + err |= check_allocation_overflow(devm_kzalloc); >> >> device_unregister(dev); I'd prefer if such a local helper macro was defined immediately prior to the sequence of uses, and then #undef'ed at the end. Other than that: Acked-by: Rasmus Villemoes