Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp503349lqg; Fri, 1 Mar 2024 11:32:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUhscLHdCpxHEVvG+pCj6W0WxmbKnEAYdvPP3mo4orzxfUV2PgGaP2zdTFfbAuyoGT+sdEeaiWhfBVPGpmewMB/YWjOKQSyHNgAiDd8Ig== X-Google-Smtp-Source: AGHT+IEHPZhZSc0IYwLVyaiXqHcdpXdFvNqJ+2poc0ZI3CbkNApDTFM+vZvXrD20+z4iqdQ+zvDq X-Received: by 2002:a05:6e02:1c46:b0:365:c812:e6f with SMTP id d6-20020a056e021c4600b00365c8120e6fmr3159380ilg.1.1709321545478; Fri, 01 Mar 2024 11:32:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709321545; cv=pass; d=google.com; s=arc-20160816; b=NKAUd2FiJZxSJ9I+OfDFUq6XBOCc/tov4+Z85hOkAAskT+AKqSZU+rWaI9EY7fcvZO hXanXE+KglTqq003NhlgQPGfBiMjaQEbnGxjdjI/ENGFjF5enxvp02QkoOSg3RXzS5Op cYm9ZBnGANa26zyzc/5ChG4fnlV7Uvssto8YAevU7qkbicvEAGsYNkHLmfj21TkmWgT8 6VmbMsYoljNPb/HMxYMlNOlJcmH/48/Shhqp878QQtld7pMZH+YmP8cCDqRwVDNNWc2s ctYJmLVSqs2cO77EqAb+LAZr5yFDuG4b+S+vyA7VETBH1vTXt7RY3R4Z68q3aqYwjsQl ZsNQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=MveRQUnOJzWljed8yOqB1iTmcwu1AfsyxpmPH6L9dTw=; fh=mhEzn47WOVHmNZmWR30LihnThxm2bBnGi+HFEVcuJ8Q=; b=cA1D0wRikMeSfFDqsKgSnrfryO/La+ilycNlImy/x8JzHYsQPGb6RKmy0qbkKFkG9B blXK8WRJtAi3KecK7OMeh0X0lW3wNY4MB/m4vq6L93ogCA3WCUNyiS90BLlaTcDs4tTs dB21zipyNVpmWQ2jvNxgcipuDqorvYgnVtNCSSXUDtArFiL0BeUQFmfjVTdgnsZRxfk/ cByjF3UK+mlA3qvBOcklGsMSPvPrRoit35bsXnVI1UDTe6/0n7CuhjdPg1bCpsKTo9zT YjkD96x4eILtsjDaZ/wDCRAmTS82BJ0sxxO2+TbivP+pPtIsuXEDi85TOcYq+hmMSNbz /CrQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b=dnzKh2OB; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-88996-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88996-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d125-20020a633683000000b005d71b72c632si4287762pga.81.2024.03.01.11.32.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 11:32:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88996-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b=dnzKh2OB; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-88996-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88996-linux.lists.archive=gmail.com@vger.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 43575B26550 for ; Fri, 1 Mar 2024 19:10:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 249273A1A7; Fri, 1 Mar 2024 19:09:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b="dnzKh2OB" Received: from smtp-8faa.mail.infomaniak.ch (smtp-8faa.mail.infomaniak.ch [83.166.143.170]) (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 6124F39AF6 for ; Fri, 1 Mar 2024 19:09:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=83.166.143.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709320190; cv=none; b=hDu4WM4ny4MsanmU0mhc/9Szd2woVhtUnrOxlF4fv3INpqhbdyv/eoUwFFFOnN+RlOLnVAD1N15PdcB4UqEffh7qbr5RUIp1sG8C1bkdgpDSFI1z5FNlxz0Al6UUsJJkniC8BGlcJIgKJqkbqveCkONSLRUAbAgEkeAjj5C5ZtM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709320190; c=relaxed/simple; bh=rjofMt5czWAZ/8UdgmbuNLIMUbqVfuBuDdVqP8nEB2w=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=iaotNkRSQ6e2nWQwckGmljR6L67XP75AAIoQFc3KtvlBrNbd+yb1PqqpdSPlfMEc705nYwTnpSUt6v0xICsVdJ+Ln1Y5R3jFj9w8hQh/ubbKdpRfiB2740kh2sRb4hfA1sksLuYSQyFh7YkQ90VGH0kCN54VT7+w7F5TviBWdh4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net; spf=pass smtp.mailfrom=digikod.net; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b=dnzKh2OB; arc=none smtp.client-ip=83.166.143.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=digikod.net Received: from smtp-3-0001.mail.infomaniak.ch (unknown [10.4.36.108]) by smtp-3-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4Tmd1t6YX5zMyYJT; Fri, 1 Mar 2024 20:09:38 +0100 (CET) Received: from unknown by smtp-3-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4Tmd1s45G5zMpnPg; Fri, 1 Mar 2024 20:09:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=digikod.net; s=20191114; t=1709320178; bh=rjofMt5czWAZ/8UdgmbuNLIMUbqVfuBuDdVqP8nEB2w=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dnzKh2OBS0YkrIYpEspkpvDAydMZFIZk4Nh0+Gbx0+8Lk3b671LXi4kdNjVmCBsTZ Rm7K2WbZWudBEHrEPsAMJOJB+6kHAUx0XE/0mQzOmvZ1EZHpPA5fTAcSzByG999MpW RTwlsi3ZWspSksJZHRaVH8PWKdKF1bQBjNrpiNAw= Date: Fri, 1 Mar 2024 20:09:27 +0100 From: =?utf-8?Q?Micka=C3=ABl_Sala=C3=BCn?= To: Kees Cook Cc: Brendan Higgins , David Gow , Rae Moar , Shuah Khan , Alan Maguire , Borislav Petkov , Dave Hansen , "H . Peter Anvin" , Ingo Molnar , James Morris , Luis Chamberlain , "Madhavan T . Venkataraman" , Marco Pagani , Paolo Bonzini , Sean Christopherson , Stephen Boyd , Thara Gopinath , Thomas Gleixner , Vitaly Kuznetsov , Wanpeng Li , Zahra Tarkhani , kvm@vger.kernel.org, linux-hardening@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, linux-um@lists.infradead.org, x86@kernel.org Subject: Re: [PATCH v1 5/8] kunit: Handle test faults Message-ID: <20240301.EeyeePa2lien@digikod.net> References: <20240229170409.365386-1-mic@digikod.net> <20240229170409.365386-6-mic@digikod.net> <202402291023.071AA58E3@keescook> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <202402291023.071AA58E3@keescook> X-Infomaniak-Routing: alpha On Thu, Feb 29, 2024 at 10:24:19AM -0800, Kees Cook wrote: > On Thu, Feb 29, 2024 at 06:04:06PM +0100, Mickaël Salaün wrote: > > Previously, when a kernel test thread crashed (e.g. NULL pointer > > dereference, general protection fault), the KUnit test hanged for 30 > > seconds and exited with a timeout error. > > > > Fix this issue by waiting on task_struct->vfork_done instead of the > > custom kunit_try_catch.try_completion, and track the execution state by > > initially setting try_result with -EFAULT and only setting it to 0 if > > the test passed. > > > > Fix kunit_generic_run_threadfn_adapter() signature by returning 0 > > instead of calling kthread_complete_and_exit(). Because thread's exit > > code is never checked, always set it to 0 to make it clear. > > > > Fix the -EINTR error message, which couldn't be reached until now. > > > > This is tested with a following patch. > > > > Cc: Brendan Higgins > > Cc: David Gow > > Cc: Rae Moar > > Cc: Shuah Khan > > Signed-off-by: Mickaël Salaün > > I assume we can start checking for "intentional" faults now? Yes, but adding dedicated exception handling for such faults would probably be cleaner. At least we can now easily write tests as I did with the last patch. The only potential issue is that the kernel will still print the related warning in logs, but I think it's OK for tests (and maybe something we'd like to test too by the way). > > Reviewed-by: Kees Cook > > -- > Kees Cook >