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 835025A004F for ; Thu, 20 Jun 2024 14:47:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718887656; 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: in-reply-to:in-reply-to:references:references; bh=/tfzw51ZBKXCF2HFuqMyCsfF6pyYtjZTi5h8k7gthng=; b=NqHxaMjG7rU2VR5FDHraI0uV1W14Yclrt7IukTL/yZ5ZT+ppkd+h6EziVNebjJR1rC94Mk Zm2BOoVlka8JX3KmjtF/rs/ltjwJXFywAbTDDQBYjL1Omyns91Bbc/aQBUKM2F8WrQ7iWc zDd3u06hnQEMITKhcYmQrflFh34BKOE= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-484-XIn4HvgaMJ2odXBWWqqbsw-1; Thu, 20 Jun 2024 08:47:35 -0400 X-MC-Unique: XIn4HvgaMJ2odXBWWqqbsw-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6E3BC19560AA; Thu, 20 Jun 2024 12:47:33 +0000 (UTC) Received: from localhost (unknown [10.39.195.98]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2463A1956052; Thu, 20 Jun 2024 12:47:31 +0000 (UTC) Date: Thu, 20 Jun 2024 13:47:31 +0100 From: "Richard W.M. Jones" To: Stefano Brivio Subject: Re: [PATCH 7/8] conf, passt, tap: Open socket and PID files before switching UID/GID Message-ID: <20240620124730.GC1450@redhat.com> References: <20240522205911.261325-1-sbrivio@redhat.com> <20240522205911.261325-8-sbrivio@redhat.com> <20240620113054.GB1450@redhat.com> <20240620141253.7e6d3855@elisabeth> MIME-Version: 1.0 In-Reply-To: <20240620141253.7e6d3855@elisabeth> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Message-ID-Hash: 6WI4XZCSCQ5MHPG23WWD6QIJTWHEQPV2 X-Message-ID-Hash: 6WI4XZCSCQ5MHPG23WWD6QIJTWHEQPV2 X-MailFrom: rjones@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: David Gibson , passt-dev@passt.top, Minxi Hou X-Mailman-Version: 3.3.8 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 Thu, Jun 20, 2024 at 02:12:53PM +0200, Stefano Brivio wrote: > On Thu, 20 Jun 2024 12:30:54 +0100 > "Richard W.M. Jones" wrote: > > > On Wed, May 29, 2024 at 12:35:24PM +1000, David Gibson wrote: > > > On Wed, May 22, 2024 at 10:59:10PM +0200, Stefano Brivio wrote: > > > > Otherwise, if the user runs us as root, and gives us paths that are > > > > only accessible by root, we'll fail to open them, which might in turn > > > > encourage users to change permissions or ownerships: definitely a bad > > > > idea in terms of security. > > > > > > > > Reported-by: Minxi Hou > > > > Reported-by: Richard W.M. Jones > > > > Signed-off-by: Stefano Brivio > > > > > > Looking at this I did notice a pre-existing, well, maybe not bug > > > exactly, but possibly surprising behaviour, which makes me a > > > bit more nervous now that we can invoke it as root. > > > > > > tap_sock_unix_open() will silently truncate the given socket path to > > > the maximum length for a Unix socket. Which means we could bind(), > > > but also unlink() a path that's not exactly the same as the one the > > > one the user requested. I don't immediately see a way to exploit > > > that, but it's the sort of thing that makes me nervous. I think we > > > should instead outright fail if the given socket path is too long. > > > > Yes, agreed. > > > > It seems as if the latest passt code still does this. Do you want me > > to open a bug about it? > > Yes, please, that, or a patch :) While I was testing this, I found we do seem to check it: https://passt.top/passt/tree/conf.c#n1446 Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org