Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp465693imu; Tue, 27 Nov 2018 15:28:50 -0800 (PST) X-Google-Smtp-Source: AFSGD/XdzNYw0E4HlwidMwnMsQmTdaXoIxixrgOHhwBbI/S8ECT+GsoM80gciE2/2xfiiEycFBJm X-Received: by 2002:a65:484c:: with SMTP id i12mr31027566pgs.309.1543361330553; Tue, 27 Nov 2018 15:28:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543361330; cv=none; d=google.com; s=arc-20160816; b=AdSDah62LxwRXpan1AklBd3XsovU6Id6Xo5tzYEIFcCWTkCFhxr7vwOTkoe/3/VIJC rWKbwC2CF2qmMGZ79tONn7kyVwXFKvdmoSkXIbBTNkkpRAMb9oO+zSvRiR7O26mnOvyk o2N6ZUinkc+6t+xHw+kGten/PMu/yPl51nB4lS+8X/G616N7kC7KwpN2N0TqhPBUZcDw dSlQuckL9U1c9YDgJahDe2Yib3qYWpRlBTt2+5ceivA1LiSGfj92nrEPeK3WELbdS2Tt oroZthKpThXmrkwJPwoHRarpI6wCf1FptUlGuX7xYWkqkTtvZmwqb61OgImoempjZrwT EfDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=ilV6PM5t2ih/wcnXXYoMHcDa1IR9FA8ihsG+ZOVkWWI=; b=J7vZ3fmlWLfkEolddRehJNDaIUISIbgJb9iCXuUzDm28BpxXJunEJQVbXjqtuIQXeo NKi4OryOs0mwdrpBBmFUyzbyOpqvhwd6MwF1sL2EBDmpcWf3WKGb53CcaFmbnQ86gSpO UKC3JwzPpD6F5XiBXm8lD9Pr6Ll4lzPQKo8l/LoS5ehSO5L7XqEjDRMDOu+ihGHJdxrh Oh6Gg7k4sc58hhx3AZyZdqZ5oky1to5cWNGsTeNG3xen3YzGHeoEb+ZM2/7OkwUBlY96 3eK63njOYvhaYc7oLkZhiWe11OwiMC9CVVGHf+hEtShkn06umqSY3WPSfVJNuJQKWppE Refg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l184si4768112pgd.523.2018.11.27.15.28.35; Tue, 27 Nov 2018 15:28:50 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726628AbeK1K11 (ORCPT + 99 others); Wed, 28 Nov 2018 05:27:27 -0500 Received: from vmicros1.altlinux.org ([194.107.17.57]:35212 "EHLO vmicros1.altlinux.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726286AbeK1K11 (ORCPT ); Wed, 28 Nov 2018 05:27:27 -0500 Received: from mua.local.altlinux.org (mua.local.altlinux.org [192.168.1.14]) by vmicros1.altlinux.org (Postfix) with ESMTP id 6507B72CC59; Wed, 28 Nov 2018 02:27:53 +0300 (MSK) Received: by mua.local.altlinux.org (Postfix, from userid 508) id 50F697CD0D7; Wed, 28 Nov 2018 02:27:53 +0300 (MSK) Date: Wed, 28 Nov 2018 02:27:53 +0300 From: "Dmitry V. Levin" To: Oleg Nesterov Cc: Elvira Khabirova , Steven Rostedt , Ingo Molnar , Eugene Syromyatnikov , Andy Lutomirski , strace-devel@lists.strace.io, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH RESEND v3 3/3] ptrace: add PTRACE_EVENT_SECCOMP support to PTRACE_GET_SYSCALL_INFO Message-ID: <20181127232753.GA18755@altlinux.org> References: <20181125022150.46258a20@akathisia> <20181125022340.5703400f@akathisia> <20181126143524.GB1660@redhat.com> <20181127040732.1c9f7965@akathisia> <20181127123116.GA13284@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="M9NhX3UHpAaciwkO" Content-Disposition: inline In-Reply-To: <20181127123116.GA13284@redhat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --M9NhX3UHpAaciwkO Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Nov 27, 2018 at 01:31:17PM +0100, Oleg Nesterov wrote: > On 11/27, Elvira Khabirova wrote: > > On Mon, 26 Nov 2018 15:35:24 +0100, Oleg Nesterov wrote: > > > On 11/25, Elvira Khabirova wrote: > > > > > > > > Extend PTRACE_GET_SYSCALL_INFO to support PTRACE_EVENT_SECCOMP stop= s. > > > > The information returned is the same as for syscall-enter-stops. > > > > > > Oh, this is not nice ;) there must be a better option, I hope... Plus > > > > > > > > > Can't ptrace_get_syscall() check > > > > > > child->exit_code =3D=3D (PTRACE_EVENT_SECCOMP << 8) | SIGTRAP; > > > > > > to detect the PTRACE_EVENT_SECCOMP case? > > > > Nope; looks like exit_code is zeroed after wait(). >=20 > Yes, thanks for correcting me, >=20 > but we can use child->last_siginfo->si_code. Yes, this approach works, thanks! > Just like ptrace_request(PTRACE_LISTEN) > does but you can do this lockless (no need to lock_task_sighand()). Why this can be done lockless? All other places in that file do the locking, so I'd rather add a comment in the new code. > And if we require that the user of ptrace_get_syscall() should also use T= RACESYSGOOD > then ptrace_get_syscall() can probably do something like >=20 > int entry; >=20 > if (!child->last_siginfo) > return -EINVAL; > else if (child->last_siginfo->si_code =3D=3D (PTRACE_EVENT_SECCOMP << 8)= | SIGTRAP) > entry =3D 1; > else if (child->last_siginfo->si_code =3D=3D SIGTRAP | 0x80) > entry =3D child->ptrace_message =3D=3D PTRACE_EVENTMSG_SYSCALL_ENTRY; > else > return -EINVAL; >=20 > and this way PTRACE_EVENTMSG_SYSCALL_ENTRY/EXIT can't confict with seccom= p or > anything else. >=20 > No? >=20 > Of course, debugger can do PTRACE_SETSIGINFO and confuse itself but proba= bly we > do not care? The only potential issue I could think of is whether PTRACE_SETSIGINFO could be used this way to cause an information leak by making PTRACE_GET_SYSCALL_INFO access some unrelated data. --=20 ldv --M9NhX3UHpAaciwkO Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIcBAEBCAAGBQJb/dL4AAoJEAVFT+BVnCUIF/MQAMC9+XrGx9ayW2qY4YB/NhyN Y45xc4uPFby1DPp0rzogf2SJ0A8A5j6TH1uDXNg4yDEh8o0Ov4oTKqbeKl6PorM1 jf0zk2rENykAdZX503kaI5HWMgddR7q1q8XyjsyDL1FUwQtBito+pbC5cr82hfkY 96UqJmm8XlbRbDIkZkuGE8SAnTbEufBg2eY9RvamuBKsOSbqN+03kP9ThQ2Ecen4 6dgdnX00hpCL3HFCjXbymjmKZGoY4hAVpKpZK76W6yaIXaBnaJ/OGC8n638Hw43Q 9Tt2FDgslQDYJyeBuL+GuW6IznUp38EG4g6iHZLL1UHZUMVYdKgQcdaOsd3lXY25 89Z7dnBcQz0P3K1Jmgc/GgZzO0xeCsEATuVWzdNPj09mMok0b++nHFnD5Yeb9nDt ndAiE9h6RnpHy2aYma05SLH7nd7CpcEbC8GIR5pMUd3F+QzPX2QNTC1S9QLNqByf 4RelqJB88Rj44NBGKWW83+I+zhpCGpsrwU4Fn8c2kLgHzZFuWwROjP5RYE0nV40Y qhP1irq1PcWg9V6OY0T6wxPV2Tfa8tuvxCxVSZ35YhrTqbgKMYxfyjk3MyUJs7FG qUH+ntArYQ2NiAeSQsU8WGD8yONDiBEJbF9EeqAApUvJTcuIRoj/xyOBiaQi7uDi S0KILWIMBBkcuXJR9Hmp =F6Fd -----END PGP SIGNATURE----- --M9NhX3UHpAaciwkO--