From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 15E3C42D88 for ; Thu, 29 Jun 2023 04:53:53 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0DA2F42BAC; Thu, 29 Jun 2023 04:53:53 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 27263406B7; Thu, 29 Jun 2023 04:53:49 +0200 (CEST) Received: from canpemm500005.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Qs2xm5py9zMp4V; Thu, 29 Jun 2023 10:50:36 +0800 (CST) Received: from Y00251687ALE274.china.huawei.com (10.174.178.198) by canpemm500005.china.huawei.com (7.192.104.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 29 Jun 2023 10:53:47 +0800 From: Weifeng Su To: CC: , , Weifeng Su Subject: [PATCH v2] pci: add O_CLOEXEC when open uio device Date: Thu, 29 Jun 2023 10:53:39 +0800 Message-ID: <20230629025339.49404-1-suweifeng1@huawei.com> X-Mailer: git-send-email 2.18.0.windows.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.178.198] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To canpemm500005.china.huawei.com (7.192.104.229) X-CFilter-Loop: Reflected X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org In this scenario, the DPDK process invokes a script which inherits an open file descriptor (FD) for a UIO device. After the script execution is complete, the UIO device's close operation is called. However, in a new kernel version (865a11f987ab5f03:uio/uio_pci_generic: Disable bus-mastering on release), this close operation causes the PCI bus master bit to be cleared, rendering the device unusable and leading to unexpected behavior. This modification was made to prevent the UIO device's FD from being inherited by the child process. Signed-off-by: Weifeng Su --- drivers/bus/pci/linux/pci_uio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c index d52125e49b..7ac142c36e 100644 --- a/drivers/bus/pci/linux/pci_uio.c +++ b/drivers/bus/pci/linux/pci_uio.c @@ -246,7 +246,7 @@ pci_uio_alloc_resource(struct rte_pci_device *dev, snprintf(devname, sizeof(devname), "/dev/uio%u", uio_num); /* save fd if in primary process */ - fd = open(devname, O_RDWR); + fd = open(devname, O_RDWR | O_CLOEXEC); if (fd < 0) { RTE_LOG(ERR, EAL, "Cannot open %s: %s\n", devname, strerror(errno)); -- 2.18.0.windows.1