DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net, david.marchand@redhat.com,
	Bruce Richardson <bruce.richardson@intel.com>
Subject: [dpdk-dev] [PATCH 4/4] eal: cache last directory permissions checked
Date: Thu, 18 Jun 2020 14:50:49 +0100	[thread overview]
Message-ID: <20200618135049.489773-5-bruce.richardson@intel.com> (raw)
In-Reply-To: <20200618135049.489773-1-bruce.richardson@intel.com>

When loading a directory of drivers, we check the same hierarchy multiple
times. If we just cache the last directory checked, this avoids repeated
checks of the same path, since all drivers in that path have been added to
the list consecutively.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/librte_eal/common/eal_common_options.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index 2a62a1342..0901b493c 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -384,11 +384,18 @@ verify_perms(const char *dirpath)
 
 	/* if not root, check down one level first */
 	if (strcmp(dirpath, "/") != 0) {
+		static __thread char last_dir_checked[PATH_MAX];
 		char copy[PATH_MAX];
+		const char *dir;
 
 		strlcpy(copy, dirpath, PATH_MAX);
-		if (verify_perms(dirname(copy)) != 0)
-			return -1;
+		dir = dirname(copy);
+		if (strncmp(dir, last_dir_checked, PATH_MAX) != 0) {
+			if (verify_perms(dir) != 0)
+				return -1;
+			else
+				strlcpy(last_dir_checked, dir, PATH_MAX);
+		}
 	}
 
 	/* call stat to check for permissions and ensure not world writable */
-- 
2.25.1


  parent reply	other threads:[~2020-06-18 13:51 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-18 13:50 [dpdk-dev] [PATCH 0/4] improve runtime loading of shared drivers Bruce Richardson
2020-06-18 13:50 ` [dpdk-dev] [PATCH 1/4] eal: remove unnecessary null-termination Bruce Richardson
2020-06-18 13:50 ` [dpdk-dev] [PATCH 2/4] eal: only load shared libs from driver plugin directory Bruce Richardson
2020-06-18 13:50 ` [dpdk-dev] [PATCH 3/4] eal: don't load drivers from insecure paths Bruce Richardson
2020-06-18 13:50 ` Bruce Richardson [this message]
2020-06-22 14:33 ` [dpdk-dev] [PATCH v2 0/4] improve runtime loading of shared drivers Bruce Richardson
2020-06-22 14:33   ` [dpdk-dev] [PATCH v2 1/4] eal: remove unnecessary null-termination Bruce Richardson
2020-06-22 14:33   ` [dpdk-dev] [PATCH v2 2/4] eal: only load shared libs from driver plugin directory Bruce Richardson
2020-06-22 14:33   ` [dpdk-dev] [PATCH v2 3/4] eal: don't load drivers from insecure paths Bruce Richardson
2020-06-22 14:33   ` [dpdk-dev] [PATCH v2 4/4] eal: cache last directory permissions checked Bruce Richardson
2020-07-02 21:13   ` [dpdk-dev] [PATCH v2 0/4] improve runtime loading of shared drivers Thomas Monjalon
2020-07-03 10:25     ` Bruce Richardson
2020-07-02 21:16   ` Thomas Monjalon
2020-07-03  8:33     ` Bruce Richardson
2020-07-03 10:23 ` [dpdk-dev] [PATCH v3 " Bruce Richardson
2020-07-03 10:23   ` [dpdk-dev] [PATCH v3 1/4] eal: remove unnecessary null-termination in plugin path Bruce Richardson
2020-07-03 10:23   ` [dpdk-dev] [PATCH v3 2/4] eal: load only shared libs from driver plugin directories Bruce Richardson
2020-07-03 10:23   ` [dpdk-dev] [PATCH v3 3/4] eal: forbid loading drivers from insecure paths Bruce Richardson
2020-07-03 10:23   ` [dpdk-dev] [PATCH v3 4/4] eal: cache last directory permissions checked Bruce Richardson
2020-07-05 17:50   ` [dpdk-dev] [PATCH v3 0/4] improve runtime loading of shared drivers Thomas Monjalon

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=20200618135049.489773-5-bruce.richardson@intel.com \
    --to=bruce.richardson@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=thomas@monjalon.net \
    /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).