patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Weifeng Su <suweifeng1@huawei.com>
To: <dev@dpdk.org>
Cc: <linfeilong@huawei.com>, Weifeng Su <suweifeng1@huawei.com>,
	<stable@dpdk.org>
Subject: [PATCH] pci: add O_CLOEXEC when open uio device
Date: Thu, 25 May 2023 11:00:35 +0800	[thread overview]
Message-ID: <20230525030035.33872-1-suweifeng1@huawei.com> (raw)

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.
Cc: stable@dpdk.org

Signed-off-by: Weifeng Su <suweifeng1@huawei.com>
---
 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


                 reply	other threads:[~2023-05-25  3:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230525030035.33872-1-suweifeng1@huawei.com \
    --to=suweifeng1@huawei.com \
    --cc=dev@dpdk.org \
    --cc=linfeilong@huawei.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).