From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id BD4C55A0082 for ; Tue, 14 Feb 2023 14:03:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676379786; 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=T5mXI3+HiiDxDmwhZ2e3xbD25tj9wzMPdubzPDkEXdQ=; b=O/64maXmHkwzOzplVUWef3rhetXh7HpCRmRqBa4Pe2IhNivlmdY+b4PZgwSctHPeRrZMqY Y5P0wHFImGqT8md18mbScbf0nZAFLVCNlWOgkRZkGkexUf6RzBO9qIU8CnY2uIsSpr+OC0 NJscU5ztciBU77amPk7vd6vj1M1itm0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-518-Oix_HlewOMC9xtfgLD9vnA-1; Tue, 14 Feb 2023 08:03:05 -0500 X-MC-Unique: Oix_HlewOMC9xtfgLD9vnA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 10216971090 for ; Tue, 14 Feb 2023 13:03:05 +0000 (UTC) Received: from maya.cloud.tilaa.com (unknown [10.33.32.3]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E0242492B15; Tue, 14 Feb 2023 13:03:04 +0000 (UTC) Date: Tue, 14 Feb 2023 14:02:53 +0100 From: Stefano Brivio To: Michal Privoznik Subject: Re: [PATCH 4/4] qemu_passt: Don't let passt fork off Message-ID: <20230214140253.49bbc13a@elisabeth> In-Reply-To: <5abfc412e4692a38e980c8dc600e1bfbd03ddcfd.1676374699.git.mprivozn@redhat.com> References: <5abfc412e4692a38e980c8dc600e1bfbd03ddcfd.1676374699.git.mprivozn@redhat.com> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: 7ABTTPYPQX5WWJAF6IHSLPJXDDVHKD7S X-Message-ID-Hash: 7ABTTPYPQX5WWJAF6IHSLPJXDDVHKD7S X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: libvir-list@redhat.com, passt-dev@passt.top X-Mailman-Version: 3.3.3 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Tue, 14 Feb 2023 12:51:22 +0100 Michal Privoznik wrote: > When passt starts it tries to do some security measures to > restrict itself. For instance, it creates its own namespaces, > umounts basically everything, drops capabilities, forks off to > further restrict itself (the child is where all interesting work > takes place now). This is sound, except it's causing two > problems: > > 1) the PID file FD, which we leak into the passt process, gets > closed (and thus our virPidFile*() helpers see unlocked PID > file, which makes them think the process is gone), I didn't realise this was the case, but giving passt write (unless I'm missing something) access to a file created by libvirtd doesn't look desirable to me. > 2) the PID file no longer reflects true PID of the process. > > Worse, the child calls setsid() so we can't even kill the whole > process group. I mean, we can but it won't be any good. > > Fortunately, passt has '--foreground' argument, which causes it > to undergo the same security measures but without forking off the > child. They're not the same -- unfortunately they can't be, because, on Linux, you can't change the PID of an existing process, so there's no way to enter a new PID namespace without clone(). If passt remains in the same PID namespace, it's still able to see PIDs of other processes, which is not desirable from a security perspective. Again from a security perspective, this is probably a small impact, so I guess it's fine if there's no other way around it. But I see a lot of ways around it... -- Stefano