From nobody Thu Oct 31 00:18:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=midokura.com ARC-Seal: i=1; a=rsa-sha256; t=1622440393; cv=none; d=zohomail.com; s=zohoarc; b=R6JBPi5ap+bCOzeYNCi7M1zN2QDkPMhkcl0aXogSwXaUd92xgVs7C6hDiPPVGwm5AcfJ9wRztEhVEBI4G8waVs1dz9tT2mIU+OO//Xa6vpRYJAw55Ye80YFBn3SEjURVgJ7rPVeXFO8NeQzAjo70I7r9sb1Q9NWAyW3VLWwGSuQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622440393; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PESTXN59EwLMWjjV5A2aXDktqX9ai+DunPJniUgY9VA=; b=Iu6ORUQniYHkKyAD8Zgfg0z2QGWDfEG7nilt1UqBh4iS/tn0hARxMoqw6DJIde7a+f0zUtE2c8LnfXGGrWxxD9bkBwGh2kaBIgqx8KtHJIlAxWHywXw6EwezKEcgN9MtBQc6e1cDyrTMuacOi6vygOKEEXideAd36OeohLqg59Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 162244039362738.52650453718729; Sun, 30 May 2021 22:53:13 -0700 (PDT) Received: from localhost ([::1]:44340 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lnarP-0007f2-HV for importer@patchew.org; Mon, 31 May 2021 01:53:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43700) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lnapT-0004rE-9q for qemu-devel@nongnu.org; Mon, 31 May 2021 01:51:11 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]:42749) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lnapR-0003mJ-N9 for qemu-devel@nongnu.org; Mon, 31 May 2021 01:51:11 -0400 Received: by mail-pf1-x431.google.com with SMTP id x18so8191393pfi.9 for ; Sun, 30 May 2021 22:51:09 -0700 (PDT) Received: from spacetanuki.lan ([202.12.244.32]) by smtp.gmail.com with ESMTPSA id b10sm4744058pfi.122.2021.05.30.22.51.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 30 May 2021 22:51:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=midokura.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PESTXN59EwLMWjjV5A2aXDktqX9ai+DunPJniUgY9VA=; b=oS3XReGyor7uDwlHLyZQhjNp4g7PElnFgzLAzwv7FGoqVvNVBkkeZGCt3/2NIKMqxF JLOsHojQwwCDTsZbrGEuD+dFjoVW1RSyYh/aGBOK+WnNta2ItzXeHdNOd7O+dmuzHwbV Bp6DuMDt2W9fUHI2LzpJ2Dr7p2OHrFgarXBbM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PESTXN59EwLMWjjV5A2aXDktqX9ai+DunPJniUgY9VA=; b=sDWgSlaYYXSMt1+6SfOpjrFdt5dHpfqeNKz0phnGU9hi7JEFx4nosWOAehMd1rgg6t PTnk/MB0IRL2R5McdFaReUnP4tRlWPlutvshxzmC42voo+pCtQqRDHSM9CgG2bfkn3Ea hh7TyjWbEq80XpgsEIwByu28iullLWbafdWfo3t2sriU9Ptuh+qfSTS0QU7whjzXlalj XpKXC9ByzbK/46DxVO/EWNC+8L9wjXj6nFx5ASG0Tmn/sTbvLN7lEroxtTeQ2M9Ng6B5 EvlhBkHgmyT00lphQBmvy5/fwL2uy59NTVZGkI78K5GO5gcMkcRNrnXAoUf2EDPoGjme JqrQ== X-Gm-Message-State: AOAM531GuRB1Q2tzrds6gMn9cVvS//CgbLqVwKS90QRXwsqtNwnojXPx Im1auxA9Vrs0/wprx2UOw0JI5YPMv0nAbg== X-Google-Smtp-Source: ABdhPJw/uKDTW7aaRX0KdQoFeq+j6NjL9wUpcyPnd+Byg6DufJogMJKw4fdNoq71nFtCGaaKcupNzA== X-Received: by 2002:a05:6a00:1a8b:b029:28e:7b62:5118 with SMTP id e11-20020a056a001a8bb029028e7b625118mr15333588pfv.49.1622440268384; Sun, 30 May 2021 22:51:08 -0700 (PDT) From: YAMAMOTO Takashi To: qemu-devel@nongnu.org Cc: YAMAMOTO Takashi , Laurent Vivier Subject: [PATCH v2 02/11] linux-user: Fix the execfd case of /proc/self/exe open Date: Mon, 31 May 2021 14:50:09 +0900 Message-Id: <20210531055019.10149-3-yamamoto@midokura.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20210531055019.10149-1-yamamoto@midokura.com> References: <20210531055019.10149-1-yamamoto@midokura.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=yamamoto@midokura.com; helo=mail-pf1-x431.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @midokura.com) Content-Type: text/plain; charset="utf-8" It's problematic to return AT_EXECFD as it is because the user app would close it. This patch opens it via /proc/self/fd instead. Signed-off-by: YAMAMOTO Takashi --- linux-user/syscall.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index a2b03ecb8b..14a63518e2 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8118,7 +8118,17 @@ static int do_openat(void *cpu_env, int dirfd, const= char *pathname, int flags, =20 if (is_proc_myself(pathname, "exe")) { int execfd =3D qemu_getauxval(AT_EXECFD); - return execfd ? execfd : safe_openat(dirfd, exec_path, flags, mode= ); + if (execfd) { + char filename[PATH_MAX]; + int ret; + + snprintf(filename, sizeof(filename), "/proc/self/fd/%d", execf= d); + ret =3D safe_openat(dirfd, filename, flags, mode); + if (ret !=3D -1) { + return ret; + } + } + return safe_openat(dirfd, exec_path, flags, mode); } =20 for (fake_open =3D fakes; fake_open->filename; fake_open++) { --=20 2.21.1 (Apple Git-122.3)