lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20231108022651.645950-3-mmaurer@google.com>
Date:   Wed,  8 Nov 2023 02:26:22 +0000
From:   Matthew Maurer <mmaurer@...gle.com>
To:     Masahiro Yamada <masahiroy@...nel.org>
Cc:     linux-kbuild@...r.kernel.org, Matthew Maurer <mmaurer@...gle.com>,
        linux-kernel@...r.kernel.org
Subject: [PATCH 1/3] kconfig: Extend expr_depends_symbol to recurse

Adds optional recursion support to expr_depends_symbol. If recurse is
set to true, it will recurse through other defined symbols' dependencies
to determine if the expression hard-depends on the provided argument
through an multi-step dependency.

Signed-off-by: Matthew Maurer <mmaurer@...gle.com>
---
 scripts/kconfig/expr.c | 22 ++++++++++++++++------
 scripts/kconfig/expr.h |  2 +-
 scripts/kconfig/menu.c |  2 +-
 3 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c
index 81ebf8108ca7..9d517b897378 100644
--- a/scripts/kconfig/expr.c
+++ b/scripts/kconfig/expr.c
@@ -876,25 +876,35 @@ int expr_contains_symbol(struct expr *dep, struct symbol *sym)
 	return 0;
 }
 
-bool expr_depends_symbol(struct expr *dep, struct symbol *sym)
+static bool sym_depends_symbol(struct symbol *hay, struct symbol *needle, bool recurse) {
+	if (!hay)
+		return false;
+	if (hay == needle)
+		return true;
+	if (recurse)
+		return expr_depends_symbol(hay->dir_dep.expr, needle, recurse);
+	return false;
+}
+
+bool expr_depends_symbol(struct expr *dep, struct symbol *sym, bool recurse)
 {
 	if (!dep)
 		return false;
 
 	switch (dep->type) {
 	case E_AND:
-		return expr_depends_symbol(dep->left.expr, sym) ||
-		       expr_depends_symbol(dep->right.expr, sym);
+		return expr_depends_symbol(dep->left.expr, sym, recurse) ||
+		       expr_depends_symbol(dep->right.expr, sym, recurse);
 	case E_SYMBOL:
-		return dep->left.sym == sym;
+		return sym_depends_symbol(dep->left.sym, sym, recurse);
 	case E_EQUAL:
-		if (dep->left.sym == sym) {
+		if (sym_depends_symbol(dep->left.sym, sym, recurse)) {
 			if (dep->right.sym == &symbol_yes || dep->right.sym == &symbol_mod)
 				return true;
 		}
 		break;
 	case E_UNEQUAL:
-		if (dep->left.sym == sym) {
+		if (sym_depends_symbol(dep->left.sym, sym, recurse)) {
 			if (dep->right.sym == &symbol_no)
 				return true;
 		}
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h
index 4a9a23b1b7e1..edfe3046d050 100644
--- a/scripts/kconfig/expr.h
+++ b/scripts/kconfig/expr.h
@@ -299,7 +299,7 @@ struct expr *expr_trans_bool(struct expr *e);
 struct expr *expr_eliminate_dups(struct expr *e);
 struct expr *expr_transform(struct expr *e);
 int expr_contains_symbol(struct expr *dep, struct symbol *sym);
-bool expr_depends_symbol(struct expr *dep, struct symbol *sym);
+bool expr_depends_symbol(struct expr *dep, struct symbol *sym, bool recurse);
 struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym);
 
 void expr_fprint(struct expr *e, FILE *out);
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index 61c442d84aef..d5898cd6aeb8 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -443,7 +443,7 @@ void menu_finalize(struct menu *parent)
 			if (!expr_contains_symbol(dep, sym))
 				/* No dependency, quit */
 				break;
-			if (expr_depends_symbol(dep, sym))
+			if (expr_depends_symbol(dep, sym, false))
 				/* Absolute dependency, put in submenu */
 				goto next;
 
-- 
2.42.0.869.gea05f2083d-goog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ