Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3499493pxb; Mon, 1 Mar 2021 11:31:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJzEkYxViqUnDZcLR/infUmv9T+DTEXoNqh8+KjNGTu0SjDii/oG0wkaH11B47bvaBtbfIk2 X-Received: by 2002:a17:906:77dc:: with SMTP id m28mr17618249ejn.5.1614627105130; Mon, 01 Mar 2021 11:31:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614627105; cv=none; d=google.com; s=arc-20160816; b=klihbm1PUuI4U/lQ3osp19rGesiMEhVyJSflVhQPiZiRNf+Yw4VyVTeQM6YABpZrza LugNgu6KmfOmHIFDYewyntiDPfVMWagi9qjIC2idnrJxxx07A7ONWxcDprpa57GSmbHE we3CPpmoA90MdouAOov1dgY42mpnA6Tv/YT+VTLgVBb1h/HIe3DYPoKBZ6Z3psScHPLQ Kp7UswGom8qv+MHGUuuaTDut5OTuQPfo0xlzVav7iBLOSJRRmiOYwBCGYiXpYy0dXDa/ rhjkrhLL3niKxYXESyky5GzFQoJD8mwsdIVM6vevOmRUbj6z4JQONn2ldUL/SeBfWj6n UdZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=UgPyarlr6W1bLi3oYMeukIfXXQreFYTHjI6/bdnuDIM=; b=XENH7+OC+iRsJnH4zrRi9kuMFH0tOr9/cPhwgISEAIp1kaMOq3acnpiTfkiF2tlHAO AI8p6yhtHYi3eGkatzKc5056M+A8quyc74xXjucaxbIrMDWdUkv0vIbfnvDN1jW+Ofvp mqjnhLWVTPsDXAlaD5ND+NpGuZYiN+F2vgOwLkyVR7aSUZUWl+ncgKEkcew9NPiflFjy 2KfUhCG3yrBoCMqG9DIHRXWwp6afpEp7D+wGv5pszz/EJ02SHCemZm7Ac2+YqeCgCuk/ dGh1Hjjz8T0OtuL1T9h5YdX3Vp1WX24nXoNMYsOLS2pGiWahRtLJRwHr6TkBmWqrJlbH aDXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Mcl6V6W+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lr6si6956873ejb.39.2021.03.01.11.31.21; Mon, 01 Mar 2021 11:31:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Mcl6V6W+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241802AbhCAT3Q (ORCPT + 99 others); Mon, 1 Mar 2021 14:29:16 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:50067 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235838AbhCAQxE (ORCPT ); Mon, 1 Mar 2021 11:53:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614617497; 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=UgPyarlr6W1bLi3oYMeukIfXXQreFYTHjI6/bdnuDIM=; b=Mcl6V6W+GBThtorJZ+TEzWAIETqTMxviQzJPPuG1Dff63vGL2uPao8Sv3zcCs3KQiMPiV8 i6cBvyOzXBKiqjgFlpLUrC4VcurctZIqf3Zjoh+UhLlmntODpwudGppn9x5e8r557Am9Do YvMfVc7mGZ4yR2Sy/ywMflCagxpAtCg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-364-p_Wd3qiHPP-YujrgL27ewA-1; Mon, 01 Mar 2021 11:51:36 -0500 X-MC-Unique: p_Wd3qiHPP-YujrgL27ewA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B2CE950742; Mon, 1 Mar 2021 16:51:34 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.40.192.81]) by smtp.corp.redhat.com (Postfix) with SMTP id A0B4D10013C1; Mon, 1 Mar 2021 16:51:32 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Mon, 1 Mar 2021 17:51:34 +0100 (CET) Date: Mon, 1 Mar 2021 17:51:31 +0100 From: Oleg Nesterov To: Andy Lutomirski Cc: Masami Hiramatsu , Peter Zijlstra , LKML , Anil S Keshavamurthy , "David S. Miller" , X86 ML , Andrew Cooper Subject: Re: Why do kprobes and uprobes singlestep? Message-ID: <20210301165130.GA5351@redhat.com> References: 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 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andy, sorry for delay. On 02/23, Andy Lutomirski wrote: > > A while back, I let myself be convinced that kprobes genuinely need to > single-step the kernel on occasion, and I decided that this sucked but > I could live with it. it would, however, be Really Really Nice (tm) > if we could have a rule that anyone running x86 Linux who single-steps > the kernel (e.g. kgdb and nothing else) gets to keep all the pieces > when the system falls apart around them. Specifically, if we don't > allow kernel single-stepping and if we suitably limit kernel > instruction breakpoints (the latter isn't actually a major problem), > then we don't really really need to use IRET to return to the kernel, > and that means we can avoid some massive NMI nastiness. Not sure I understand you correctly, I know almost nothing about low-level x86 magic. But I guess this has nothing to do with uprobes, they do not single-step in kernel mode, right? > Uprobes seem to single-step user code for no discernable reason. > (They want to trap after executing an out of line instruction, AFAICT. > Surely INT3 or even CALL after the out-of-line insn would work as well > or better.) Uprobes use single-step from the very beginning, probably because this is the most simple and "standard" way to implement xol. And please note that CALL/JMP/etc emulation was added much later to fix the problems with non-canonical addresses, and this emulation it still incomplete. Oleg.