Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp3246542lqo; Wed, 15 May 2024 04:21:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWPj75CONC2UxTBA9CDxy9I+xio9A8mpjsySZc7UIhMhD7TAOuj8WBjNpwIwsXUh2rA2XZKFqvoYa5ucVBI4UvC3ymLfKpokKEHTNBbHA== X-Google-Smtp-Source: AGHT+IEaN78f7STLbxGOPEGCDV/vbBoR74JS9AjPe5NjCCpZUIAf00mVdvqr9AMDo/JIb/4aam93 X-Received: by 2002:a17:906:a050:b0:a59:cdf4:f948 with SMTP id a640c23a62f3a-a5a2d675dc5mr1463421466b.65.1715772114376; Wed, 15 May 2024 04:21:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715772114; cv=pass; d=google.com; s=arc-20160816; b=Iuxk8/lIS6B6ZKH3JwVlyvMZO9jUMzc1yFGjZSPGVZC1bR9YKYjqTWpru3d30yiiYZ iHY0fh1eKWL8diBSpJrxX9rzOERzCUBWkJbxTOJp08+WnchhLeLdUQ0dMSr2tqzAstx5 a6JrDaQnqEf5wBgbPXO4liAPUFxDmV9SgNKaxbZ4/egIY3MzPJOUDt9yfZSrzLLh1j1F XpFXYgd9/cS5FjOjMOGl02l34FP6XDXEZLsQOJA081/JuNnDu4XXQRJPGGLcaNrZh91F +MeaoA2fpvFAjA2/SoewlfdkXeyNtzKLnHNjE7UzrcymPENaLIhsowDpRtDonGuwTGm3 EmCg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=h5bDd9jfqFy8/uy57c7rT9ALmyU6BJ6GsFfTS9tK9yg=; fh=3OH/MMtI54GRRrrKcJTPZw8sN5vAC6Gt8lBYjgGt8Kc=; b=LWLwermQ3GmVMmWbE8y4eRVaCGa/CuGb/fmrRp0qKW5SgqmQD8VGwcfX43u6QDBw/y 91nqzPr6/WNWSoCQZ8aSP0RZHrsdJbyKgaT7WUMyiQwq5ZRR1+w17UBol64BcfNsdiuL YjX8l4jfw/iK8xJVGctXYtS74ldDoXkevOg+0Wyz85vwHabk4uATdkJ36AScCXf9FYo7 faMgwFR2LK8eaSepnKpye4rzXIMBpPDWbXcusKokTPnzUyU055Q9yh9ymI7KZXKISI68 1fmwLNme1zf+pvccIY7y/ffrMYZ/k0JiJwtVJqXnOf7VsUpW7iAg5/XvrN7qdWHCr9qD rQ3A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WKLSLYPI; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-179799-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179799-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a17c2c163si689334166b.926.2024.05.15.04.21.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 04:21:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179799-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WKLSLYPI; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-179799-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179799-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 1F8891F24191 for ; Wed, 15 May 2024 11:21:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 00A09762FF; Wed, 15 May 2024 11:21:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WKLSLYPI" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C7F037605E for ; Wed, 15 May 2024 11:21:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715772068; cv=none; b=PUwwuE2IVDYCGbFm9gl1GDEFZ0iNfzOJfEuZcGrtKR0Dk4j5WY9Q1HnZSScIfHvVIk90sioEslI/jHjX5iCaYiVEPKRCVLcSD1n6vOjynmvOyc5mrG2X8JiRmZy5MGtJeAbpYAlPbWq3464uusdFU0i4UthEeGeI0BUBjvjzElU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715772068; c=relaxed/simple; bh=M/ZccXoJRnPbA6meUj/MmsF/JxN6cGeMpuCaH9Cj9bw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=MV+eZfQ3+k7/nS6CGej63JsBBUXwNIpN7fIEAK+8J/cbCapxl/jS3piWty+4+txU+Zvq1vh/DSo7kmaR9nPLNR979n+BDhhejKD1Shf6RoVJPy1F6ngXsYWWb3K/B+49ZLkPVYxejgbD2fwM9G5PcrkYvCd+S2Mfp9zzeuMM9Sw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=WKLSLYPI; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1715772065; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=h5bDd9jfqFy8/uy57c7rT9ALmyU6BJ6GsFfTS9tK9yg=; b=WKLSLYPIVNx9BPfTU2gMFWDkwlzIrJ6JdqAOEg8rvhzwffgTk2eFit2H36jubhEzcJ0WIQ BkVnS6mpP7134O4JHicKaNOyDuFKN0cXKsmgsv6N4IoErowok/V/W3wxBU771u1nMOiKD6 yNO2p/dxtr9jFmc5vkYPWZzXPB9gGP8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-257-WhGl7FHGPIyWXZjzT2JL7g-1; Wed, 15 May 2024 07:20:54 -0400 X-MC-Unique: WhGl7FHGPIyWXZjzT2JL7g-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 415FA8058D7; Wed, 15 May 2024 11:20:52 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.226.36]) by smtp.corp.redhat.com (Postfix) with SMTP id 26913200A08E; Wed, 15 May 2024 11:20:46 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Wed, 15 May 2024 13:19:26 +0200 (CEST) Date: Wed, 15 May 2024 13:19:20 +0200 From: Oleg Nesterov To: Deepak Gupta Cc: "Edgecombe, Rick P" , "olsajiri@gmail.com" , "songliubraving@fb.com" , "luto@kernel.org" , "mhiramat@kernel.org" , "andrii@kernel.org" , "john.fastabend@gmail.com" , "linux-api@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "mingo@redhat.com" , "rostedt@goodmis.org" , "ast@kernel.org" , "tglx@linutronix.de" , "linux-man@vger.kernel.org" , "yhs@fb.com" , "daniel@iogearbox.net" , "peterz@infradead.org" , "linux-trace-kernel@vger.kernel.org" , "bp@alien8.de" , "bpf@vger.kernel.org" , "x86@kernel.org" Subject: Re: [PATCHv5 bpf-next 6/8] x86/shstk: Add return uprobe support Message-ID: <20240515111919.GA6821@redhat.com> References: <20240507105321.71524-7-jolsa@kernel.org> <20240513185040.416d62bc4a71e79367c1cd9c@kernel.org> <3e15152888d543d2ee4e5a1d75298c80aa946659.camel@intel.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: User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 Sorry for the late reply, I was on PTO. On 05/14, Deepak Gupta wrote: > > Question, > > Is it kernel who is maintaining all return probes, meaning original return addresses > are saved in kernel data structures on per task basis. Yes. task_struct->utask->return_instances See prepare_uretprobe() which inserts the new return_instance with ->orig_ret_vaddr = original return addresses when the tracee enters the ret-probed function. > Once uretprobe did its job then > its kernel who is ensuring return to original return address ? Yes. See instruction_pointer_set(regs, ri->orig_ret_vaddr) in handle_trampoline(). I know absolutely nothing about the shadow stacks, trying to read Documentation/arch/x86/shstk.rst but it doesn't tell me too much... Where can I find more documentation? I didn't try to google yet. Upon function return, the processor pops the shadow stack copy and compares it to the normal stack copy. If the two differ, the processor raises a control-protection fault. grep-grep-grep... exc_control_protection I guess. Let me ask a couple of really stupid questions. What if the shadow stack is "shorter" than the normal stack? I mean, enable_shstk() { prctl(ARCH_SHSTK_SHSTK); } what happens when enable_shstk() returns? And what is the purpose of fpregs_lock_and_load() ? Why do we need to fpregs_restore_userregs() in shstk_setup() and other places? Oleg.