Received: by 2002:ab2:715a:0:b0:1fd:c064:50c with SMTP id l26csp49259lqm; Mon, 10 Jun 2024 12:16:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWjLFMguXv7Yx6kir1hyCW3IV3dgu7dMQo/gRE2o/0Q77oU55ihoAn3hiE6tyd2aW+EpR/sRg6mXWMNRIbBUSGBRZu5RZjPUQPJYjkgFQ== X-Google-Smtp-Source: AGHT+IGV3hkfevrSgFiEzfmNjL5Z9bApZUrDekhXBZVLoWfa4etsSJm3eQ6B2W9/ft47UH+Lyyl2 X-Received: by 2002:a17:902:6805:b0:1f6:e003:1c62 with SMTP id d9443c01a7336-1f6e0031eb4mr79474235ad.60.1718047003104; Mon, 10 Jun 2024 12:16:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718047003; cv=pass; d=google.com; s=arc-20160816; b=BhGEuywCGIQqlTyiQkQSKjJmWvcc44rEKqUnug7QfwYqSxwMTq4AuxyzwB3nVC7GkI HbP7YdlEJBG1oc8CAjJgSq4i2snWMGPPz39STufXlcUXSWav+f5Os25D+SfBAY41vdo0 aRH0PehtO/KPscG0G9vHwqhm3ZEpoJ4OIuwbUW+hKr510g6gMU9NOn1LY902yEss7Ff2 VAC9B3q7DnPukf5y9H3pBLWl4P2zrP/Ev+RpbY3/9crfeGo2yqDLGQ+XSdHZ++Ah/sPN 01t3ErW8H9nrApl+QKBt7aWwtkrm+BUqJMKlcl4IoWrd0yUtjtZGHO393AvWhOXWq8kV w7LQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=R3/A3I3jD0X7V3bwMa+tIirZ9Wd1XnGkqTbPEhhCFAM=; fh=UubR5N1fWhDAhvSgs2Mb+Ug3uMx8gQ5vHkMSxcdXfeQ=; b=JMdrYajkOyM+1Ir32HVQq/Y89D+nBY/FMgJR0m1XMy8I378CEJnw7hz7n2g3xNdW99 QAMgmufFXi6P3hlzTHqOuF9TI18JRTvmcuoEgHZIb8Z2We+uUa3h+fgroO0gPp2cZw+F rOJqyXukakoTDLBM5Y6CLwxe2kZzeAa0ururkITN5a3K+AFuqQzo0uHBsFtKHtKNwfnN K6UU3qKfNvGjCiR/HQypjwSqQf33qi9nQqq40pwWn8oRRFEuyZHdUuKdBtgTSE/BTQl/ mhclvZ3iOkpocbFtHTYEN6hevSMRiarFBkU0S8S9aLxCL3JtLu2bpDhNPOA21+OeLXk7 Q7Ow==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WlrJ56iY; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-208775-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208775-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f7175a6d89si18994175ad.559.2024.06.10.12.16.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 12:16:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208775-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WlrJ56iY; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-208775-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208775-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 76AF0286331 for ; Mon, 10 Jun 2024 19:11:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3DC5B14D2AB; Mon, 10 Jun 2024 19:11:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WlrJ56iY" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D8C11B5A4; Mon, 10 Jun 2024 19:11:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718046672; cv=none; b=W+7/5RdrYUTwflGWOAWQwSUkKOEy8kMl0I5JNHiBNA74s1dX7wVt1BkkeMorfqcVvEflUYxykQY6m61cCeU13YXGRW4LC+HJYE5TP8stwlghIfJrUMyXFPxaDotTq4gKzcG3fa0JQfIcmu7W5Dar+6l3pbX5fi4HdMbdI4YVuLA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718046672; c=relaxed/simple; bh=Am+1VRHQSbf2WAYS4raTblVDlWJa42B8soubx3hgfgU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=lPAboRfI0HV5oY9Pdkc1JJi+clVKdbWD/MwSQ3cxza2umyzK0vhr28pyBma7Au26HaJi/psjjacf20h4alW6Rt5OKy1Rhi8wMx8DS2K55NUlGVai9EYahqCJTybIQEW0U2KRv2kgIcXzRM93sVoSf2fM5uxJfhtZK6bW5mrUp+8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WlrJ56iY; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8362C2BBFC; Mon, 10 Jun 2024 19:11:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718046671; bh=Am+1VRHQSbf2WAYS4raTblVDlWJa42B8soubx3hgfgU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WlrJ56iYRD3BNCRQ3tLeSdx9Lvmr1Hh2+tTudfGTi68y24n6xNLkfgQ/k9ABPHxd5 rE6DE8+ACD4bPJuawyiKNzrrkC+DMEgMQ+Ptu21S1FiBpqnKYdB4RbI+fcVyP912Te pFUy0rHhnmyaAlq4hgtfSE0zHmbqN/iKC+HMMdFjYcf/3vJXpb/hetxyG3G7rqNj/5 dvcoV+gFFKEqxSgSU+bV226TdSRewBND1jWv4+P0qMX5zXRI4REGuyNCdutRD53hcX pnTbRQkwuvYuVTcGL/qi6905RVhDD7Z2Uxlkb7MmW1oATOC29XIQ7IJHumVbuGT9zx 8ukAIvECUDmcw== Date: Mon, 10 Jun 2024 12:11:11 -0700 From: Kees Cook To: Ivan Orlov Cc: Mark Rutland , Vitor Massaru Iha , Brendan Higgins , David Gow , Rae Moar , "Gustavo A. R. Silva" , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-hardening@vger.kernel.org Subject: Re: [PATCH 2/2] usercopy: Convert test_user_copy to KUnit test Message-ID: <202406101209.1B76564DC@keescook> References: <20240519190422.work.715-kees@kernel.org> <20240519191254.651865-2-keescook@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Wed, May 29, 2024 at 01:17:35PM +0100, Ivan Orlov wrote: > On 5/19/24 20:12, Kees Cook wrote: > > #define test(condition, msg, ...) \ > > ({ \ > > int cond = (condition); \ > > if (cond) \ > > - pr_warn("[%d] " msg "\n", __LINE__, ##__VA_ARGS__); \ > > + KUNIT_EXPECT_FALSE_MSG(test, cond, msg, ##__VA_ARGS__); \ > > cond; \ > > }) > It looks like the 'test' macro is not used anymore, so probably it should be > removed. Oops, yes. Thanks! > > +static int usercopy_test_init(struct kunit *test) > > +{ > > + struct usercopy_test_priv *priv; > > + unsigned long user_addr; > > - if (ret == 0) { > > - pr_info("tests passed.\n"); > > - return 0; > > - } > > + priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL); > > + if (!priv) > > + return -ENOMEM; > > Should the check be done with KUNIT_ASSERT_NOT_ERR_OR_NULL here as well, as > it is done with priv->kmem? Yes, that's much more idiomatic. I'll adjust this too. > Other than that, > > Tested-by: Ivan Orlov Thanks! -- Kees Cook