Received: by 2002:ab2:7a09:0:b0:1f8:46dc:890e with SMTP id k9csp55189lqo; Wed, 15 May 2024 07:36:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUeFfiwjZqnQKTw9fJ1sUPoylu+xJzTI2n0pUmSxjAdYo69wAyZdGvaID1s9EkiLT8NVilSqFR+112EbSNYstENFAcDaqk3kjF4kW570Q== X-Google-Smtp-Source: AGHT+IEEtuThvbZ9CWkrrtdyvQSeHtSrsXEpVMxg1axhwzrn2L5eYfYB4fI8VMkbEG55KIrW+fvX X-Received: by 2002:a17:906:8315:b0:a5a:d6c:a30b with SMTP id a640c23a62f3a-a5a2d65f265mr1115585466b.58.1715783781885; Wed, 15 May 2024 07:36:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715783781; cv=pass; d=google.com; s=arc-20160816; b=jSA2hrd3pirGU/N9VZrONWp48WLveM+lX3ZWA3e3fxq6vC3yN1wbuHgPzQImQO+Woc eS5raEvGBKZtc7Pflb0LpPF0kHf0H+GI4w4DJWt/2TqmbrnVOB8iSMpttZfrNEMYvX/7 tTTCIaq8zkRkbst8fKJglF+Sj+BpdL6p3ibI75p1GsxSrcNj/LtJZ3x7z57KSskfQkkO Z+z4hLXDdj/dYinVL0b4lcyMdB1CE3geQZLn3RlZJkRclWIAPZTrK5bJr53M/0vv98cp Ly7HwuQMxCvfStXwEw5zfjjpf1ul4Mbb3NjxFaDXkqVUrwCg6+H3hQ/m6WmQT2HaKrRI tKeA== 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=fWssvw+tkze5cYj9060HrB4qYTJQkyrlcfUG/7N3/dU=; fh=qwckxsd3TDgAdiGBKOdyL64EIdF0DBVukkg8itt03Ag=; b=GIp1BGKf0bic9bb0e2Zn3z6NPl7Iuf/Ylmzwl4U9DsCqctWNhaipxkqXLDJSn7CU0I zBANzmfwoNdtfT0Q4YVbGvancz3wxgE2sX/4fl5nCeofHQvhvb9tx60bxgXiM+Mqil2x omIMfpoU0cBgqUJJPql33e1nlnHJMcQEIGlEpc1j5PGXNbCNs/gM8g6zfEEL0JhmG+9u MBff1j1PPqVf1YN+qX15o+dgrHK/3TfmmoIkEoKDV7uzhBV8hMdD7k4cF1u9JZueoL42 5uYyN5wTaQ4JOCj387+SqLLHuPDRu3wVPCDbcithOzdy7DBx/jyIEMUB7230XWWBZDQL TuaQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=RAJGhgAy; 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-180016-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180016-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. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a1797bf61si740335866b.254.2024.05.15.07.36.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 07:36:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-180016-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=RAJGhgAy; 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-180016-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180016-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 7BFE21F2185F for ; Wed, 15 May 2024 14:36:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E73CA15573B; Wed, 15 May 2024 14:36:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RAJGhgAy" Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (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 A98FE145B1B; Wed, 15 May 2024 14:36:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715783770; cv=none; b=IoDtnFmLERHiqZJAlfNcAPpseGWwyKp2guf/W6IxaWp/SgINmf0ASNFKJ0npN1i/fWugcg1R++e+E97AFx3FnG7vyH4BkHEN5mEQOcMrAtVcis/8pW+1v75wemnl7Negd4s7p/rJd8HT/2wIAlnJ2P0HsglfkgTBR3LSConWn+U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715783770; c=relaxed/simple; bh=v0/BK2yo6D0HmXUHcm3GIq3kIfESRAEZE0OJMyRY6yk=; h=From:Date:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=mZZBhYPLmwr54JcITy2KeTngnqMzNGRIH5v+5mQP7CbRdo79r7sb7YQLWeXtZ5sLmXYbHlvZufBw+mSTjlGoTkJrwohP2qaLiCGpfg7uZDZCcSm1rMxjRpbK2/DoU70Panako5M3eUIEW6nEH3aSk+PpmZzZeZID7BYHGMiMbgI= 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=RAJGhgAy; arc=none smtp.client-ip=209.85.214.177 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-pl1-f177.google.com with SMTP id d9443c01a7336-1f08442b7bcso17627165ad.1; Wed, 15 May 2024 07:36:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715783768; x=1716388568; 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=fWssvw+tkze5cYj9060HrB4qYTJQkyrlcfUG/7N3/dU=; b=RAJGhgAyrQtrO6bqQEVCU5RRsevmr5wewnUfzz/djq9SR4A9hr7Hqwq1QLymg3OCpo x6TTbmPy96UNPm57YBw3KSk6akpkjCfD7CinIY94lGr2c5rao8bECQPDu/ORKFR3/S1k jYc1LawGRoztPKKMkLtu6FYmBxt9EWls/J7erHIwHu79RLa4q0f1aKaduVCKFj1WjhBb AwS3tdruPhTygnwBIi06vcD8ziMSmXvoVfylB3dN+gLG7Ba55/+3FqqjOPMAsYxriipp hC/NNFvnkfUon4qqyj9ZqemCHEJO1RkexErnJvVqO2sn8kcrzX2zsDk8xW50nrFBNoxo lRDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715783768; x=1716388568; 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=fWssvw+tkze5cYj9060HrB4qYTJQkyrlcfUG/7N3/dU=; b=TBQTgECfGGZShCtzwK8c9v55rrqfZYRLN/kz7+jRkt+wlso6lb8jN2qnVj8kxPLWW0 fO0q5hQtXroeY73toyNg/b+Grb1fHrKaM7PZO82Nv3tiTJ/h5LOxLkZkZA5Uh83l5g3Z 4YenL945MUuT8rpxlWVplJ4oPt8bnMm8qWs1Zgflzo38DmMh4JDDmbVZL8Y52LPDiOjy o2YEd4/0BqzT7U8KTq2YG1Hzi/f20DpeZPVflx6T8CwpKMFEXiof6HWvux66cTwRGzA1 d3GB5LFAibMbPKgav3jJZS2vw8Po1mioUU+xtg1gva9V59XBv6nnsgD0ffMD4YaToakJ SiOw== X-Forwarded-Encrypted: i=1; AJvYcCVoXatuy+UEn2Af9JoTSqkhwJoVlhl8bZZRDU6Z+AvFGHANLzn9piTqRRvs6BpO+tcWN37rfUmwVWKI0LP70Hw6eH/qgdJ1xeMMEHuuO+lM5qGOuljDVisaA1oo7oat+wAqN7F/4XJc9V5fFHZq702VWUhPgAGf2K6YeEDQRuQ5GxKeucl5i5RM4xExliK3YuB14RugEdSV6TpeajC4uie1NKUzeJsmFBT9QMeUy+gZnsxCcWs+Jfq2GZEG X-Gm-Message-State: AOJu0YysNdfebqgO3GvpX9K9e5zQrfOyXybkaYT/03RaOjKIteWymfFo GcaoX2EVEtbgdglpGG0E2g7ryV1SSFp3gUhujSftNfABuAOwVCHA X-Received: by 2002:a17:903:228d:b0:1e5:a3b2:3dad with SMTP id d9443c01a7336-1ef43f51f2cmr209886835ad.42.1715783767774; Wed, 15 May 2024 07:36:07 -0700 (PDT) Received: from krava ([76.8.218.154]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0bf30fc7sm118608255ad.133.2024.05.15.07.36.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 07:36:07 -0700 (PDT) From: Jiri Olsa X-Google-Original-From: Jiri Olsa Date: Wed, 15 May 2024 08:36:03 -0600 To: Oleg Nesterov Cc: Deepak Gupta , "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: References: <20240513185040.416d62bc4a71e79367c1cd9c@kernel.org> <3e15152888d543d2ee4e5a1d75298c80aa946659.camel@intel.com> <20240515111919.GA6821@redhat.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: <20240515111919.GA6821@redhat.com> On Wed, May 15, 2024 at 01:19:20PM +0200, Oleg Nesterov wrote: > 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? I think it will crash, there's explanation in the comment in tools/testing/selftests/x86/test_shadow_stack.c test that's why ARCH_PRCTL is using syscall instruction directly and not calling syscall function jirka > 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. >