Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp3034820lqo; Tue, 14 May 2024 18:44:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWB2oJ40cZ0Ybr+X9F9812Kv6luQZIJTVmUckvgoFACwc8Aapk99R7WRmQ9u4YSzh0SCnpDV8WEOdxSWoBZK0FS1NsTun2/GoASDpNJgg== X-Google-Smtp-Source: AGHT+IHxNikiLmAO3+F+otXku4hKTuyifCp4ptXT/i34wznAzN1h8tUhZqLrIssA4Jzvs/zSK8mr X-Received: by 2002:a17:90a:e98c:b0:2b1:1c1e:f489 with SMTP id 98e67ed59e1d1-2b6cc1442fcmr11470346a91.4.1715737491350; Tue, 14 May 2024 18:44:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715737491; cv=pass; d=google.com; s=arc-20160816; b=mBhsL3lqtgYIG2auZwnrt0fMkGbqh/HxvLkhfWHoX9UbUw3D1wy+gZbmpDl0jG5hod IeHrQJTn5e3OuFItaxYyx9yaWlPMqGCNf29Vvgiq+CTVBupomLbCsws6sm8I4BbAPExD SWxZaSNrNjbQkLtRsO6J7nfyaMnPQBI13Acl0LP6gBWASBWfxddMj+L8fiQW2tiejoya dFS0T9BWZ07JRSss71Q+F347Rop7kt3fc5cJRghU4iScfjINabkKG9mTbDJPtg+lss3Q Rly1Yxqy6LW0a4gIYjOKi6p9ZCtuRcbq23FoYfAiFNIXaPQ6K6/9i5tqJ6/2OhNOGx35 TIlA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=qo/v4eXzdi6YHioqLixe5DcUJ4f/UL2pWmemFFHuCb4=; fh=nWbZ6UKiu3aNmrZBUJDZIXDZ827nzKCcz9XpCPxWED8=; b=bfcH72Cx0OgjLxKsUuwBvC6pfggv1iy/4Bswsa/eSY0ER/JKfmcW9T7y0z95jjNAc6 /L7Hv5PQ+nrnQfqWmabWvo3E6arQBK4+K3WTNdVF3hvS6H+K5Sl4zsAiJ7F9FSw6vanY 689ordwHufgfISZq7e38jlYH5A9pOlR5IHxfeHprbQc2v5qTOGweU2hW7tjR5X8lDACY Gmc4u9XWDwaBniNQ0kLY/lUaJl27ir7EIA0wcRGWTO3X0WjsBVI1O9G//hGuUW01FmCu Ec0V8lpgxQCjlQF9w5xHpIIeuwLfzCjPXZ8cxAHbeQPSMug61vzloHg+y2rpgwEipHcP 8dmw==; 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=aLO7PNM0; 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-179328-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179328-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2b6290d0403si13988417a91.170.2024.05.14.18.44.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 18:44:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179328-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=aLO7PNM0; 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-179328-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179328-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id C3D96B21356 for ; Wed, 15 May 2024 01:44:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E360163CB; Wed, 15 May 2024 01:44:39 +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="aLO7PNM0" Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (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 A2FBDBA4B for ; Wed, 15 May 2024 01:44:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715737479; cv=none; b=BJpiMR4NS4ZcNedtaq/LHSwDrXAw+MDbgqcEcSm6gPny+cy2WVM8e08p7PITuU26G3S432kCb9bGun1XhqmYd2WVJ7O6vvzSI6+fe0CNuY4GOYpIuo/CWWrnqfDB4JVuzEpZJoX/q26UnXq3hJPWjGlj05f0lIyqwKADscC9Hz4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715737479; c=relaxed/simple; bh=utrhsUe7+CsXJr0wIMC6o0BnlW4BggIXELMhPPq0LLY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=NM4yuzAqqrGO/TMD6MnuvyJGFHobCLg5yO0ATCbiAhERaMr32nCALwuDqrSnXvf4OeNT/HvHXyleD4okiEAlr8rJR2GdUseKXLl4tnweWkUh9ifLLmtwRkKUqu/rn+nz5PzRGygjj0SJaG5VE/mNvhDLHtj/TjzB8UzSj14dnAk= 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=aLO7PNM0; arc=none smtp.client-ip=209.85.210.174 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-pf1-f174.google.com with SMTP id d2e1a72fcca58-6f44e3fd382so5249425b3a.1 for ; Tue, 14 May 2024 18:44:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1715737477; x=1716342277; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=qo/v4eXzdi6YHioqLixe5DcUJ4f/UL2pWmemFFHuCb4=; b=aLO7PNM0dUV2nFR3uNW7VBuUROhMzuknk95TAq+VncPVvq/8XGJREw03E/f7db/T7P 56TlB3Y+EGMHqsw4i6PxJd2oJbmp3tufIJwWylFjTESpM6nssCbCe2AUrJ3mpZ+yV/NX N9naksMPBnPJ1NzvWgOFG1s0h9vjjWE6IbdAm8HcnaCnB6/UzZe6huAKXDMXIe3jbRqy /dRy+gmrTNNhM3JOYLjGSKz+93l7oovuD6dSDlB2Obx3tJTrf8mtA4/2Ar1M9qR4NlIU LYRQrhyGomg8fkgEIUixYtYbj+c+Pvct6Td4XtuUUHhF/blPWTtgqAzfSgfD6ErKZ5+z CYIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715737477; x=1716342277; h=in-reply-to:content-transfer-encoding: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=qo/v4eXzdi6YHioqLixe5DcUJ4f/UL2pWmemFFHuCb4=; b=Zd2q1DZgxD0sxnzRXmxFrJo4IIu8oaHynnyfB+fx0YxfSuz2J+U8Wj+R5p8gS76wV5 mZjTGTn6HKfFu6jE3rsVcM/oHXFvJK67NM9tniTzDfAtu0R3H8JZnLRYMRx+5q5tM9Hc vMWQrvw/8lNgtfkcwZiJeIbOqhZp9oJN1kWldO4DIqNigxpzzZs5cGRI3KJ2MZgovFe/ Dnfpyqz8sBbC+RqPvH0mj3qib8ydzTzin1sxWlvvBIm39TbLXeazMevLWmhSwPN0/RUW hL8EPHxNf26MQM97ak+XI4zqWPf5g4Ilvw9OfW8I4gLR9uq5euWmqsb4q7098N9katoW 5PRg== X-Forwarded-Encrypted: i=1; AJvYcCUqr2FZtSfsIuF/Bo9qTjxkhMr/oA2KN9IActa0zi7FR6tLRt5AgK7eHFMOC4fRYRIHDn9zucFsPi7SgEzr4O1Jl6bxpvUAVBkK5X9w X-Gm-Message-State: AOJu0YyuzwRaLux74C7O2eJDjZ9TzFs6FdjDhzQhWUm0Z2JSFJtauchG wINbIjPlQna5QEElqcPz5REcpWgSQIXwbqt83MqOiHyRpRh/Yn93W5m7qBQBxIQ= X-Received: by 2002:a05:6a00:1493:b0:6ea:df6a:39e7 with SMTP id d2e1a72fcca58-6f4e02adb85mr16427939b3a.13.1715737476914; Tue, 14 May 2024 18:44:36 -0700 (PDT) Received: from debug.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-634103f6e2dsm8832789a12.61.2024.05.14.18.44.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 18:44:36 -0700 (PDT) Date: Tue, 14 May 2024 18:44:33 -0700 From: Deepak Gupta To: "Edgecombe, Rick P" Cc: "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" , "oleg@redhat.com" , "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: References: <20240507105321.71524-1-jolsa@kernel.org> <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=iso-8859-1; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3e15152888d543d2ee4e5a1d75298c80aa946659.camel@intel.com> On Wed, May 15, 2024 at 01:10:03AM +0000, Edgecombe, Rick P wrote: >On Mon, 2024-05-13 at 15:23 -0600, Jiri Olsa wrote: >> so at the moment the patch 6 changes shadow stack for >> >> 1) current uretprobe which are not working at the moment and we change >> ?? the top value of shadow stack with shstk_push_frame >> 2) optimized uretprobe which needs to push new frame on shadow stack >> ?? with shstk_update_last_frame >> >> I think we should do 1) and have current uretprobe working with shadow >> stack, which is broken at the moment >> >> I'm ok with not using optimized uretprobe when shadow stack is detected >> as enabled and we go with current uretprobe in that case >> >> would this work for you? > >Sorry for the delay. It seems reasonable to me due to 1 being at a fixed address >where 2 was arbitrary address. But Peterz might have felt the opposite earlier. >Not sure. > >I'd also love to get some second opinions from broonie (arm shadow stack) and >Deepak (riscv shadow stack). > >Deepak, even if riscv has a special instruction that pushes to the shadow stack, >will it be ok if there is a callable operation that does the same thing? Like, >aren't you relying on endbranches or the compiler or something such that >arbitrary data can't be pushed via that instruction? Instruction is `sspush x1/ra`. It pushes contents of register return address (ra also called x1) onto shadow stack. `ra` is like arm's equivalent of link register. Prologue of function is supposed to have `sspush x1` to save it away. ISA doesn't allow encodings with register in risc-v GPRs (except register x5 because some embedded riscv space toolchains have used x5 as ra too). On question of callable operation, I think still need to fully understand who manages the probe and forward progress. Question, Is it kernel who is maintaining all return probes, meaning original return addresses are saved in kernel data structures on per task basis. Once uretprobe did its job then its kernel who is ensuring return to original return address ? > >BTW Jiri, thanks for considering shadow stack in your work.