Skip to content

glusterd: validate debug.{trace,error-gen,delay-gen} values - #4825

Closed
ThalesBarretto wants to merge 2 commits into
gluster:develfrom
ThalesBarretto:bug/glusterd-debug-xlator-value-validation
Closed

ThalesBarretto wants to merge 2 commits into
gluster:develfrom
ThalesBarretto:bug/glusterd-debug-xlator-value-validation

Conversation

@ThalesBarretto

Copy link
Copy Markdown
Contributor

glusterd: validate debug.{trace,error-gen,delay-gen} values

Problem

debug.trace, debug.error-gen and debug.delay-gen take the name of the translator to insert the debug xlator
above (a brick-graph xlator such as posix/locks, or client), or off — not a boolean. They have no
validate_fn, so gluster volume set VOL debug.delay-gen on returns volume set: success, stores on, and does
nothing: the graph builder only inserts the debug xlator when the value equals a translator name, so any non-xlator
value is silently ignored. The keys are NO_DOC, so the operator gets no hint from volume set help either.

Behind the same path, get_server_xlator() has an inverted strcmp — it returns GF_XLATOR_SERVER on the first
non-matching entry, so it reports SERVER for almost any input and the guard in debugxl_option_handler() that is
meant to skip an invalid debug target is dead. It was introduced correct in 99f18fa (2012) as explicit
strcmp(...) == 0 checks; the later table-driven rewrite dropped the == 0.

Fix

Two commits:

  1. Restore get_server_xlator()'s comparison to == 0, so it correctly reports whether a value names a brick-graph
    xlator. Its only caller is the debug-xlator guard.
  2. Add a validate_fn to the three debug keys that accepts a valid brick-graph xlator name (via the now-correct
    get_server_xlator()), client, or off, and rejects anything else with a message naming the expected form.
    Commit 1 is a prerequisite: without it every value is treated as a valid server xlator and the validator would be a
    no-op.

No behaviour change for the valid, documented usage (debug.delay-gen posix, debug.error-gen client, …), which all
in-tree tests use.

Test

tests/bugs/glusterd/debug-xlator-value-validation.t: asserts debug.delay-gen on / bogusvalue, debug.trace enable, debug.error-gen 1 are now rejected and not stored; that debug.delay-gen posix, debug.trace client,
debug.error-gen locks succeed and that delay-gen actually appears in the brick volfile; and that off is accepted.
Fails on unpatched devel (the invalid sets succeed), passes with this change.

Fixes: #4824

get_server_xlator() walks server_graph_table[] to tell whether a value
names a brick-graph xlator, but the comparison is inverted: strcmp() is
0 on a match, so "if (strcmp(xlator, dbg_key)) return GF_XLATOR_SERVER"
returns GF_XLATOR_SERVER on the first *non*-matching entry, i.e. for
essentially any input. Its only caller is the guard in
debugxl_option_handler() that is meant to skip a debug.{trace,error-gen,
delay-gen} value which is not a valid xlator name; the inverted result
makes that guard dead, so an invalid target for one debug key is not
skipped when another debug key triggers the debug-xlator pass, and its
debug xlator is inserted above the wrong translator.

The function was introduced correct in 99f18fa (2012) as a series of
explicit strcmp(...) == 0 checks; the later table-driven rewrite dropped
the == 0. Restore it.

Updates: gluster#4824
Signed-off-by: Thales Antunes de Oliveira Barretto <thales.barretto.git@gmail.com>
These keys take the name of the translator to insert the debug xlator
above (a brick-graph xlator such as "posix" or "locks", or "client"),
or "off" to disable -- not a boolean. They had no validate_fn, so
"volume set <vol> debug.delay-gen on" (or any non-xlator string) returned
"volume set: success", stored the bogus value, and silently did nothing:
the graph builder (check_and_add_debug_xl / debugxl_option_handler) only
inserts the debug xlator when the value equals a graph xlator name, so a
value that is not one is quietly ignored. Because the keys are NO_DOC,
"volume set help" gives the operator no syntax hint either.

Add a validate_fn that accepts a valid brick-graph xlator name (via the
now-correct get_server_xlator()), "client", or "off", and rejects
anything else with a message naming the expected form. Requires the
get_server_xlator() fix in the previous commit; without it every value
is treated as a valid server xlator and the validator would be a no-op.

Fixes: gluster#4824
Signed-off-by: Thales Antunes de Oliveira Barretto <thales.barretto.git@gmail.com>
@ThalesBarretto
ThalesBarretto marked this pull request as draft September 22, 2026 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

glusterd silently accepts invalid values for debug.trace / debug.error-gen / debug.delay-gen

1 participant