From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oi1-f198.google.com (mail-oi1-f198.google.com [209.85.167.198]) (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 96653429036 for ; Thu, 24 Sep 2026 21:01:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.198 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790283693; cv=none; b=GIIrfvV+jRB0yGNtefmfHWw3necUSToFMiojq/WfOem4/VCT7kmV5ynHl36C6N9yP5GBdVNTg8ajFGqSJIh9Z10P5uP9HAdudEmdhgG1qrUuGpgxarVXVrV+q0Ki6KhdJKDE2XZztISpnxsMNUyOXi2S4kUnfrDxiWeADReEXl4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790283693; c=relaxed/simple; bh=mj3SdbpcuVXLFrrUIf3KbnkVRVxd21IkNwP+DxYDJxk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=QhMrE4Q9zmECznZ9bzgVJAcF+gGMyoN4zqvGZa293kVYj4xtuc2R2TFlOCF0YY0CFvW/dPu3d9m56ix+4xKX9cVm02OQk4laADi3yXFr1UVQlBusZYBDNMQbUSVp1dpXiO9KU3nIYdkkgkshUFHFq10QAoU0tz6ajMoe9l7eU1A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--avagin.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=TOK4dpou; arc=none smtp.client-ip=209.85.167.198 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--avagin.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="TOK4dpou" Received: by mail-oi1-f198.google.com with SMTP id 5614622812f47-4b2d1eb484aso514894b6e.2 for ; Thu, 24 Sep 2026 14:01:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1790283689; x=1790888489; darn=lists.linux.dev; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=MtHl8hYmoYmzTRn6TIDSWRUdJUOUFOpNuKrI1Eig3qY=; b=TOK4dpou/60ImWBrTfsZhGjV91M6zIGGod5YekomtUvfQoN0oQlXjuPSF9Y6jxXBce ++6V90Ffg/G3j7pBzZqMOvo3gx6kOm1uXSk/LOoKmAnoH+I+IZHnybTScCftQXkLw+K5 FqblVFPsLRlyCT3MUGcEal1WBFbajHkcChQ0N+ZmLX9RX4zClQdkLuzypU85EwSyHBU+ CQGQlg1BPEBuZwE+lpIjqdPBd/4Ct+zMKlz50VpVEB+K5hax+Om3sKHwzNrE4tRV7ay/ EV+zoqlfnDmqfrBO/LhwY/5DFBBpcZWON19Io125FKwdIHeSVDVtbD+62qItZxEjGBo1 PK3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790283689; x=1790888489; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=MtHl8hYmoYmzTRn6TIDSWRUdJUOUFOpNuKrI1Eig3qY=; b=qn8svSGVUgnagFRhxqC7vHMxxJrbHIDaKHGZepMJKV1o53gLu1scI2sXRghBC1DYqD snpjVvi8TASYh2efgWpOWeSmm+MyU5z+iqbMoQQZzDJFPctDwtG3oIfFi/5+tLHltkdV 7A33gZgo9zYTiyCpS5Yla68w0FQZVfMJ5vNYxWCpebOnQKhFQE4IWf0X/aaGWOqN8YLy uRQ3tMH95JyBtKGm7qGkzqfRb11no0xkLD4cgPj4ZFmNR36Zt96a4qu22zV7Qfv+GZp3 xreCOVBFZSpaZpKVoGUPCziqBD8aGjN2B2s7wQgxtBxMTWysuZDaKNRG3OJKqAuZeeZt mpSw== X-Forwarded-Encrypted: i=1; AKwUvByS9JzF7xfAgmYUDYMexpwwbuuSFfFuNxCkxoHzW5IeQ4tJv/Nqg8Oe3lAU4Cb1vx6LTMxX@lists.linux.dev X-Gm-Message-State: AFuF++kU8ue+UFMlZy+yvPCdS86zGVLO1/fLQ/EGInAEBBiVp0JJeK7v 790nJAy58HGVfjAyfszcQlSlzz/DsdFkR+L8ZmJMvvhUuR8b/yviH1UQD3Obz2x9OGueJajtrR2 V0kpFAA== X-Received: from jaar2.prod.google.com ([2002:a05:6638:c082:b0:5f1:d3d4:268d]) (user=avagin job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6808:3090:b0:4b9:e65b:8c39 with SMTP id 5614622812f47-4d72aa5ad53mr4530494b6e.39.1790283688845; Thu, 24 Sep 2026 14:01:28 -0700 (PDT) Date: Thu, 24 Sep 2026 21:01:18 +0000 In-Reply-To: <20260924210121.87032-1-avagin@google.com> Precedence: bulk X-Mailing-List: criu@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260924210121.87032-1-avagin@google.com> X-Mailer: git-send-email 2.56.0.rc1.315.gc6ed9934b7-goog Message-ID: <20260924210121.87032-5-avagin@google.com> Subject: [PATCH 4/7] x86/fpu: Document reasoning of FX-only fallback From: Andrei Vagin To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , "Chang S. Bae" Cc: linux-kernel@vger.kernel.org, criu@lists.linux.dev, Dave Hansen , x86@kernel.org, Andrei Vagin , Alexander Mikhalitsyn , "H. Peter Anvin" Content-Type: text/plain; charset="UTF-8" Add a comment to check_xstate_in_sigframe() to explain the reasoning behind falling back to the FX-only state when signal frame metadata is inconsistent. The fallback is intended to preserve backward compatibility with legacy user-space processes that are not aware of XSAVE states and might only fill or copy the legacy FP state. However, this fallback should be avoided whenever possible. If a process was actively using extended features, falling back to the FX-only state silently resets those extended registers to their initial state, which can lead to silent user-space state corruption. Reviewed-by: Alexander Mikhalitsyn Reviewed-by: Chang S. Bae Signed-off-by: Andrei Vagin --- arch/x86/kernel/fpu/signal.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/x86/kernel/fpu/signal.c b/arch/x86/kernel/fpu/signal.c index b9dcd0cd0e41..d56819fe491e 100644 --- a/arch/x86/kernel/fpu/signal.c +++ b/arch/x86/kernel/fpu/signal.c @@ -54,6 +54,14 @@ static inline bool check_xstate_in_sigframe(struct fxregs_state __user *buf_fx, if (likely(magic2 == FP_XSTATE_MAGIC2)) return true; err_setfx: + /* + * The fallback to FX-only state is used to preserve backward + * compatibility with user-space processes that are not aware of xsave + * states. + * + * In all other cases, returning false (to trigger SIGSEGV) is + * preferred to avoid silent user-space state corruption. + */ trace_x86_fpu_xstate_check_failed(x86_task_fpu(current)); /* Set the parameters for fx only state */ -- 2.56.0.rc1.315.gc6ed9934b7-goog