Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp532333ybh; Sat, 18 Jul 2020 11:31:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwke9DZAUwNyfVvzuqD2QzCB2uPY3l/JBNA/8HQjnggxBHpBOHVMLxY0NINwuVag5+6ToP6 X-Received: by 2002:a05:6402:1a4b:: with SMTP id bf11mr14024147edb.191.1595097073033; Sat, 18 Jul 2020 11:31:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595097073; cv=none; d=google.com; s=arc-20160816; b=nHYBFkMps87Ba1o/D8X0yE3s7BqOz2Sm92bULIQ+denHmJTCBfqH3/6+EeXEO//Wne R5lD6X126jMFUg5lo2sDjHV3MYRtUHsgLBP4IWfqNaNAGNTMLOt4de+FrlyQmnSxXjLc xRmL3Dc9qGMPG9y7zGNulWzDcFqEnkzaLeX54l9dauaij7bNKPFX7DpHtNSKWZ63TPaL /E0tICM7XutiLS7gzVRHI7UzF/SVQU/fkPR/RZi9xfoBNB1S8OCbEOhy+XQL+CFoqlQh VXCFgdoo1NlpFBDOzgps++KyxNjCwXHWseMqd8bT7WlQHF4rP6oQO3v3/LCT2/qcdkhv gk8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=saDczXhc3VeOqItVm7KGqjb2lR8I8am7UWvoQvXUfek=; b=FjKlD5qwPshr4TcWOeIdhCmejNMZDkqK5xXmuwpwP/0DIvCO0c5LuGC/vS31eS4WI0 vx0u++2p6UcCKv2kUH8mN0psBCC7PoKzTUxmKJh1PPc2chVmlk1YGC2EB83FgdQR15rh qKfk4ekc2t/6qlvQQbuYp+KJECZPZxnppRQZyVXedId/G17p0q2TY7wxCGHB7rX9bGKe zT5pZTpsID6JtFnRB5T5D1DbnP5YZrOveWjU2gN3ImeRlBpmb0hyN1iqiHkgZ3WARfU5 PGBdGCpgazvcpucYyiS2PU8G6l+SG1sr9G23L3y3pCleDln3v2W+9tWpeL65h1p2OdS2 07Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Wq+W/AEo"; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f15si8005506edt.552.2020.07.18.11.30.49; Sat, 18 Jul 2020 11:31:13 -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=@kernel.org header.s=default header.b="Wq+W/AEo"; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728210AbgGRS1v (ORCPT + 99 others); Sat, 18 Jul 2020 14:27:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:59184 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726690AbgGRS1v (ORCPT ); Sat, 18 Jul 2020 14:27:51 -0400 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5CA362076A for ; Sat, 18 Jul 2020 18:27:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595096870; bh=0/uzVOeqOSkhjD5cKCKfDXwHah7S3/NW8UIwyXORlf0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Wq+W/AEowqqwk34qKH5Tc2Ck1fZlF2f7ijggRN7hDCCOQ3cIGUGx/E1Yl4F8xWE2o XCuS2RJLFY1JmHMLQZxQ3zaToKm+T9QdLQZjkQxl4521xDQktLy9fJhbc0icszRMLj mSo6s/OUgDHndawvYZkExWDW7FwT9vnikRTJ3Ggs= Received: by mail-wm1-f48.google.com with SMTP id o8so18660471wmh.4 for ; Sat, 18 Jul 2020 11:27:50 -0700 (PDT) X-Gm-Message-State: AOAM5309UB2mZ/hNTf7ob9gpkSXTqaheJwJO7RiEcZ+jbSL0jD9awI27 CYC4dyCNTu96rnkaHc/fMB4xhzaWJp51pa3rdwKe7w== X-Received: by 2002:a7b:c92e:: with SMTP id h14mr14024554wml.36.1595096869015; Sat, 18 Jul 2020 11:27:49 -0700 (PDT) MIME-Version: 1.0 References: <7653c6c74a4eee18b8bdc8262e0c0b5b95f9d771.camel@intel.com> In-Reply-To: <7653c6c74a4eee18b8bdc8262e0c0b5b95f9d771.camel@intel.com> From: Andy Lutomirski Date: Sat, 18 Jul 2020 11:27:37 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Random shadow stack pointer corruption To: Yu-cheng Yu Cc: Andy Lutomirski , LKML , X86 ML , Borislav Petkov , Dave Hansen , "H.J. Lu" , Ingo Molnar , "Ravi V. Shankar" , Sebastian Andrzej Siewior , Tony Luck , Thomas Gleixner , Peter Zijlstra , Weijiang Yang Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jul 18, 2020 at 11:25 AM Yu-cheng Yu wrote: > > On Sat, 2020-07-18 at 11:00 -0700, Andy Lutomirski wrote: > > On Sat, Jul 18, 2020 at 10:58 AM Yu-cheng Yu wrote: > > > Hi, > > > > > > My shadow stack tests start to have random shadow stack pointer corruption after > > > v5.7 (excluding). The symptom looks like some locking issue or the kernel is > > > confused about which CPU a task is on. In later tip/master, this can be > > > triggered by creating two tasks and each does continuous > > > pthread_create()/pthread_join(). If the kernel has max_cpus=1, the issue goes > > > away. I also checked XSAVES/XRSTORS, but this does not seem to be an issue > > > coming from there. > > > > What do you mean "shadow stack pointer corruption"? Is SSP itself > > corrupt while running in the kernel? Is one of the MSRs getting > > corrupted? Is the memory to which the shadow stack points getting > > corrupted? Is the CPU rejecting an attempt to change SSP? > > What I see is, a new thread after ret_from_fork() and iret back to ring-3, > its shadow stack pointer (MSR_IA32_PL3_SSP) is corrupted. > > > This is going to be impossible to diagnose, given that the upstream kernel doesn't know about these MSRs at all. If you point to a git tree, maybe I can spot the issue.