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.129.124]) by passt.top (Postfix) with ESMTP id C06F25A0265 for ; Mon, 7 Nov 2022 19:40:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667846434; 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=ULzbnGe7RotkB4CXA+3r2lSS65/gJz4IzGdAOaiq+SU=; b=fojlScgqr/t6eLsvIsdu9xDcEeB0MjBxJDozXEk3LivGQftt9gtGQkPiqNonoUMrZv7oCv p83/K58URWaWM4DIR71AuwU/5WOG92DXw6QCRvxYM5bayozuJ67RF8/6X3vNCpK8DofLjg nabdsZpJZUeCq/g9kB7iovcOWga1oXE= 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-475-Cr2EdtVFPD-JABqk9AedKQ-1; Mon, 07 Nov 2022 13:40:33 -0500 X-MC-Unique: Cr2EdtVFPD-JABqk9AedKQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4712380280D; Mon, 7 Nov 2022 18:40:33 +0000 (UTC) Received: from maya.cloud.tilaa.com (ovpn-208-9.brq.redhat.com [10.40.208.9]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 04B9A40C6FA1; Mon, 7 Nov 2022 18:40:32 +0000 (UTC) Date: Mon, 7 Nov 2022 19:40:11 +0100 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH] pasta: Workaround: wait for execvp() to be done in child before entering netns Message-ID: <20221107194011.30d09bac@elisabeth> In-Reply-To: <20221107105111.09af5336@elisabeth> References: <20221104015328.3831630-1-sbrivio@redhat.com> <20221107105111.09af5336@elisabeth> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: 3ZYAWJYZ2KTQZ7R24KOKTH2NOIDYTH4B X-Message-ID-Hash: 3ZYAWJYZ2KTQZ7R24KOKTH2NOIDYTH4B 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: 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 Mon, 7 Nov 2022 10:51:11 +0100 Stefano Brivio wrote: > On Mon, 7 Nov 2022 14:17:44 +1100 > David Gibson wrote: > > > On Fri, Nov 04, 2022 at 02:53:28AM +0100, Stefano Brivio wrote: > > > This happens about every third time on the two_guests/basic test, and > > > on that test only: we clone() twice, first to spawn a child, then to > > > spawn a thread to check that we can enter the target network > > > namespace. > > > > > > In this thread, we open a file descriptor associated to the target > > > namespace. It might happen that it doesn't exist yet: the kernel can > > > legitimately take its time to create one, after clone(). In this > > > case, at least on a 5.15 Linux kernel, trying to open that file again > > > always yields EACCES, and we get stuck there. > > > > > > This only occurs if we spawn two instances of pasta very close > > > together, as it's done in the two_guests/basic case. > > > > > > I couldn't figure out what the race condition is, yet, and especially > > > if it's a kernel issue or something we're doing wrong. However, if we > > > wait until the execvp() in the child is done, the issue disappears. > > > I'm not sure yet if it's just because of timing and this is hiding an > > > unrelated race condition. > > > > > > The workaround consists of checking /proc/PID/exe against our own. If > > > it's different, that means execvp() already completed and we can > > > proceed. It's rather ugly, but much better than the alternative. > > > Leave a FIXME there for the moment being. > > > > > > Signed-off-by: Stefano Brivio > > > > Weird and ugly, but seems like we need it. > > > > Reviewed-by: David Gibson > > Sorry, I forgot to mention: I didn't actually push this, because while > repeating that test over and over again I hit the same failure at some > point, even with this trick. > > So this is probably just affecting the timing. I need to look into it > again. Tracked at: https://bugs.passt.top/show_bug.cgi?id=36 for the moment being. -- Stefano