Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp528424pxf; Thu, 11 Mar 2021 08:51:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJxgKtcGvtq8xh82CasgWJFrC7X5/FKlndiJZmrn81LojOeU/M0RuPyPLvBlCvo3meVNpb9j X-Received: by 2002:a17:907:e8f:: with SMTP id ho15mr4053967ejc.541.1615481493513; Thu, 11 Mar 2021 08:51:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615481493; cv=none; d=google.com; s=arc-20160816; b=er73OMAg3gsgeMWUVyh3bSoyL2RBWd+VVDfC6RrllokzwSrRR8g1oq49BEHN+Od96q cv6bFHTbzTgDuVox+Yo35jKSPiY0i+mF5MXxWJh+tDYBm5O/g/Mto4ovhm3XZ20S4iIs 9tBWYpmKG2CteIpvpPAnvNrzasPMXxHysUTRUTd1ZwkMPWcXWX+6RI2dL7jUsAn5Xn8l a8sCQZBcFyhoSO53+oTGHvue2y3r+t6O5R9UV7UG89XVBoE10HaeFXu4B3NiFxWuBvb8 bEhtJTq9hlthqC3uvHZ0ekIkk0HWFHDvN7YnuFmS2dr2SBbrMoUdISUQKT9znYyPWp/k CEcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:date:message-id:organization:from :references:cc:to:subject; bh=Mu+kTxCsPTnIg8gBfUesxKBub24uN2wGc5pCIkERQpA=; b=J7EVklXbDgtJ+qCZy3ae8wK+G+HSB00SSI9+t1ekKbYqf77022xTkZmpX7JhVq5aoM OZsC74pwsaLlHsfNJ6XpCYr+knpm+eP4qkLEhuzxiTYlAsxgrK2kt0c3XJ+f2vM/Mfb3 PGjK5u8uir102lJMnlT4bJOt3Ql90BqmLe9NMN/cjQQM40KsFsEXanH1QLCBfRUo3ONV fPKxoSwmknlKN4E9///ekqwEfNEVCD1PJ8o3ynkuJ/Z1l10PmGikBAIbsFyuHGzbKGig hP3fWupzyrpthaBfBgIzR9t+oKVZ09Ri+LDt+J4QI8tjLLjJIjfesYB5zRo9V0CoYBuj wwVA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e7si2047879ejd.658.2021.03.11.08.51.10; Thu, 11 Mar 2021 08:51:33 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229729AbhCKQtv (ORCPT + 99 others); Thu, 11 Mar 2021 11:49:51 -0500 Received: from mx1.riseup.net ([198.252.153.129]:53122 "EHLO mx1.riseup.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229530AbhCKQtV (ORCPT ); Thu, 11 Mar 2021 11:49:21 -0500 Received: from fews1.riseup.net (fews1-pn.riseup.net [10.0.1.83]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client CN "*.riseup.net", Issuer "Sectigo RSA Domain Validation Secure Server CA" (not verified)) by mx1.riseup.net (Postfix) with ESMTPS id 4DxFKF0NRKzDxxF; Thu, 11 Mar 2021 08:49:21 -0800 (PST) X-Riseup-User-ID: 4679470A95FF91EABF51198E5B78047C0E3FD6BB6DE13DC0EF9CA8910FCE32BE Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews1.riseup.net (Postfix) with ESMTPSA id 4DxFKD4zCrz5vNM; Thu, 11 Mar 2021 08:49:20 -0800 (PST) Subject: Re: [PATCH] ptrace: Allow other threads to access tracee To: Oleg Nesterov Cc: linux-kernel@vger.kernel.org References: <20210310205908.23447-1-jnewsome@torproject.org> <20210311152123.GC15552@redhat.com> From: Jim Newsome Organization: The Tor Project Message-ID: Date: Thu, 11 Mar 2021 10:49:19 -0600 MIME-Version: 1.0 In-Reply-To: <20210311152123.GC15552@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/11/21 09:21, Oleg Nesterov wrote: > Cough... it is not that simple. Yes, I was afraid of that :) > Just suppose that 2 threads call ptrace(tracee) at the same time. Say, the 1st > thread does PTRACE_CONT while the 2nd thread tries to change the registers. Is it acceptable for the new register-values to be lost, or even corrupted, in this case? From my perspective it is, if the tracer failed to synchronize itself, but maybe there's an overarching philosophy that syscalls should be "atomic"? I suppose even if the corruption of the register-values-themselves is acceptable, some synchronization may be needed to avoid the possibility of corrupting the kernel's data structures? Is it "just" a matter of adding some locking? Would a relatively coarse lock on the target task over the duration of the ptrace call (which I believe is always non-blocking?) be acceptable, or would we need finer grained locking in places where we actually touch the target task? And do you have a feel for whether you'd be inclined to accept such a patch once that (or whatever actually is needed) is added? Thanks! -Jim