Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp127435lqh; Fri, 3 May 2024 16:02:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX0vXKXT62C//cyLExgynXj3EGwR4Eei8wXPUjNFlRkH2UaPvgn3oVa0Lvcebr/cdwFAUbezX8Q4CESiaTgj7SMH6rQMq2KMY8fzG3qBQ== X-Google-Smtp-Source: AGHT+IGwCNqa/wd4oPLu/mGR7UbZhlqbWqxDbCYPl3yJeBkrizHVLNZbVfCHTltE/XzagOfQckwR X-Received: by 2002:a05:6122:c81:b0:4d4:32e1:e7b4 with SMTP id ba1-20020a0561220c8100b004d432e1e7b4mr4225844vkb.4.1714777340041; Fri, 03 May 2024 16:02:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714777340; cv=pass; d=google.com; s=arc-20160816; b=iOorfpPvnnO9w4cd01KJfugB5iwUv2jtAN95Jq2GhhXxdk2447vUNgfdADPODAjSVU Pia3jmeQa5mHaz44RttQG5ITLeaSE0mBsCFQMOsZvJNTwROm6VcjjPclWrFOw2LSGV1g KEg+P9ItqmnWCgD6d7reakf2NtmOcpCKo15PjrKQAkGZX22ZijzAoMdb1rmMJD6k1MIm DTwx6FTZkBiWBzn/eg69Hjc4zebBgw2cQESSE2pglBfsnUQAzrh+Bt3Fy4SMul1L7Nkp ytS3V+fnKhjm+6x/PS5KmzcYXQI6SL6yUZdlkegAcLfsZeh8nEQmPOTYS+JPVr0P2Dtz S2pg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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=4+92T3dF1pCkzFJyIvWH9pdOMABziRyYEtERHQRUflQ=; fh=LeT2SVB0ycgpxU6RUC0/cdm/Y4yFAe7If9EgQjMMTsY=; b=sXtkXLwo1GNp2Z1/ixZ5EFqKJQaoRQYb9k3fVmJ+yoYtRUsHFi4sLvTJnUxcl9Kp7s kxCKrIDyEr0j7/zWVYQFR2eEm+tQTbC7wjf/ka/Ws25XX50S9B2Y5QoQNikO1l+xy3X/ ZrJJWTO/wm/BGhvCrcMCt41JuQrepPoPRGGUHv7i6Z+F1yCMw3Yjkts4wVeOG2FBW73d xbKznB4PLJAO/xKG4d64eHuSnCye9dxbnRGzzWaKgtPkQA4SgepT4HYDDVUD1ul9WUoS piqGZRBXPQfumppKzaLvPiH+16KIZQpVBaNkHxvF0FHtrGq8v7i53tC0Y0ZImbulB5w8 vqvA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b="zCe+/lF3"; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-168389-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168389-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id q188-20020a1ff2c5000000b004deb43f5d12si954395vkh.138.2024.05.03.16.02.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 16:02:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-168389-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b="zCe+/lF3"; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-168389-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168389-linux.lists.archive=gmail.com@vger.kernel.org" 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 6B06E1C22F8F for ; Fri, 3 May 2024 23:02:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9D4FC7E56C; Fri, 3 May 2024 23:01:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="zCe+/lF3" Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (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 5FA52339A1 for ; Fri, 3 May 2024 23:01:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714777318; cv=none; b=JbePJWeDNESwzCV8WLTb5Utm9flnZGP9MvCW5k3aBcq2xmJvCIzXw+XkB/eJQYnnAcPHzXiuIeJwxslDjRUUER9cfchaCArtjejFjfWpGh6H/gHPk0EAJDr5YBPswRxNnUm5pBGYoBozqzJLGF/v/LEPm9bLBdoEFbr+5pyEmAI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714777318; c=relaxed/simple; bh=4+92T3dF1pCkzFJyIvWH9pdOMABziRyYEtERHQRUflQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=SptrdcLP1ianSj5OSeA2qVp9QmW0rU8nd1afDbasbLg2aDXLer0EsomrVzF7a9LyQx26Awgg3zhXFqpN7mEP34wvKmmn2ne0DutrhMyxtlTh7yJ27PrvPnYdYObFAa5oz8ZKhoo3TBtH+kKErQOYE8Fuqz+lIPr+xFumPF8y7GU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=zCe+/lF3; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1e65a1370b7so1618485ad.3 for ; Fri, 03 May 2024 16:01:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1714777317; x=1715382117; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=4+92T3dF1pCkzFJyIvWH9pdOMABziRyYEtERHQRUflQ=; b=zCe+/lF34YSpkLm2TxtBbKSM5HvQTiKwAV3/44wZGfe5OEzwrVa15OMDxIqPZ6I5Ir fuY3gGUb1FAi2faOv0IGo2pG5+C0IrtWoAvDo27Rm59TDonSdrohlP/jS86LM+nBFEtr GQ3wWvTpg2+gE2rC84ee/b9iJ/8BqenQTpLVlydzmF1Q0OR+SG+iFBTc7vA2g6AR9wul m/yFYwnkqQjsc8A+msgyA4Sd2DrAZoqHoiIs/JMbDHBl0iLiHDMXXc9ty8yA5mVjjUPu NIXwFUvpRU7gKebDzlcSK+ISTKqFUA3d5KvW+ehUNElxgrnfJxbe9q+O7QQnllgNc6za k4nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714777317; x=1715382117; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=4+92T3dF1pCkzFJyIvWH9pdOMABziRyYEtERHQRUflQ=; b=bdw2U0YsLt9bkLBjvRe2OcVzxdBmvrvWx3xBe68DbisnMJAc/G5njF/A7Dxd+8vQ1A 3y/7WxqQP/XnfggECveu42zI1KDIBngFYnSJze+Yoq4pt4Sra+YP+BSpFZ1Fc4VRmu6i yingBfm+LQGRfroq+As/v5WyTzwJ/aPQu+0c8LIYF+vHGR1PblsnxwdCEphiRNoxgxYy TNktWlH65hV1GS9Fs9z9CZc5aTi7zt5/IATOKvlCo/UucFG6Rhjm6tbBFw5+T58glmvu RbGsq/ocMQ56LK6dD/VDLMO8cATvzdmkx5tAVLy3HSkDjbuSArfzPLDuUTFa0gtYulR+ ukrQ== X-Forwarded-Encrypted: i=1; AJvYcCVQCxfr8Ix4oa0YhtReow4iXw7vijGsTRtCLslyNnUutzh6CAHUY2NsmAwfgL6dtgA/8I/c1Xys4jpEM41mr2oWX4/c5bUr64gB6Q+o X-Gm-Message-State: AOJu0YwYxjr2fJyDYi0TI9XG5+uOjTS4eYxJj3dKXDPnvpDmE3fnxMcN VEJSq08/KBlOrpNpqS3gwwE403a7H3Q1agbYP/9TIlHkP2D97a9sLqu1LUua+oA= X-Received: by 2002:a17:903:32cf:b0:1e2:ca65:68c2 with SMTP id i15-20020a17090332cf00b001e2ca6568c2mr5565119plr.51.1714777316672; Fri, 03 May 2024 16:01:56 -0700 (PDT) Received: from debug.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id f7-20020a170902684700b001eab1a1a752sm3841345pln.120.2024.05.03.16.01.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 16:01:56 -0700 (PDT) Date: Fri, 3 May 2024 16:01:53 -0700 From: Deepak Gupta To: "Edgecombe, Rick P" Cc: "olsajiri@gmail.com" , "songliubraving@fb.com" , "luto@kernel.org" , "mhiramat@kernel.org" , "andrii@kernel.org" , "linux-api@vger.kernel.org" , "john.fastabend@gmail.com" , "linux-kernel@vger.kernel.org" , "mingo@redhat.com" , "rostedt@goodmis.org" , "ast@kernel.org" , "tglx@linutronix.de" , "yhs@fb.com" , "oleg@redhat.com" , "linux-man@vger.kernel.org" , "daniel@iogearbox.net" , "peterz@infradead.org" , "linux-trace-kernel@vger.kernel.org" , "bp@alien8.de" , "bpf@vger.kernel.org" , "x86@kernel.org" , "broonie@kernel.org" Subject: Re: [PATCHv4 bpf-next 2/7] uprobe: Add uretprobe syscall to speed up return probe Message-ID: References: <20240502122313.1579719-1-jolsa@kernel.org> <20240502122313.1579719-3-jolsa@kernel.org> <20240503113453.GK40213@noisy.programming.kicks-ass.net> <725e2000dc56d55da4097cface4109c17fe5ad1a.camel@intel.com> <6c143c648e2eff6c4d4b5e4700d1a8fbcc0f8cbc.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; format=flowed Content-Disposition: inline In-Reply-To: <6c143c648e2eff6c4d4b5e4700d1a8fbcc0f8cbc.camel@intel.com> On Fri, May 03, 2024 at 07:38:18PM +0000, Edgecombe, Rick P wrote: >+Some more shadow stack folks from other archs. We are discussing how uretprobes >work with shadow stack. > >Context: >https://lore.kernel.org/lkml/ZjU4ganRF1Cbiug6@krava/ Thanks Rick. Yeah I didn't give enough attention to uprobes either. Although now that I think for RISC-V shadow stack, it shouldn't be an issue. On RISC-V return addresses don't get pushed as part of call instruction. There is a distinct instruction "shadow stack push of return address" in prolog. Similarly in epilog there is distinct instruction "shadow stack pop and check with link register". On RISC-V, uretprobe would install a uprobe on function start and when it's hit. It'll replace pt_regs->ra = trampoline_handler. As function will resume, trampoline addr will get pushed and popped. Although trampoline_handler would have to be enlightened to eventually return to original return site. > >On Fri, 2024-05-03 at 21:18 +0200, Jiri Olsa wrote: >> >> hack below seems to fix it for the current uprobe setup, >> we need similar fix for the uretprobe syscall trampoline setup > >It seems like a reasonable direction. > >Security-wise, applications cannot do this on themselves, or it is an otherwise >privileged thing right? > >