From owner-dev-commits-src-main@freebsd.org Tue Jan 19 12:25:42 2021 Return-Path: Delivered-To: dev-commits-src-main@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 F27BC4F2B78; Tue, 19 Jan 2021 12:25:42 +0000 (UTC) (envelope-from etnapierala@gmail.com) Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DKntZ66Cvz3NQ2; Tue, 19 Jan 2021 12:25:42 +0000 (UTC) (envelope-from etnapierala@gmail.com) Received: by mail-wm1-x32a.google.com with SMTP id c127so1083028wmf.5; Tue, 19 Jan 2021 04:25:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to; bh=wCiE1FhxsLcoCIuOE5iJvJ7jEOgIBhCX70XJywj7VQA=; b=YOG6YMVFyKsY1lPkOX9AVyAIWoWHHVpyWXKa1/iy6i5wmEFiEQ+H4Ew67zFEjR4kWh q1pHFqo1VEggD74bopXUzk6M0IMWqHaD3Df2MUeyBD/XViWje44REGTHR2R39L+lnsDo XLY+PZsqQWI2URcsR4bXd8BXX5LArk0CpClUQ4cfizBNpjHTMVRAehl4/i2bJi6kN4Vy rIS5uWrsdXMT9i/a4VnsLVABunBVt2NbVewjZmIlVdsgl0dXZVXHi6r/aUAlVen1VesG ztt2tjX+p/r6ZYdJwUwgYAlR0qB5Z9d1Qm2T3CCdsKIiYG6ggjG0HUjTg4Cg2frDVP8R f3Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=wCiE1FhxsLcoCIuOE5iJvJ7jEOgIBhCX70XJywj7VQA=; b=iQ4MiStZkf3EBSPzH/NFAklD3EvvALOvRTXjZofqC8M2qspd4xUwIW70ayR4qe8Ds3 DNa9sXobDVqeHu1uVHfFghrhB+Gq8ElpOfAcc/Onyva5oJ+SdOg+Gen2MjBPzlrHI+BU r1xVFJ+8BC8y3EwZti0ZuD5gxiAF3aXX95UiK7KTx4ieA4YXeZKmHHSvw8zdLMhatfaR bQMIPwGRKVyAJAZj+1w2yAXeKjFo5duZbB9QML528iNSyVsZMbrJhuEj8Hdc+rNmw0cc dceUMiOpbw7m5YlapZL1Ip/QrusR6+MC7rTuvpzqUwYRi9JinDnrwM+VUhXMbeeerR7d dZbQ== X-Gm-Message-State: AOAM531W8aol31gxCKZHTSRPch21h+tRWlzI4ciXBtxPcj81sif2ZgaI I4Q9b3Cbi0v5XhQT3CfFIKMF+Qx2wsc= X-Google-Smtp-Source: ABdhPJx7N62hFjmn8KtDcbY8p1oDpWho5gAqVd8sfokXk5OXLsY/8QBi9PjLetsSiApI64MwQuMQIQ== X-Received: by 2002:a1c:bc8b:: with SMTP id m133mr3015079wmf.58.1611059139177; Tue, 19 Jan 2021 04:25:39 -0800 (PST) Received: from brick (cpc159423-cmbg20-2-0-cust338.5-4.cable.virginm.net. [86.7.147.83]) by smtp.gmail.com with ESMTPSA id r2sm37120365wrn.83.2021.01.19.04.25.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Jan 2021 04:25:38 -0800 (PST) Sender: =?UTF-8?Q?Edward_Tomasz_Napiera=C5=82a?= Date: Tue, 19 Jan 2021 12:25:36 +0000 From: Edward Tomasz Napierala To: Konstantin Belousov Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 47f7345baba0 - main - linux: fix PTRACE_POKEDATA and PTRACE_POKETEXT. Message-ID: Mail-Followup-To: Konstantin Belousov , src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org References: <202101191053.10JArcDa041994@gitrepo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 4DKntZ66Cvz3NQ2 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jan 2021 12:25:43 -0000 On 0119T1314, Konstantin Belousov wrote: > On Tue, Jan 19, 2021 at 10:53:38AM +0000, Edward Tomasz Napierala wrote: > > The branch main has been updated by trasz: > > > > URL: https://cgit.FreeBSD.org/src/commit/?id=47f7345baba01121e29c22b43f68345399a32912 > > > > commit 47f7345baba01121e29c22b43f68345399a32912 > > Author: Edward Tomasz Napierala > > AuthorDate: 2021-01-15 16:57:24 +0000 > > Commit: Edward Tomasz Napierala > > CommitDate: 2021-01-19 10:30:55 +0000 > > > > linux: fix PTRACE_POKEDATA and PTRACE_POKETEXT. > > > > Sponsored by: The FreeBSD Foundation > > --- > > sys/amd64/linux/linux_ptrace.c | 9 +++++++-- > > 1 file changed, 7 insertions(+), 2 deletions(-) > > > > diff --git a/sys/amd64/linux/linux_ptrace.c b/sys/amd64/linux/linux_ptrace.c > > index a14155ed7e97..c1d05db5bc42 100644 > > --- a/sys/amd64/linux/linux_ptrace.c > > +++ b/sys/amd64/linux/linux_ptrace.c > > @@ -594,10 +594,15 @@ linux_ptrace(struct thread *td, struct linux_ptrace_args *uap) > > error = linux_ptrace_peekuser(td, pid, addr, (void *)uap->data); > > break; > > case LINUX_PTRACE_POKETEXT: > > - error = kern_ptrace(td, PT_WRITE_I, pid, addr, uap->data); > > - break; > This is wrong. You should access text AS if linux request was for text. Do we actually want to maintain that distinction? Looking at sys/kern/sys_process.c, they are synonyms. > > case LINUX_PTRACE_POKEDATA: > > error = kern_ptrace(td, PT_WRITE_D, pid, addr, uap->data); > > + if (error != 0) > > + return (error); > > + /* > > + * Linux expects this syscall to write 64 bits, not 32. > > + */ > > + error = kern_ptrace(td, PT_WRITE_D, pid, > > + (void *)(uap->addr + 4), uap->data >> 32); > > break; > You should use PT_IO there instead of doing two accesses (to the wrong AS). Hm, you're right. The only problem I can see is that PT_IO fetches struct ptrace_io_desc from userspace, which makes wrapping somewhat hard. How about introducing PT_READ64 and PT_WRITE64 request types and using them instead? Thanks!