Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp580197lqp; Wed, 12 Jun 2024 09:52:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVAEaNAwIGSlzaSErYLJV2T8xwFJmDFvuUc/Fr3mDbCxtDt5Kf2XHInoEJIxg4zSh1jRkSMnKHsgTpOzxAe3p9r9BRgmafhzGYg3tfuyA== X-Google-Smtp-Source: AGHT+IEXaTbgRd4KUpI1gAP8GzHiymKi/mlflcZOXMgfTrWe4eNXq3GXBAgN/E8EiJI6/tzABQ+v X-Received: by 2002:a17:902:ecc2:b0:1f6:e4ab:a1f4 with SMTP id d9443c01a7336-1f83b568db4mr32919565ad.12.1718211142266; Wed, 12 Jun 2024 09:52:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718211142; cv=pass; d=google.com; s=arc-20160816; b=mc2YTsntWJ/U36EYAcDwx0Fjhc4vxIrfetAh2pBCMmVmMnb8MIfcf5qdlG/sEBzLxp D8r+OA030zxv/PEI0EEEpuT4TlZvdme7Ca7FUKSDU2UrxIWYVSNOruCv0R1djiIjK/b/ BwzjHMhwdaPChLuDzcXpUeNiUp4eKnrToKYglyk+NMfcUbsfIK8tN5xdOjlOKe9986ds qEoV4BO0q7M/rvYBIGQ/ScpH4sregekYWj/s25u+fYoCqOdAJ1OYpccq54pqIVT9AyD6 q2EJ7v5U8Ho/8xttU8JvhJg+ShmIgWR0z+zU5OR6ObTCiohN32iiwtSC5x501tPvjiHP bYgw== 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=hxZnq239fy/V/h0CbR1hQTKonO4O3A9Y6Hcyx88v8fI=; fh=Cd4yW8B+37fJ1Ihmf4+OdLqDWf+lrzM9sjrG0zV3lww=; b=Oxw5k9tnmEWSBG4szlRFjM9KKKk/GK0CaryNu9d1VzFH519If8CJ7WfSIp3JbG4FE9 6iwZKcS+Tbb1DSLd5ePYIbXhuD2N+YYO2jdTSfVtRGOmoeuKoyV2YVX99yv48gXtUyAT E3RJLPEFzB0rvtjuzgPRRfyM7OgWK7AXMRtEGSHCVH8UcRfggCNFVIFDpXSlaoa5eF3N xWUQx8Rn+18uh2LTQcBwZCoD14ApGnZf+yoLPnJFMhls6JzQXPneX7Q/mJFemOcIUjM7 V3RVEiCdPp1VOUBzP5G001McWKOGInxZ5iuYph/KUiBoCG1XQMwSO0vsdeVNRiGYamlA rSyQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FajjE16o; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-211941-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-211941-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f847639d3asi8176075ad.278.2024.06.12.09.52.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 09:52:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-211941-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FajjE16o; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-211941-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-211941-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 CFF8D2850A9 for ; Wed, 12 Jun 2024 16:52:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 27982181D06; Wed, 12 Jun 2024 16:51:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FajjE16o" 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 4A47A181BA1; Wed, 12 Jun 2024 16:51:52 +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=1718211113; cv=none; b=QedUpmZ4V+2ZFMr8KVFEyuj3AhEruqZwndIyar2302T84wIAe364joAOLWsgkVGj2LQa1UhR49DUoXukY8USMBI8lGWOGwve+HO5BYtRQWxwABqlm3D5ZXl3i6focUKvS9GzpxkVKLdbImf6in1Sw9Tsl66shxUi3TvGpVYFPX0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718211113; c=relaxed/simple; bh=i3zcEBBXxs419UXvZd1JWOYs5IMvkcbnW3VEvOOo4nM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=NM0JBvzF6ZhFDKF0xkz5bSokTMvzX/TyKFHXcv6CgXUIxiYuoag36+40zHVV3ifXvPtNbOhYhS14NHrCeVTLxtYqhx4e5x4G2y94uI+DVQu7rCOGU7kP7CaLn8V8mc99DnYk3yNaEnN27l3G/FVo2jg0oWM+NVeC6pkjMoRz1fU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FajjE16o; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB0F1C116B1; Wed, 12 Jun 2024 16:51:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718211112; bh=i3zcEBBXxs419UXvZd1JWOYs5IMvkcbnW3VEvOOo4nM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=FajjE16oiN0sCUdjEHzhtdxIoQ+JmYsyycKinb3gPp0UQgycwaTf9mimZp45Z+LUA 3JiCZMbf5+BwW4ZS39+uhlQV5jbXLmPiv1TuqONCArjpoJU/JQgISOe2K8G+bHT21z ymkmuE0Ro8bp+PEdeeR3m5ubtux7jtn4alCYIEtbJ4IwAcFn7M+AiwPmE/rzNhxpaG e9g1Y9xqf2Awq9tz5ViRJ6+cCj5jjHVyEuTU7StQn+yOG2CerxhMEcmrfrgXBkB7aL cXmxFwTgwvFigVH6NQpjlAvAeFQW9WDg5tKWcw+97DmjO4JSlooWHFzL1MaaVxnI92 0WEHACeqIZeMA== Date: Wed, 12 Jun 2024 09:51:52 -0700 From: Kees Cook To: Geert Uytterhoeven Cc: Mark Rutland , David Gow , Vitor Massaru Iha , Ivan Orlov , Brendan Higgins , 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, linux-m68k@lists.linux-m68k.org Subject: Re: [PATCH v2 2/2] usercopy: Convert test_user_copy to KUnit test Message-ID: <202406120927.3C64ACD6@keescook> References: <20240610213055.it.075-kees@kernel.org> <20240610213330.1310156-2-kees@kernel.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, Jun 12, 2024 at 05:13:39PM +0800, David Gow wrote: > On Tue, 11 Jun 2024 at 05:33, Kees Cook wrote: > > > > Convert the runtime tests of hardened usercopy to standard KUnit tests. > > > > Co-developed-by: Vitor Massaru Iha > > Signed-off-by: Vitor Massaru Iha > > Link: https://lore.kernel.org/r/20200721174654.72132-1-vitor@massaru.org > > Tested-by: Ivan Orlov > > Signed-off-by: Kees Cook > > --- > > This looks good, particularly with the x86 fix applied. > > It's still hanging on m68k -- I think at the 'illegal reversed > copy_to_user passed' test -- but I'll admit to not having tried to > debug it further. > > One other (set of) notes below about using KUNIT_EXPECT_MEMEQ_MSG(), > otherwise (assuming the m68k stuff isn't actually a regression, which > I haven't tested but I imagine is unlikely), Hi Geert, I'm trying to debug a hang on m68k in the usercopy behavioral testing routines. It's testing for the pathological case of having inverted arguments to copy_to_user(): user_addr = kunit_vm_mmap(test, NULL, 0, priv->size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANONYMOUS | MAP_PRIVATE, 0); ... bad_usermem = (char *)user_addr; ... KUNIT_EXPECT_NE_MSG(test, copy_to_user((char __user *)kmem, bad_usermem, PAGE_SIZE), 0, "illegal reversed copy_to_user passed"); On other architectures, this immediate fails because the access_ok() check rejects it. On m68k with CONFIG_ALTERNATE_USER_ADDRESS_SPACE, access_ok() short-circuits to "true". I've tried reading arch/m68k/include/asm/uaccess.h but I'm not sure what's happening under CONFIG_CPU_HAS_ADDRESS_SPACES. For now I've excluded that test for m68k, but I'm not sure what's expected to happen here on m68k for this set of bad arguments. Can you advise? Thanks! -Kees -- Kees Cook