Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp343742pxb; Wed, 14 Apr 2021 17:19:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqhhn0eRzCgV1N6g+cHubr65B1VhO4Jz9nvCuzhRDtoNKmUdLm577XhhJURnXSBWbWATRx X-Received: by 2002:a17:906:7016:: with SMTP id n22mr652960ejj.23.1618445977997; Wed, 14 Apr 2021 17:19:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618445977; cv=none; d=google.com; s=arc-20160816; b=aGpvYZrvWatefTSenu+RpqBJugX/Wjk52YBJTzCx4NK7fdkj5zUcKDjwNPBL8aOd9l M42KYRyG4DgqQ9vUGGAhQ24AOtIG+5oAnmnPRYL1rIpuky9mwX+lP0rFk/3FzCiyDyAt 8Mmxd87f4G8J0r4eGCOhRoBNKT6Fu4YTCnGNQKZMi9dMGvsHuvXFrgB2l1PfHobuxmxC I81ipo2trIiQks+TCPkJstMjKYSOYqJr4MSNttJoB0fMTHJs19npseL9Mjz0met9RuzB xWj4gXSiuLJkjIv1dkH5Uey3tKagCg98LT3Op+8l5dNSbbHiJifR6LbTuaz54f/H7WCv oVkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:message-id:in-reply-to:date:references:subject:cc:to :from:dkim-signature; bh=NO4FGUOTnvyNv6ZEsf7CqScF3ifaTTajd0Qf2emlRl0=; b=N9QU/g+ietUaGeEfJu6w9XZ4xZ+BMHy90ULWvsyMMovjThoCSgWBf4sGAYYCpIV35E RqibdmDEQ7/MFQJhuRc2gSbcwCLX2CGJz49iAZK2nHiXgFd9SQH4utbOLlkHUxPxf6VV RV1fAxR49YsSJLZ9nyJSdumfe6CAEJ1WXUkzzvGTCxhBUq8WXIPzusZnjgjLwZkGeNv5 WSO7ipe9yMMW7ESbQiPEsHuLGAG/l1c7LdklMWHVdH6C8zSIx6EAcAL2y5LTMgukx4Ra OlWTFE2VeQy/Jk5Vn9O/2ApG8VRdsNZQ1dJNrLRSPvO7Ft/Qwu4KMF2y53MDkRpB1ZpO KLFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YpS1w1cu; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hs11si883367ejc.429.2021.04.14.17.19.15; Wed, 14 Apr 2021 17:19:37 -0700 (PDT) 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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YpS1w1cu; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233040AbhDNMVO (ORCPT + 99 others); Wed, 14 Apr 2021 08:21:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:52923 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346904AbhDNMVM (ORCPT ); Wed, 14 Apr 2021 08:21:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618402850; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NO4FGUOTnvyNv6ZEsf7CqScF3ifaTTajd0Qf2emlRl0=; b=YpS1w1cuS3xQcpeGuRymmMxzhteusWRnHMQGAS8iquKnbbXZ3mpk7McTt+ojglvvSVusfz eqLzd9ip+oUcSHiFaTD3/iE98RBgPqnSWBCWFF1XNSMPgyTctMqnHA05N/4OcFL5mzZqbm 8ZxxW6ybr1XpNXFFceGsu0tj9EY8tJw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-424-MbvmUyxeMQSe91Bt0GGgJQ-1; Wed, 14 Apr 2021 08:20:46 -0400 X-MC-Unique: MbvmUyxeMQSe91Bt0GGgJQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 03C101006C81; Wed, 14 Apr 2021 12:20:44 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-112-148.ams2.redhat.com [10.36.112.148]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 571D210016FE; Wed, 14 Apr 2021 12:20:34 +0000 (UTC) From: Florian Weimer To: Jann Horn Cc: Andrei Vagin , kernel list , Linux API , linux-um@lists.infradead.org, criu@openvz.org, Andrei Vagin , Andrew Morton , Andy Lutomirski , Anton Ivanov , Christian Brauner , Dmitry Safonov <0x7f454c46@gmail.com>, Ingo Molnar , Jeff Dike , Mike Rapoport , Michael Kerrisk , Oleg Nesterov , Peter Zijlstra , Richard Weinberger , Thomas Gleixner Subject: Re: [PATCH 0/4 POC] Allow executing code and syscalls in another address space References: <20210414055217.543246-1-avagin@gmail.com> <87blahb1pr.fsf@oldenburg.str.redhat.com> Date: Wed, 14 Apr 2021 14:20:48 +0200 In-Reply-To: (Jann Horn's message of "Wed, 14 Apr 2021 13:24:30 +0200") Message-ID: <874kg99hwf.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Jann Horn: > On Wed, Apr 14, 2021 at 12:27 PM Florian Weimer wrot= e: >> >> * Andrei Vagin: >> >> > We already have process_vm_readv and process_vm_writev to read and wri= te >> > to a process memory faster than we can do this with ptrace. And now it >> > is time for process_vm_exec that allows executing code in an address >> > space of another process. We can do this with ptrace but it is much >> > slower. >> > >> > =3D Use-cases =3D >> >> We also have some vaguely related within the same address space: running >> code on another thread, without modifying its stack, while it has signal >> handlers blocked, and without causing system calls to fail with EINTR. >> This can be used to implement certain kinds of memory barriers. > > That's what the membarrier() syscall is for, right? Unless you don't > want to register all threads for expedited membarrier use? membarrier is not sufficiently powerful for revoking biased locks, for example. For the EINTR issue, is an example. I believe CIFS has since seen a few fixes (after someone reported that tar on CIFS wouldn't work because the SIGCHLD causing utimensat to fail=E2=80=94and there isn't even a signal handler for SIGCHLD= !), but the time it took to get to this point doesn't give me confidence that it is safe to send signals to a thread that is running unknown code. But as you explained regarding the set*id broadcast, it seems that if we had this run-on-another-thread functionality, we would likely encounter issues similar to those with SA_RESTART. We don't see the issue with set*id today because it's a rare operation, and multi-threaded file servers that need to change credentials frequently opt out of the set*id broadcast anyway. (What I have in mind is a future world where any printf call, any malloc call, can trigger such a broadcast.) The cross-VM CRIU scenario would probably somewhere in between (not quite the printf/malloc level, but more frequent than set*id). Thanks, Florian