Received: by 2002:a05:7412:7c14:b0:fa:6e18:a558 with SMTP id ii20csp102772rdb; Sun, 21 Jan 2024 19:59:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IHW4LBhjblT4JOO0T5bk6zRYLwgQV21Tp870Mp/PVYGDEnxLfincsIEr5UjlP17MRihnZuw X-Received: by 2002:a50:fb8d:0:b0:559:ffd7:a19b with SMTP id e13-20020a50fb8d000000b00559ffd7a19bmr1618448edq.30.1705895945874; Sun, 21 Jan 2024 19:59:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705895945; cv=pass; d=google.com; s=arc-20160816; b=HmXOwjFI6erj5rkj7Z5FEY0/4nE9pQvJgssmv8CEM6Z/C42rvLevOmyDvsn35UMMUL T/kGxdyx//IgPzKX/dTWNrZ7TcxqP+r2ur8MLGuktRwd++Efq8BIkNMwJFsr0AxFdND8 zQ5/iIxwB8qORI3ZJpjYxxwu+jJOoWo/wSV/QGe/BjN6CNoC68CGi86Xx4Um3awQgrLN Di0iBuVqMg8LIQFhGfek7IaeNGuFAej9ozTaPJNQOjP1FZo/t1sYYfeb4SRM1leD2pKv 14byN+11Th4gnX/jE0kUO8G05HRUq8PEMdh4TlvM+hwOdQQFmEnDD+0njRwIeuvuUE9e Zm+g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=0nTrFT7rRpBWds3+I6H31jRLE1XMXyJqWuOdYqlemoc=; fh=vQROzqsqKbuBfUG1c6TTNscEWyGEIW0EJDI4Xjopjr8=; b=h/LxWUanWo5c81n8QjIt67rU6nvNNrcbIHazZ99bnpNVn0wLSFhBMqMnTGORS7HFif agNSv9Z/LRPvAMYzbkXtxNS/1bxT+54g3NQPNQxP8FhfjU7g4BUQ0Zgbwij5YMz71odZ CVNqLDK2EygX0oGik9ISjRt2HeGHA06nAm4BSGIBo7WBQIMq9RM934Yydg6EWcYE9ABm Ol1ugRwlbt9RKLLJ2W9nS2BmMaiGuYpHRWoYNc0oRzLjmjA+qOpts/KnRFYLG9nylyk0 g7iAoQevPJ9BhcEvE+7N0G8TddhM2AW5rjTHhpae2xe6r4sE4cLjnhAGuUr7+FuIJg88 Xmzw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=U43mwVvr; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-32312-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32312-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ew6-20020a056402538600b0055a63faf522si3257410edb.3.2024.01.21.19.59.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jan 2024 19:59:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-32312-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=U43mwVvr; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-32312-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32312-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 9B13A1F234F8 for ; Mon, 22 Jan 2024 03:59:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B60BE1FBA; Mon, 22 Jan 2024 03:58:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="U43mwVvr" Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (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 5BA781C2D for ; Mon, 22 Jan 2024 03:58:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705895937; cv=none; b=kcJu90vCRfNKok435w+wjzX9W8H5ds5B3ug9j1QehtNnRKeOnS3jHUHR6ar8Foz6PJzS/bHyn8prUy0+WxWAFOMG0oXYKEbVq9rYlIiMMEICpWXi6PSrx0KOc2dBkzJQoRfE3SWBVazXM+zgQu972CpD1GujvwRSVY+ZezKLZdg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705895937; c=relaxed/simple; bh=tLXsqPP7DZTbGqeWxVioSmb1fX8OXB2SzYiah5WXtgc=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=pyFux5opaJ6dRhM/mbzh7Qcjxm+/DTf68of02U6OeN+bUFMPVdsXMdjIvkXEbVnDNot97ezPFcVnkLY3UrCCV5AwWyt3JYDQfN7ywZafocn5sDtbvtEPdxBn7l1Kp2P+6tb9Hoceu15dYUyfD13CnMl+fN3Kp0uWj0nvwGId/4w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=U43mwVvr; arc=none smtp.client-ip=209.85.208.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2cef994d4e6so7129201fa.2 for ; Sun, 21 Jan 2024 19:58:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705895934; x=1706500734; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=0nTrFT7rRpBWds3+I6H31jRLE1XMXyJqWuOdYqlemoc=; b=U43mwVvrnNbyhUXtAeFnKL8CnOHfPT4mOtsBL4PbJhOv5gVNr8hQOULZZpwRFaQi0X oUkyQR01OK4NMz+gJ4S7WZD30Y7vE7cx5n62V5mc1Z8Q83fk2fmSK0ugF71kEpkXyiDW b/lSsdGTvsFZStYe9EaJiqPohvfEODx3S3vG/djyGFN5eEhaNcmvYdz2m68GWOP6VKQ5 /3X2mu6b8S5KS4p/jWJ4M89KdSXK1Yg+VZq12kPUmcj2FM/He9xTygAg8y4DTKcb0jbZ dVKZ5bPg04CF7J5+8+39lxt3j6g0/9qhaK2cS31eTCbhhBbCuIw+1svjeew3DUpvuqF1 cuWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705895934; x=1706500734; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0nTrFT7rRpBWds3+I6H31jRLE1XMXyJqWuOdYqlemoc=; b=kTPEYU3/ktX5WLoHJWAzED1BnrWvRIT0RCezFNildwaa6WjCqxeEOTg49SIfcShDn5 +aTS6Vo3rR5RoJYWMFTJ9DGFj3iFq9PLGKRB5HNmkuYcpKh87ZH/EiMa+tyMB1w+UR0f 5bH2E+L85hJCtJcL02m/u9cbOl/e5RWLMYUqtCLY8atKuLARBTEiZ5Ti9BxYysZ037ij dKypm1mSzDeK32I+ajCyu8HMoIkFR8DBAmOMWoYgMLYdWdRcC5lIATQQZ5KpMHPupIeJ w0ocAokGyCRcKH789kpkUnK/LwskOeLItYJV8gX3yD9jAp71ovRJJyAVGiq3nR5gdnJR OYMw== X-Gm-Message-State: AOJu0YzYhBWYUVxHO70ONI+u1Ig8eYlQjO94hCgiUcJgIua/Nu5+lIlw t2/6Dlub5gwJMi2/Xfnl/QQduplVvw5A+FdFS6MfWy/R+HGlFuwRY5egfYoTwsv6Vw9nCHiw+EG iTQNGNCSq3MqnAVHKbgs6duY/H6Y= X-Received: by 2002:a2e:3519:0:b0:2cc:31e9:745e with SMTP id z25-20020a2e3519000000b002cc31e9745emr1165912ljz.60.1705895934035; Sun, 21 Jan 2024 19:58:54 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240116234901.3238852-1-avagin@google.com> <30cd0be4-705f-4d63-bdad-fc57301e7eda@intel.com> <54bcb902-0fab-4a53-8b8e-85b6e4484b03@intel.com> <87cytyfmd8.ffs@tglx> <5bddbb34-4081-494b-8c12-c2e70898a608@intel.com> <877ck6fg0z.ffs@tglx> In-Reply-To: <877ck6fg0z.ffs@tglx> From: Andrei Vagin Date: Sun, 21 Jan 2024 19:58:42 -0800 Message-ID: Subject: Re: [PATCH] x86/fpu: verify xstate buffer size according with requested features To: Thomas Gleixner Cc: Dave Hansen , Andrei Vagin , Ingo Molnar , Borislav Petkov , Dave Hansen , LKML , x86@kernel.org, "H. Peter Anvin" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Jan 18, 2024 at 2:11=E2=80=AFPM Thomas Gleixner wrote: > > On Thu, Jan 18 2024 at 14:02, Dave Hansen wrote: > > On 1/18/24 11:54, Thomas Gleixner wrote: > >> On Thu, Jan 18 2024 at 10:27, Dave Hansen wrote: > >>> If we have nice, reliable fault handling and then decide that we've g= ot > >>> XRSTOR's running amok reading random memory all over the place that n= eed > >>> a nicer error message, then we can add that code to predict the futur= e. > >>> If our "predict the future" code goes wrong, then we lose an error > >>> message -- not a big deal. > >> After staring more at it, it's arguable to pass fpstate->user_size to > >> fault_in_readable() and ignore fx_sw->xstate_size completely. > >> > >> That's a guaranteed to be reliable size which prevents endless loops > >> because arguably that's the maximum size which can be touched by XRSTO= R, > >> no? fpstate->user_size isn't constant. It can be modified from the XFD #NM handler. For example, it happens when a process invokes one of amx instructions for the first time. It means we have to be able to restore an fpu state from signal frames generated with a smaller fpstate->user_size. Can it trigger any issues? > > > > I like it. It takes fx_sw completely out of the picture, which was the > > root of the problem in the first place. > > Correct. > > I really don't care about the esoteric case where this might > theoretically result in a unjustified application abort. > > You really need to twist your brain around 6 corners and then squint > twice to construct that case. Of course syzcaller might trigger it, but > fuzzing the sigreturn frame is a #GP, #PF and whatever lottery anyway. In my case, the bug was triggered by gVisor (it is like the user-mode Linux). Thanks, Andrei