From owner-dev-commits-src-all@freebsd.org Wed Sep 15 13:30:20 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 75D0167EDD0; Wed, 15 Sep 2021 13:30:20 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4H8h0q48wtz3n3J; Wed, 15 Sep 2021 13:30:19 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.16.1/8.16.1) with ESMTPS id 18FDU5NE023847 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 15 Sep 2021 16:30:08 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 18FDU5NE023847 Received: (from kostik@localhost) by tom.home (8.16.1/8.16.1/Submit) id 18FDU5hT023846; Wed, 15 Sep 2021 16:30:05 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 15 Sep 2021 16:30:05 +0300 From: Konstantin Belousov To: Jessica Clarke Cc: Edward Tomasz Napierala , src-committers , dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: bdf0f24bb16d - main - linux: implement PTRACE_GET_SYSCALL_INFO Message-ID: References: <202109142041.18EKf6RU040962@gitrepo.freebsd.org> <7C375F3A-889E-440F-A164-959A9A903733@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.5 X-Spam-Checker-Version: SpamAssassin 3.4.5 (2021-03-20) on tom.home X-Rspamd-Queue-Id: 4H8h0q48wtz3n3J X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=gmail.com (policy=none); spf=softfail (mx1.freebsd.org: 2001:470:d5e7:1::1 is neither permitted nor denied by domain of kostikbel@gmail.com) smtp.mailfrom=kostikbel@gmail.com X-Spamd-Result: default: False [-2.29 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; DMARC_POLICY_SOFTFAIL(0.10)[gmail.com : No valid SPF, No valid DKIM,none]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; HAS_XAW(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_SPF_SOFTFAIL(0.00)[~all:c]; RCPT_COUNT_FIVE(0.00)[5]; NEURAL_HAM_SHORT(-0.29)[-0.292]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US]; MIME_TRACE(0.00)[0:+]; MAILMAN_DEST(0.00)[dev-commits-src-all,dev-commits-src-main]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Sep 2021 13:30:20 -0000 On Wed, Sep 15, 2021 at 02:15:59AM +0300, Konstantin Belousov wrote: > On Tue, Sep 14, 2021 at 11:54:08PM +0100, Jessica Clarke wrote: > > On 14 Sep 2021, at 23:45, Konstantin Belousov wrote: > > > > > > On Tue, Sep 14, 2021 at 08:41:06PM +0000, Edward Tomasz Napierala wrote: > > >> The branch main has been updated by trasz: > > >> > > >> URL: https://cgit.FreeBSD.org/src/commit/?id=bdf0f24bb16d556a5b1e01cdfc087d08e91ac572 > > >> > > >> commit bdf0f24bb16d556a5b1e01cdfc087d08e91ac572 > > >> Author: Edward Tomasz Napierala > > >> AuthorDate: 2021-09-12 11:31:10 +0000 > > >> Commit: Edward Tomasz Napierala > > >> CommitDate: 2021-09-14 20:19:55 +0000 > > >> > > >> linux: implement PTRACE_GET_SYSCALL_INFO > > >> > > >> This is one of the pieces required to make modern (ie Focal) > > >> strace(1) work. > > >> > > >> Reviewed By: jhb (earlier version) > > >> Sponsored by: EPSRC > > >> Differential Revision: https://reviews.freebsd.org/D28212 > > >> --- > > >> lib/libsysdecode/mktables | 2 +- > > >> sys/amd64/linux/linux_ptrace.c | 98 +++++++++++++++++++++++++++++++++-- > > >> sys/compat/freebsd32/freebsd32_misc.c | 3 ++ > > >> sys/kern/sys_process.c | 17 ++++++ > > >> sys/sys/ptrace.h | 4 ++ > > >> 5 files changed, 120 insertions(+), 4 deletions(-) > > >> > > >> + case PT_GET_SC_ARGS_ALL: > > >> + CTR1(KTR_PTRACE, "PT_GET_SC_ARGS_ALL: pid %d", p->p_pid); > > >> + if ((td2->td_dbgflags & (TDB_SCE | TDB_SCX)) == 0 > > >> +#ifdef COMPAT_FREEBSD32 > > >> + || (wrap32 && !safe) > > >> +#endif > > >> + ) { > > >> + error = EINVAL; > > >> + break; > > >> + } > > >> + bcopy(td2->td_sa.args, addr, sizeof(td2->td_sa.args)); > > >> + break; > > > > > > This is awful, you already got that feedback in review, as I read it. > > > I strongly suggest to remove PT_GET_SC_ARGS_ALL, and instead checks something > > > in the implementation of PT_GET_SC_ARGS to select either full copy or just > > > nargs args. > > > > > > Easiest thing for 'something' would be SV_PROC_ABI(p) == SV_ABI_LINUX. > > > > That is incorrect. The original review just changed PT_GET_SC_ARGS even > > for FreeBSD and that was what was described as horrible. John suggested > > two alternatives: this approach, and having the Linuxulator bypass > > kern_ptrace entirely by doing its own thing. > My view is that > - the whole thing with reading past nargs is horrible > - having hidden API interface is horrible, it is obvious layering violation > when you need to hide an API: the consumer calls at the wrong level. > > Another reason to dislike this is that we started to add new PT_ verbs > at relatively high rate recently. I am aware of at least to more PT_ > ops coming in. In other words, we are not too far from exhausting the > MI range and then we would need to make some arrangements. Having one > more PT_ value, esp. not useful for anything but for layering violation, > is not good. https://reviews.freebsd.org/D31968