Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1822200lqe; Tue, 9 Apr 2024 00:58:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWjZSa71xj8ZeJ2fIRcbnA1a1EafV19APdrePpA3L0SKmijA+ex2IJVaiXSeVKMAYpUCEntAQtGK5w9KXB+qBHwSG3GC/PM0CUET4Palw== X-Google-Smtp-Source: AGHT+IHs7OxYAFwhVFx26mQAf1bT7Bg2hvb4wWNx/Ych2SKKSLLPyXPno5q2l7EjzwehKZ29MV6q X-Received: by 2002:a50:c30c:0:b0:56d:c295:dde3 with SMTP id a12-20020a50c30c000000b0056dc295dde3mr9480374edb.35.1712649500923; Tue, 09 Apr 2024 00:58:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712649500; cv=pass; d=google.com; s=arc-20160816; b=c7aswIS7xUW1lxQSnHKqAYW+Yj1RSBEZMG0GFc1qvEnmmbWsLzj9G6XBaqlReBIC1P UIEoLQXu6Tk5oba2S/D8sq9IiyIj9UBpYpTSIHzyKp5Xtl1y+5bkBYL/mDf1w011aw6P UW6nDyqp9e5ZxDNnpmkf/Hg09FPlswN3Hnz50B5TCacodDE/mtYfObJy4HrcmTFTO9ZM bVFtWvYFszxvHNMRBth8jsdTpAEb3v/OS6/762LkBYg2jmeCxJC3X2OV0BtBT+FyOUx7 NT1o9Ran3OsyP62AxWz9ZZsEKv7Qq+lV9iR33arJlYr+vBJ0gdiGHTs0icMuEqZ/WS9O uoIw== 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:date:from:dkim-signature; bh=A9YXgPNf4gqlB56sgUucCnlcjmHfsJoKI/6vQ+DJBgs=; fh=5Hvos+pLfeIZ2pWVSr0FLzyEA865eyn/CcaZU/48+EY=; b=elFswvpX/a2bH0NcSy5+8PLETMIEd5AbdrAOJSAgFniMlUBNFOtYAdotkARQxeKabn Su5MzBUXgdcLi3g+bCG5Cftn8GiNCg0noSsTNrzZBXYKRHzot87uRmnueVFyc8d/KtIF Qv77luEC9WRIAtZFun2ENhCOLmIqlxub96nML89PKmHJ8QwMVhbbEQOcRymVkrLHAmj8 4+9EHPfjSNQqKVmcC+AJIDF+jSyd3Hr3QrLzWi/KCsi+sX4bVrV0Lk24xGrMAiqjkVnk GnP/nv4ktOSkb9V7Q6wh1SLldWYcB9rb81Fr0mh+u1kk60MHMPVtsC48UodSHDa2znLL /jdw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=cgfalYQU; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-136398-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136398-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id q23-20020a50aa97000000b0056e2c9b694dsi4380782edc.109.2024.04.09.00.58.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 00:58:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-136398-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=@gmail.com header.s=20230601 header.b=cgfalYQU; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-136398-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136398-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 0C31B1F22D95 for ; Tue, 9 Apr 2024 07:58:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 013D57E0F3; Tue, 9 Apr 2024 07:58:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cgfalYQU" Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (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 596F77D09F; Tue, 9 Apr 2024 07:57:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712649480; cv=none; b=qRpjrwbdVrEumEpvY2TBW62uOebCC3rCfiA367qToETq4qyyla56e6vzuKkVX08tkm0KtPH36AhKDsJPGMdjuvSUDGk4EAi7540jITqogw+OVeehhFhRZWexwmKrb3lVMwD1eW+iYFckW86A7UZgsbiVuy6QGQiE8no9FmxDWbY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712649480; c=relaxed/simple; bh=+96kTkCYzibKfYMPaLZoRN4b2dBphMs9/4tzob3I6KM=; h=From:Date:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=TyKFBZiy1s/8I89CzrkDiSQvO6mc6vKMxfUJNlKJE6eKb42r47JPZdsJUvXbTmOyhc5y20+C0p2Yq68ZT6tCc8sH7aCfkrmAj+f7wgNDTRGLne3Xmr6+x5Gu25WvZ0DcISTv3gf3v6e3/DFG6PhUt603TopVgqmPLCPGNOtthcE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cgfalYQU; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-4155819f710so41360385e9.2; Tue, 09 Apr 2024 00:57:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712649477; x=1713254277; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:from:to:cc:subject:date:message-id:reply-to; bh=A9YXgPNf4gqlB56sgUucCnlcjmHfsJoKI/6vQ+DJBgs=; b=cgfalYQU5jiklB12MFso7LgZ48CDHni5bJNH0gm/bkzMZkFD42R3i1cBnzwWKdMk/X RcJgbskjwHR2BvhRtCoULqXSOjskzBy+gto8dAxqNhv4T/WKTbVGVNZ7iR7907MazEIa 3R4UgroyfgKIRNYCJUnui5Um6WFMirREltu72ywCChYh4vo92NYRF7Zwrlz5uM9bya3G Pr+1jpPEnTKCx+jyjpqWViMs/urrjUZAszvy7NMxbvl5a+GDR8xddwiES6TTEtmLbKc1 eBSzpEsfjcPpZQM6nLaVykVuQfSKS+88yQFowSSczLG5HSS8TywkP2tEtcsPDUfd3Noq V3jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712649477; x=1713254277; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=A9YXgPNf4gqlB56sgUucCnlcjmHfsJoKI/6vQ+DJBgs=; b=gs+mELdQTZZGjM+1pfe0yiESxp8Fqa+XG/Vc7o80MmuKmn3A1Cu7QqQRLARcX+FzDp ZwQ6cG+103SYxxeB799wedHF0AfG05+xb3KpFHvk4pcWxo/MOnwySPZ1m/VcK5Jf+v8j oJDchrYQpKW1EI6UQMn8g8SENPn3CQHEMtWSSp0hajYVz2LUGbfbbKNLHDCZ21YmtVan INLyca8McfsJfxeH4quYWIqIOON7dPd4dd0oOVZWcYNqfVbththCKbecWJ7tiBIR82DK BgB3rNrXX5O1VRqns7IQEl/fjfA/MK2iAWZ8iyuXbwEYyfkNZMqCzN4c2IR2i2rBVAx7 mV9Q== X-Forwarded-Encrypted: i=1; AJvYcCWcX+GgfxFLr8h9LXRC5Ihyzole7M7hVeIOWpGkPKYIGKAmAACx96IY9tSYkRRoFPDUiSzFS8DsWvhB3BsnocSExj8VdTdj96KKc39zt4hHgoxo8EQSo/zNDZtELJ7aok6EtZv6bo9swV60Ik0jm2X2GphW0ZOnrZFmj7EHrG0R6X7gzTKUi5TVU/B1UilY9bBirLO0hb8pMAoAbuADNatQ X-Gm-Message-State: AOJu0YwL8a5ae+taiZDxKD9wZs+79suTuUT9HuxVryr3Slobtb3t8muG UyHV5SA7Gs+WKoSI+RuyePE1h+nrmqqSosiNoPS11SpD5oKLbiiA X-Received: by 2002:a05:600c:4708:b0:414:95e0:388c with SMTP id v8-20020a05600c470800b0041495e0388cmr8811472wmo.8.1712649476445; Tue, 09 Apr 2024 00:57:56 -0700 (PDT) Received: from krava ([81.6.34.132]) by smtp.gmail.com with ESMTPSA id n11-20020a05600c3b8b00b00416aca5ff66sm970839wms.19.2024.04.09.00.57.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 00:57:56 -0700 (PDT) From: Jiri Olsa X-Google-Original-From: Jiri Olsa Date: Tue, 9 Apr 2024 09:57:54 +0200 To: Masami Hiramatsu Cc: Jiri Olsa , Oleg Nesterov , Andrii Nakryiko , Steven Rostedt , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org, Song Liu , Yonghong Song , John Fastabend , Peter Zijlstra , Thomas Gleixner , "Borislav Petkov (AMD)" , x86@kernel.org, linux-api@vger.kernel.org Subject: Re: [PATCHv2 1/3] uprobe: Add uretprobe syscall to speed up return probe Message-ID: References: <20240404095829.ec5db177f29cd29e849169fa@kernel.org> <20240405005405.9bcbe5072d2f32967501edb3@kernel.org> <20240404161108.GG7153@redhat.com> <20240405102203.825c4a2e9d1c2be5b2bffe96@kernel.org> <20240405110230.GA22839@redhat.com> <20240409093439.3906e3783ab1f5280146934e@kernel.org> 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: <20240409093439.3906e3783ab1f5280146934e@kernel.org> On Tue, Apr 09, 2024 at 09:34:39AM +0900, Masami Hiramatsu wrote: SNIP > > > > > > > this can be fixed by checking the syscall is called from the trampoline > > > > and prevent handle_trampoline call if it's not > > > > > > Yes, but I still do not think this makes a lot of sense. But I won't argue. > > > > > > And what should sys_uretprobe() do if it is not called from the trampoline? > > > I'd prefer force_sig(SIGILL) to punish the abuser ;) OK, OK, EINVAL. > > > > so the similar behaviour with int3 ends up with immediate SIGTRAP > > and not invoking pending uretprobe consumers, like: > > > > - setup uretprobe for foo > > - foo() { > > executes int 3 -> sends SIGTRAP > > } > > > > because the int3 handler checks if it got executed from the uretprobe's > > trampoline.. if not it treats that int3 as regular trap > > Yeah, that is consistent behavior. Sounds good to me. > > > > > while for uretprobe syscall we have at the moment following behaviour: > > > > - setup uretprobe for foo > > - foo() { > > uretprobe_syscall -> executes foo's uretprobe consumers > > } > > - at some point we get to the 'ret' instruction that jump into uretprobe > > trampoline and the uretprobe_syscall won't find pending uretprobe and > > will send SIGILL > > > > > > so I think we should mimic int3 behaviour and: > > > > - setup uretprobe for foo > > - foo() { > > uretprobe_syscall -> check if we got executed from uretprobe's > > trampoline and send SIGILL if that's not the case > > OK, this looks good to me. > > > > > I think it's better to have the offending process killed right away, > > rather than having more undefined behaviour, waiting for final 'ret' > > instruction that jumps to uretprobe trampoline and causes SIGILL > > > > > > > > I agree very much with Andrii, > > > > > > sigreturn() exists only to allow the implementation of signal handlers. It should never be > > > called directly. Details of the arguments (if any) passed to sigreturn() vary depending on > > > the architecture. > > > > > > this is how sys_uretprobe() should be treated/documented. > > > > yes, will include man page patch in new version > > And please follow Documentation/process/adding-syscalls.rst in new version, > then we can avoid repeating the same discussion :-) yep, will do thanks, jirka