Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp235127lqt; Thu, 6 Jun 2024 01:51:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWn98j5p28qLI6WhHXOHKZQ9T04yhv/lJxh/JEsEMrzMZpycfbSqP8f72SeDUPqifxjVrYHxw0mBwciMMj7ExDawYC0ksuoOLtZPi+Rvw== X-Google-Smtp-Source: AGHT+IGtlA/d3XdcjOQ7cSugnmPyZZhDZQ92YWqna1reAt/oiH31kwqS5zo00g3My9qLlOjWIlPh X-Received: by 2002:ac8:5d4e:0:b0:43a:b1bf:4762 with SMTP id d75a77b69052e-4402b5abe59mr56262841cf.5.1717663908466; Thu, 06 Jun 2024 01:51:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717663908; cv=pass; d=google.com; s=arc-20160816; b=BtJpKgLCsmV7i2k9WMNjfzcyMa9vVAF8ve3chjpPHuYoDG8Nq2yYMEhO9ZM7Vno3rE tGbeVksngygCiSAIQubO4MDqKAhu02d6GeUepBfmAEix/9uZYfqVgDcNS0Yr8CZW6UZc r2ZLFU5RiphHcSOPcAo87rG53FMJ9bq8fl9cvTU0fX/doSAA7HsUbSyZXMgVMkWbfre2 tH6pca8Eb+bV0v8VQWZeJ5faSs0UkAGzWB7QX107kJJs8BOGK/4UGNXhkqCM5WMm8yLd Q/vn8yHNxmcliKXLd9v7WIpSuN/gwaEfXzjwY338zufZT36BWcH7DYI6rqUpFS8nCNCB kAFg== 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:sender:dkim-signature; bh=C7mm47USfyF10BLhroH/wO49awuW1U7B3PUEMT0cnVY=; fh=q1gKaxJuNfA+vmJM2dDddeDpKaZQSRrBo/XLzmHEFA8=; b=g9QPgCzYLdZLIU/h3K6B25P7es92ffXXU9Ce1S5qcyn4PD7oKrRsxDTav9vD7CLAIz Wc4HrVAAGCBC6hgvTR/0+uxbFRB/JcS/MgQyoUBOZeQWOjs1C5sxJO/fK9N98v6J2rjc SFbjU/lFG8pp6BeyA6R+9Rcyk1T9GEDLrNxawh/s+50I+W930gEbd4NqUvsO4eKfYw/d KdSeLaidhyrEMRmskxwfOG6pIHyN5q3I+5E70FUl8xsKh7HUTVI/EEjX8ro/45Ac32iJ aGtXuYz7Svwr0iPWPkh/a1y0ar0Ql2h+yM1/1siO1pKKcSDqXhqUNq9NcKAdb2vAMxeL alsw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=B1Q2sZKg; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-203880-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203880-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-795331ca3b8si46730885a.245.2024.06.06.01.51.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 01:51:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-203880-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=B1Q2sZKg; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-203880-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203880-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 2435D1C24276 for ; Thu, 6 Jun 2024 08:51:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3BE6D14EC6D; Thu, 6 Jun 2024 08:48:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="B1Q2sZKg" Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC8D714EC4A for ; Thu, 6 Jun 2024 08:48:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717663719; cv=none; b=CJb6ncn8Dy0sQEmnfa4MSm2bOHTHhTYFqZYC81mJfJck0Pr8X++zgGbvrAtmKry/9AI44XV+wN7LfQFTojLh0FAoVNzSZ5XUWXNWBN9erDoA9X+R9uRGEITuWg/nweYCRaWKFumF4M0NfzB5bYXLgt7dVShr6ubXw37AWVBUnjY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717663719; c=relaxed/simple; bh=l9xAn4M5MGqMAykc7g1jfGArOcfFcSGhYTBvMYs2WIQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=CNi24/bs/YCONZgNnetnHT2zpsxIYgURAElUSdx84hrFLt0qw3PwLMjcnWXZNO6Ha11gXkLBgPKSGDC1JMebb+MCKsLUvCeQNUCkuZok/vp/tJaxiiJ/oqbuQYAUA1YpQAo8Zd+YjU92WZ4eV69+jAdhlwvGsnP/KDGHdjS+mkw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=B1Q2sZKg; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-42159283989so9847505e9.3 for ; Thu, 06 Jun 2024 01:48:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717663716; x=1718268516; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=C7mm47USfyF10BLhroH/wO49awuW1U7B3PUEMT0cnVY=; b=B1Q2sZKg3MsOxvA5pcFl8Yot0bpsvDbNcbe4jPIt5MyHIvqOKCe9bhMUAe/i089QV6 27YSo301nHupBYyGOfqK2fcnO5HYoht3ELeXtZPl3HwhWDOeSYbqW0m/yF6VjOLC6p8U 4MAfnjqie/yWnt1P98leGjFZV86uK0/IamvVxI8+ghZ/Zgj838tyN64AQTrKFLTjmox9 bUg7gCf0GaHCFkblGWl9LyvglTUQLd9EaRPfX2CsZfVHooWlaMne2UQj45xQKGEn6wTN x4cLJQqabdBGJdTR2513L30UgOaT4t+x6gQ4VbCsoqJ5IPlML2Ivifplg1bbvXEDhaaA Dlrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717663716; x=1718268516; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=C7mm47USfyF10BLhroH/wO49awuW1U7B3PUEMT0cnVY=; b=HonOZHJPCUHRba/ArCEVZrqmGCWXGS6Ljvf1NKv4lnhSAzfVoGrGoBD1jPgs5FLW8M /iZLI4nDdI96QXy4PxXoAFq8DF2y2AxkSD3OBGWsY2UFqw6tBBrSRqwBtpV2joqc76G3 JoKRV9ddDXUwNI0nVm7ZPSOqVv71FW7VEbpG1G+n0SBWm1r7o3MmROqfZ+43hF/D1ZUz Wd25gDQMNohsEp3syVvem3A+o+g7F3ayfHg7ftnitlZLbSFmPTSOUayPn/x7M0ZMaX6Y 4O0oNkG07IEGBfGg2p9yCaCE6mzUHgKIzEiYz2N3+3xupQv9A36NmiFLlRELTXRxImRR 9mzw== X-Forwarded-Encrypted: i=1; AJvYcCXBVRjAu4oZBpPdQ3x655wiRVuz72A4buG7rAuOQm5VJ/toSJ8ZLphLlYhHWSA3YixVq7/hsLCaxGYMQYz6o4pmGTlZL9/kYgEwL8Xp X-Gm-Message-State: AOJu0YwBVjFPpVUQzO2kWv3SNza0IREewM6ckT16DX1jxiBUk6Bd4lAh IMvqQKwIJeRta5Q9Rb6B6+I28zf/ejo+rYJzHGUVEH/5UOAuwfo5 X-Received: by 2002:a05:600c:35c1:b0:416:8efd:1645 with SMTP id 5b1f17b1804b1-421562c354emr56334005e9.7.1717663715889; Thu, 06 Jun 2024 01:48:35 -0700 (PDT) Received: from gmail.com (1F2EF20A.nat.pool.telekom.hu. [31.46.242.10]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4215811d49esm46855915e9.27.2024.06.06.01.48.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 01:48:35 -0700 (PDT) Sender: Ingo Molnar Date: Thu, 6 Jun 2024 10:48:33 +0200 From: Ingo Molnar To: Linus Torvalds Cc: Oleg Nesterov , linux-kernel@vger.kernel.org, Andy Lutomirski , Andrew Morton , Dave Hansen , Peter Zijlstra , Borislav Petkov , "H . Peter Anvin" , Thomas Gleixner , Uros Bizjak Subject: Re: [PATCH 3/3, v4] x86/fpu: Remove init_task FPU state dependencies, add debugging warning for PF_KTHREAD tasks Message-ID: References: <20240605083557.2051480-1-mingo@kernel.org> <20240605083557.2051480-4-mingo@kernel.org> <20240605141733.GC25006@redhat.com> <20240605162610.GF25006@redhat.com> 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: * Ingo Molnar wrote: > I changed the debug check to test for PF_KTHREAD, and to return NULL: > > +#ifdef CONFIG_X86_DEBUG_FPU > +struct fpu *x86_task_fpu(struct task_struct *task) > +{ > + if (WARN_ON_ONCE(task->flags & PF_KTHREAD)) > + return NULL; > + > + return (void *)task + sizeof(*task); > +} > +#endif > > ... and the NULL we return will likely crash & exit any kthreads attempting > to use the FPU context area - which I think is preferable to returning > invalid memory that may then be corrupted. > > Hopefully this remains a hypothethical concern. :-) > > Alternatively, this may be one of the very few cases where a BUG_ON() might > be justified? This condition is not recoverable in any sane fashion IMO. And promptly this triggered in live testing, because while kthreads do not use the FPU context area, the current fpu__drop() code does call x86_task_cpu() even for kthreads... See the two new 4/3 and 5/3 patches in this thread I've sent that clean this up: [PATCH 4/3] x86/fpu: Push 'fpu' pointer calculation into the fpu__drop() call [PATCH 5/3] x86/fpu: Make sure x86_task_fpu() doesn't get called for PF_KTHREAD tasks during exit I'll also reorder the patches to apply these fpu__drop() changes before adding the debug warning. Thanks, Ingo