Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3002632imu; Wed, 7 Nov 2018 03:23:45 -0800 (PST) X-Google-Smtp-Source: AJdET5fE43rtvlxI9MtQX6WiVJPcLXBoArgnoUwyGRkWMoQ5xaMj8SU9drXNC9wKt3RZAc22B7F8 X-Received: by 2002:a62:15c7:: with SMTP id 190-v6mr1397471pfv.213.1541589825473; Wed, 07 Nov 2018 03:23:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541589825; cv=none; d=google.com; s=arc-20160816; b=cBgsRgW81zc45PGAfflsCT6xbRPyUhn+3VxDP0PUwJnqrRMWExKpHUTg6PHPxhSlAD q4wtuxCi0ZedcnzbTHbkMZW7CCt7xEZxsI9oUpqQ9POce+clgSyENWi/NmWGHjojExvc UpAkm9bZqBRdRxa7S9ZnKAI88CqTvJ9PI1Jvxyq02jSS7eK/RbiLKmPhttyMqUg6TB1L AhwlZjrfil21R8qZs8hm7w9gY/Ttl42QeavrrewvFVl0OEk1MjdZSwTM9ueNzJbftugD zKR3CF5vnL6OvlEbnGEmCpWcf5NY+naoyDAtIbfhQ9burifAB+9A9sPc5OLyO5MbrEbU rFpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=t6/07WNxVB8JZpdVfh88B1RRR45lWdXAT4YEcKb77JQ=; b=VB2OKlN2A0GvQe5l6+QT9zngegBgcTYBsIFJhdcJuAMUK96dj/2nQb3ciUBKxqMp8F 2T8SWGodoOCgOKbXgIHKFwOKb7ft4yoFVoyzzLszqYxCwni+hR5P3T1lMqyFKTZ9OTeL cMDkCSQ4L3ztVN0XKf7R0PKslQcwafosWR4aVE3tUF2wALlUPwZ0Q3z/FVKtHPSjBR6w vUgXgtDO6Ow9BdSytxUkMKdWDRuI32KzS9psE0EHpfHGDoN4Df7yKhYsjKm9ryQjWMF2 r98CjjGJxJx87L1RJVYRnnvbRGYZES93xZX5di4nKEGDuO0UCcPG8B4nDmSnF4RDh6tf sylQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v13si306669pgn.355.2018.11.07.03.23.30; Wed, 07 Nov 2018 03:23:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730906AbeKGUvD (ORCPT + 99 others); Wed, 7 Nov 2018 15:51:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51168 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726225AbeKGUvD (ORCPT ); Wed, 7 Nov 2018 15:51:03 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 989702D7E8; Wed, 7 Nov 2018 11:21:07 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.43.17.31]) by smtp.corp.redhat.com (Postfix) with SMTP id D1F075D75C; Wed, 7 Nov 2018 11:21:01 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Wed, 7 Nov 2018 12:21:07 +0100 (CET) Date: Wed, 7 Nov 2018 12:21:01 +0100 From: Oleg Nesterov To: Elvira Khabirova Cc: rostedt@goodmis.org, mingo@redhat.com, linux-kernel@vger.kernel.org, ldv@altlinux.org, esyr@redhat.com, luto@kernel.org, strace-devel@lists.strace.io Subject: Re: [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request Message-ID: <20181107112100.GA20419@redhat.com> References: <20181107042751.3b519062@akathisia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181107042751.3b519062@akathisia> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 07 Nov 2018 11:21:08 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/07, Elvira Khabirova wrote: > > In short, if a 64-bit task performs a syscall through int 0x80, its tracer > has no reliable means to find out that the syscall was, in fact, > a compat syscall, and misidentifies it. > * Syscall-enter-stop and syscall-exit-stop look the same for the tracer. Yes, this was discussed many times... So perhaps it makes sense to encode compat/is_enter in ->ptrace_message, debugger can use PTRACE_GETEVENTMSG to get this info. > Secondly, ptracers also have to support a lot of arch-specific code for > obtaining information about the tracee. For some architectures, this > requires a ptrace(PTRACE_PEEKUSER, ...) invocation for every syscall > argument and return value. I am not sure about this change... I won't really argue, but imo this needs a separate patch. > +#define PT_IN_SYSCALL_STOP 0x00000004 /* task is in a syscall-stop */ ... > -static inline int ptrace_report_syscall(struct pt_regs *regs) > +static inline int ptrace_report_syscall(struct pt_regs *regs, > + unsigned long message) > { > int ptrace = current->ptrace; > > if (!(ptrace & PT_PTRACED)) > return 0; > + current->ptrace |= PT_IN_SYSCALL_STOP; > > + current->ptrace_message = message; > ptrace_notify(SIGTRAP | ((ptrace & PT_TRACESYSGOOD) ? 0x80 : 0)); > > /* > @@ -76,6 +79,7 @@ static inline int ptrace_report_syscall(struct pt_regs *regs) > current->exit_code = 0; > } > > + current->ptrace &= ~PT_IN_SYSCALL_STOP; > return fatal_signal_pending(current); ... > + case PTRACE_GET_SYSCALL_INFO: > + if (child->ptrace & PT_IN_SYSCALL_STOP) > + ret = ptrace_get_syscall(child, datavp); > + break; Why? If debugger uses PTRACE_O_TRACESYSGOOD it can know if the tracee reported syscall entry/exit or not. PTRACE_GET_SYSCALL_INFO is pointless if not, but nothing bad can happen. Oleg.