Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp818250pxj; Thu, 27 May 2021 12:20:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRGvgoqZHaDoyI1pxaHJ9gwTTIzYCN6nJPLZ63zFw60Enl14pW+27VkP+tcYifYTj4356Y X-Received: by 2002:a50:9549:: with SMTP id v9mr5990833eda.312.1622143259494; Thu, 27 May 2021 12:20:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622143259; cv=none; d=google.com; s=arc-20160816; b=MI4CnuXB99+ZUAR5fyPxaXagEyMuF8YtJPA0aM92LAuo/v7wxN1h3XmIzaQ7rJVLaS 5kzzny3xgC06JKn+f7x7evYHJHhP+GsBjUxsV1JkcdYAOg84rBjdavJByqiSQzIv/d0G 7BL+N7ZzXbOooQSzsLBqsDNo9pngMHKEO44Wf9kMYqHFbrtEDub2RowOfjPowc3rRkTG srJoRfLfZRb6B/6j6tiU5tdE2mw1iqUh8PotK/WGZmQsBchIBLxBwKaiI7AFHR1Vn3B2 Sl0TrHnli4Cxatvq8/NeOC5G22Ri76sKe2PCbHEDoPHDQK1XiZvTTiCY2VXBFyChafAx Ul1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:to:dkim-signature:dkim-signature:from; bh=WO9Ffk5zvc6wscj8WLhjqrBBshoNYmhwd/PJW0bJ2lY=; b=SOz+89J65uk8VPOcbv8bAa+occdwfldtsMqctLMlPpXhbCH5Y22qBCfdIalDSFD8KB 12+IQi1NXSZbFxQf0YjGsFLVkTs6m8SO8Qk9UNHXgRKaJSopP5+ksNXmxhC1WPFGCtrc COsvhjeMD47kP1+HQBUsHLa/1FpwdAznTAaglN+H7mDoPpzZuyvkLDYiuFW8bs958yUt TZVsxhjX4wO4UwqkPTIp+iOV4gH+vw3AEy1+wvnD1yY5RTKknKBhr7O9Ky5H+AepQxur yHOL/cwz98feS5+thbH6hZ3YQKtbaisRWMbcxzLU6TpTj3wMk8jdudG/bM5F3NEYbvjM x76Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=lUszLzgt; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=1665o0Fk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i10si3774734ejd.137.2021.05.27.12.20.35; Thu, 27 May 2021 12:20:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=lUszLzgt; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=1665o0Fk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234359AbhE0TSi (ORCPT + 99 others); Thu, 27 May 2021 15:18:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233565AbhE0TSh (ORCPT ); Thu, 27 May 2021 15:18:37 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44350C061574 for ; Thu, 27 May 2021 12:17:04 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1622143022; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=WO9Ffk5zvc6wscj8WLhjqrBBshoNYmhwd/PJW0bJ2lY=; b=lUszLzgtxK9We+YdyK2J3nzMwT2DmcgQkixgBJNMeSSvvHaKXsaMfV4rG8Maj184ELG3am sKIYwHcfJAoaPDiKs9HQsyAMYlnVszZHwp59/GVJPTCDR1V2nmwiopqu1wJ/rQqTpngC6B YU0LpsXsjdXEY1Ki2KQdzQQNELDTn3m+EeEqQ7Ra2PAIui+KfoGjb9Z4JB+MPOQT742pS4 SIYCDhCHzT0tGl7f/0bvQwIeNrAthOVGwU4EoKpVOR2Z44FJJsuZcjh02S7U9C5wy0DVxv ej93elObpQw1rdt2/4A6/GDLrCXrslXAZxIONuHg/v017ZbqA2wIFF7GbVCGMA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1622143022; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=WO9Ffk5zvc6wscj8WLhjqrBBshoNYmhwd/PJW0bJ2lY=; b=1665o0Fkpzcmqas363kUxfojqDCR564RT7XKhttJPSm2n4bAMiPZU5MGBLt6WO42QZTBTE wndGTm0EvGTyl+Bg== To: "Yu\, Yu-cheng" , Andy Lutomirski , syzbot , bp@alien8.de, bp@suse.de, dave.hansen@linux.intel.com, fenghua.yu@intel.com, hpa@zytor.com, linux-kernel@vger.kernel.org, mingo@redhat.com, peterz@infradead.org, syzkaller-bugs@googlegroups.com, tony.luck@intel.com, x86@kernel.org Subject: Re: [syzbot] WARNING in ex_handler_fprestore In-Reply-To: References: <0000000000004c453905c30f8334@google.com> <87sg29886g.ffs@nanos.tec.linutronix.de> <87bl8w86m3.ffs@nanos.tec.linutronix.de> Date: Thu, 27 May 2021 21:17:02 +0200 Message-ID: <871r9s7zrl.ffs@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 27 2021 at 11:59, Yu-cheng Yu wrote: > On 5/27/2021 9:49 AM, Thomas Gleixner wrote: >> On Thu, May 27 2021 at 00:03, Thomas Gleixner wrote: >>> I decoded it fully by now and will send out coherent info (and hopefully >>> a patch) tomorrow with brain awake. Time for bed here... >> >> Not yet there with a patch, but I have a trivial C reproducer. See >> below. >> >> The failure mode is: >> >> signal to task >> sigaction_handler() >> wreckage xsave.header.reserved[0] >> sig_return() >> restore_fpu_from_sigframe() >> try: XRSTOR from user -> #GP >> copy_from_user(fpstate, task->fpu.state.xsave); >> validate(task->fpu.state.xsave) -> fail >> fpu__clear_user_states() >> reinits FPU hardware but task state is still wreckaged > > In fpu__clear_user_states(), maybe can we clear xstate_header.reserved[] > as well? Just because my reproducer wreckages xstate_header.reserved, you think it's sufficient to maybe clear that field? May I recommend to study the XSAVE documentation? > Or do we want to check the user buffer first before copy it? Before your patch the code was correct. So maybe study the SDM, the code and the commit and carefully read this email plus the following ones before you come up with more helpful suggestions. 80 lines of useless quotes See: https://people.kernel.org/tglx/notes-about-netiquette Thanks, tglx