Skip to content

fix(rest,cli): refuse a DrbdOptions property LINSTOR's whitelist refuses - #313

Merged
Andrei Kvapil (kvaps) merged 11 commits into
mainfrom
fix/drbd-options-whitelist
Nov 24, 2026
Merged

Andrei Kvapil (kvaps) merged 11 commits into
mainfrom
fix/drbd-options-whitelist

Conversation

@kvaps

@kvaps Andrei Kvapil (kvaps) commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

What this PR does

blockstor stored any DrbdOptions/* property it was given. A typo such as blockstor rd sp <rd> DrbdOptions/AutoSnapshot/Keep 2 (meant as AutoSnapshot/Keep) was accepted, every satellite rendered it into the options block of the resource's .res, drbdadm refused the file, and every replica of the definition reported ApplyFailed and retried with back-off until the key was deleted. The caller saw success; the mistake surfaced only as Warning events on the nodes.

LINSTOR refuses such a write before it stores anything. Its whitelist lists, per object, which keys may be set, and each key has a rule its value must meet (CtrlPropsHelper.fillProperties, WhitelistProps.isAllowed). This PR does the same for the DrbdOptions/ namespace, on the REST API and in the native CLI, which writes the CRDs directly and so needs the check of its own.

Whitelist. A new pkg/propwhitelist package embeds the DrbdOptions rules of the linstor-common that linstor-server v1.33.1 builds from (properties.json and drbdoptions.json), per object: controller, node, resource definition, volume definition, resource, volume, storage pool, storage pool definition, node connection, resource connection. A resource group is judged as a resource definition and a volume group as a volume definition, as LINSTOR does. Values are checked the way LINSTOR's Property classes check them (yes/no booleans, ranges, symbols, numeric-or-symbol, longs). hack/gen-drbd-whitelist regenerates the catalogue from a linstor-common checkout.

REST. Every door that stores properties checks the keys it would set: controller set-property, node create and modify, resource group create and modify (with its volume groups), volume group create and modify, resource definition create, modify and clone, volume definition create and modify, resource create and modify, volume modify, node connection, storage pool and storage pool definition modify. A refused write stores nothing and answers 400 with LINSTOR's FAIL_INVLD_PROP (213) entry: Invalid property key: <key> / The key '<key>' is not whitelisted. for an unknown key, Invalid property(<key>) value: <value> with the rule in details for a bad value, and the controller's own wording on the controller. An empty value (the set-property delete) and delete_props are not judged, so a key stored before this check can still be removed. Keys outside DrbdOptions/ are not judged.

CLI. set-property and drbd-options on every noun apply the same check before they touch the bag; delete-property is not judged.

blockstor's own keys. blockstor reads three DrbdOptions keys LINSTOR does not list, documents them as the way to set what they set, and returns one of them in a definition's props: DrbdOptions/AutoAddQuorumTiebreaker (the per-definition and per-group tiebreaker switch) on the controller, definitions and groups, and DrbdOptions/TcpPortRange and DrbdOptions/MinorNrRange (written min-max) on nodes. They are accepted next to the generated catalogue, only on those objects and only with a value their reader can parse, so the e2e suites that write the tiebreaker switch through REST and clients that write back the props they read keep working.

Normalised values. Like LINSTOR (WhitelistProps.normalize), an accepted boolean is stored in its canonical form, at every REST door and in the CLI.

Licensing. AGENTS.md forbids anything generated from a GPL source, and linstor-common is a submodule of the GPLv3 linstor-server with no license file of its own. This PR adds a narrow exception there: a tool may read drbdoptions.json and properties.json as data and carry over only interface facts (key names, value types, enum values, ranges, units), never descriptions, code, comments or anything genproperties.py stamps GPLv3. pkg/propwhitelist/drbdoptions.json holds only those facts and names the linstor-common commit it was built from. The same exception covers the existing submodule and the hand port in pkg/drbd/options.go.

Behaviour changes

  • A DrbdOptions/* key LINSTOR does not whitelist for the object is refused with FAIL_INVLD_PROP, including a valid DRBD option on the wrong object (a net option on a volume definition, any section option on a node or a replica).
  • A whitelisted DrbdOptions/* key with a value its rule refuses is refused, for example quorum-minimum-redundancy bogus or max-buffers 8.
  • Rows 62 and 66 of docs/cli-parity-known-deltas.md are closed and removed.
  • An accepted boolean is stored the way LINSTOR stores it: Yes as yes for a yes/no option, No or FALSE as false for a true/false key. Before, it was stored as given, so the satellite left a capitalised Yes out of the .res (drbdadm takes yes and no only) and AutoEvictAllowEviction no read as unset.
  • drbd-options --after-resync-source and --disconnected are gone. LINSTOR does not whitelist those handlers, so the flags could only fail.

Known limitations

  • LINSTOR's controller adds the options its local drbdsetup xml-help describes to the controller whitelist at startup. blockstor uses the static catalogue for every object, so a controller option newer than drbd-utils 9.32 is refused until the catalogue is regenerated.
  • LINSTOR's own spelling of the tiebreaker switch, DrbdOptions/auto-add-quorum-tiebreaker, is accepted and stored but blockstor does not read it, as before this PR; only AutoAddQuorumTiebreaker turns the witness off. A definition adopted from LINSTOR that carries auto-add-quorum-tiebreaker false still gets a witness. Reading it changes which witnesses exist on adopted clusters, so it is left to a separate change.
  • Only the DrbdOptions/ namespace is checked; LINSTOR checks every namespace except Aux/ and a few EBS tags.
  • Objects stored before this change keep whatever they carry. The satellite side of that, leaving such a key out of the .res with a Warning Event instead of failing every apply, is in fix(satellite): render volume definition disk options the way LINSTOR does #275.

Upgrade note

The check judges only the keys a request sets, so an object that already carries a refused key keeps it and can still be modified. A request that sends such a key again is refused, as LINSTOR refuses it. This matters for linstor-csi, which sends a StorageClass's property.linstor.csi.linbit.com/* parameters with each provisioning: a StorageClass carrying a refused DrbdOptions key will fail every PVC after the upgrade. Before upgrading, check the StorageClass parameters and the props of groups and definitions that clients write back against the whitelist. On the test cluster this PR was checked against, every StorageClass parameter and every group prop passes; the only stored values it refuses are two keys LINSTOR's controller writes for itself (auto-verify-alg on definitions, auto-verify-algo-allowed-list on the controller) and auto-quorum=majority on some definitions, none of which a client sends.

Testing

  • pkg/propwhitelist: unknown keys, keys on the wrong object, value rules for every type with LINSTOR's messages, other namespaces untouched.
  • pkg/rest: the typo is refused with FAIL_INVLD_PROP on each of the doors listed above; a request with one bad key stores none of its keys; a bad value is refused with the rule in details; the controller uses its own wording; delete_props and the empty-value set-property still remove a key stored earlier; whitelisted options and other namespaces still land. The C6 corner case now asserts the refusal.
  • internal/cli: set-property refuses the typo, a bad value and a misspelt net key on a definition and on the controller and stores nothing; delete-property still removes such a key; drbd-options refuses a value its rule refuses.
  • blockstor's own keys: accepted over REST on a definition, a group and a node and by the CLI, refused on the wrong object and with a value their reader cannot parse.
  • Normalisation: Yes, No and YES are stored as yes, false and true over REST (definition and node) and by the CLI's set-property and drbd-options.
  • Every knob drbd-options offers resolves to a key the whitelist accepts on a definition.
  • Mutation-checked: disabling the REST check, the check on one door, the CLI set-property check and the CLI drbd-options check each make the tests above fail; so do turning off the own keys, dropping normalisation at the REST door, in set-property or in drbd-options, and putting the two handler flags back.
  • New L6 cell tests/e2e/cli-matrix/rd-sp-unwhitelisted-drbd-option-rejected.sh and L7 replay tests/operator-harness/replay/rd-sp-unwhitelisted-drbd-option-rejected.yaml.
  • make lint-config && make lint: 0 issues. go test ./... with envtest 1.35.0 passes. go test -tags=integration ./tests/integration/... passes; five cases there wrote values or keys LINSTOR refuses (ping-timeout 500, sndbuf-size 512K, protocol on a volume definition, a net option on a replica) and now use accepted ones. In the full run one case failed with the python CLI container exiting 139 (a segfault of the emulated client image, not a blockstor answer); it passed on rerun together with every case this PR touched.

Merging into the alpha line

This branch starts from main. On dev/v0.4.0-alpha.14 it conflicts in four places, each an insertion next to code the alpha line changed: internal/cli/handlers.go (the noun table), pkg/rest/autoplace.go (createResources), pkg/rest/storage_pools.go (the pool modify refusals) and docs/cli-parity-known-deltas.md. Keep both sides.

Not tested

  • The L6 cell and the L7 replay were not run on a stand, and cli-parity-refresh.sh was not run.
  • Nothing ran against a live cluster. Clients other than the python CLI and the blockstor CLI (linstor-csi, piraeus-operator) were not exercised; they work against LINSTOR, which refuses the same keys.

LINSTOR refuses to store a property its whitelist does not list for
the object, and a value the key's rule refuses. blockstor stored any
DrbdOptions key verbatim, so a typo reached the satellites and every
replica's .res.

The package holds the DrbdOptions rules of the linstor-common that
linstor-server v1.33.1 builds from, per object, and checks a key and
value the way LINSTOR's Property classes do, with LINSTOR's own
description of what a rule accepts. hack/gen-drbd-whitelist
regenerates the embedded catalogue from a linstor-common checkout.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
A typo such as DrbdOptions/AutoSnapshot/Keep was stored, every
satellite rendered it into the .res, drbdadm refused the file and
every replica of the definition failed each apply until the key was
deleted. The caller had been told the write succeeded.

Every door that stores properties now checks the DrbdOptions keys it
would set against the whitelist of the object they land on, and
refuses the request with LINSTOR's FAIL_INVLD_PROP entry, storing
none of it, as LINSTOR does. A key on the wrong object and a value
the key's rule refuses are refused the same way. Deletes are not
judged, so a key stored before the check can still be removed.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The native CLI writes the CRDs directly, so the check the REST doors
apply did not reach `rd sp`, the command the typo came through.
set-property and drbd-options now judge the key and value against
the whitelist of the noun's object before they touch the bag; a
delete is not judged.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Rows 62 and 66 recorded that blockstor stored any DrbdOptions value
and any option class on any object. Both are now refused as upstream
refuses them, so the rows go, and an L6 cell and an L7 replay pin
the refusal at the operator CLI.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Several cases wrote values or keys LINSTOR refuses, and the REST and
CLI doors now refuse them too: ping-timeout 500 (its range ends at
300), sndbuf-size 512K (a byte count without unit), protocol on a
volume definition, and a net option on a single replica. They now
use a value in range or a key the object takes, so they keep testing
what they were written for.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The whitelist is LINSTOR's, and LINSTOR does not list the few
DrbdOptions keys blockstor reads on its own: the definition and group
switch for the auto tiebreaker (AutoAddQuorumTiebreaker) and the node
port and minor ranges (TcpPortRange, MinorNrRange). They are
documented as the way to set what they set, GET returns the tiebreaker
switch in a definition's props, and the e2e suites write it through
REST, so refusing them turned each of those writes into a 400 and left
no way to turn the tiebreaker off per definition.

Accept them next to the generated catalogue, each only on the objects
its reader looks at and with a value that reader can parse.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The check accepts Yes or TRUE without regard to case, as LINSTOR's
does, but stored the value as given. LINSTOR stores it normalised
(WhitelistProps.normalize): yes/no in lower case, a true/false key as
true or false. The readers are not as lenient as the check. drbdadm
takes only yes and no, so the satellite leaves a stored Yes out of the
.res and the option silently has no effect; strconv.ParseBool takes
no yes or no, so AutoEvictAllowEviction=no read as unset.

Rewrite an accepted value to LINSTOR's form at every REST door and in
the CLI's set-property and drbd-options before it is stored.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
drbd-options offered --after-resync-source and --disconnected, two
handlers drbd.conf documents but LINSTOR's whitelist does not list.
The whitelist check refuses their keys on every object, so the flags
could only ever fail. Drop them, and test that every offered knob
resolves to a key the whitelist accepts.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 4 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 58b35df6-cc52-4fd5-b2f0-557181061b28
Commits

Reviewing files that changed from the base of the PR and between 3f511fe and feb89dd.

Files selected for processing: 38

  • AGENTS.md
  • docs/cli-parity-known-deltas.md
  • hack/gen-drbd-whitelist/main.go
  • internal/cli/drbdopts.go
  • internal/cli/handlers.go
  • internal/cli/props_whitelist_test.go
  • internal/cli/write.go
  • pkg/drbd/flagkeys.go
  • pkg/propwhitelist/drbdoptions.json
  • pkg/propwhitelist/own.go
  • pkg/propwhitelist/whitelist.go
  • pkg/propwhitelist/whitelist_test.go
  • pkg/rest/autoplace.go
  • pkg/rest/controller_props.go
  • pkg/rest/corner_b_quorum_props_test.go
  • pkg/rest/drbd_options_corner_cases_c4_c6_test.go
  • pkg/rest/node_connections.go
  • pkg/rest/nodes.go
  • pkg/rest/props_whitelist.go
  • pkg/rest/props_whitelist_test.go
  • pkg/rest/rd_clone.go
  • pkg/rest/resource_definitions.go
  • pkg/rest/resource_group_extras.go
  • pkg/rest/resource_groups.go
  • pkg/rest/resource_modify.go
  • pkg/rest/resource_modify_test.go
  • pkg/rest/storage_pool_definitions.go
  • pkg/rest/storage_pools.go
  • pkg/rest/volume_definitions.go
  • pkg/rest/volumes_per_resource.go
  • tests/e2e/cli-matrix/README.md
  • tests/e2e/cli-matrix/rd-sp-unwhitelisted-drbd-option-rejected.sh
  • tests/integration/group_c_test.go
  • tests/integration/group_e_test.go
  • tests/integration/group_f_test.go
  • tests/integration/group_h_test.go
  • tests/integration/group_i_test.go
  • tests/operator-harness/replay/rd-sp-unwhitelisted-drbd-option-rejected.yaml
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parity part matches LINSTOR v1.33.2. CtrlPropsHelper.fillProperties refuses a known key with a bad value as Invalid property(<key>) value: <value> with the rule in details, and an unknown key as Invalid property key: <key> / The key '<key>' is not whitelisted. (CtrlPropsHelper.java:613-630). WhitelistProps.isAllowed passes a null value, the delete (WhitelistProps.java:294-325), and normalize stores the canonical form (334-342). The REST and CLI wiring judges only the keys a request sets, and the upgrade note covers the linstor-csi StorageClass case. My one blocker is licensing, inline.

I know the tree already has third_party/linstor-common as a submodule and a hand port of drbdoptions entries in pkg/drbd/options.go. If linstor-common data is meant to be acceptable input, that exception belongs in AGENTS.md, so the rule matches what the code does.

@@ -0,0 +1,845 @@
{
"source": "linstor-common 64240e34a6e2 (linstor-server v1.33.1)",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is generated by a tool from properties.json and drbdoptions.json in linstor-common, the submodule of the GPLv3 linstor-server. linstor-common has no license file of its own, and its genproperties.py stamps GPLv3 on what it generates. AGENTS.md lists "no GPL artifacts may enter the tree" as a hard rule, including any GPL-marked spec file and "code generated from a GPL source by any tool". Committing this output plus hack/gen-drbd-whitelist reads as exactly that case. Please either derive the rules clean-room (the drbdsetup man pages are on the safe list), or record an explicit exception for linstor-common data in AGENTS.md in this PR, so the rule and the tree agree.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took the second option: 8a829da records the exception in AGENTS.md, next to the GPL rule, so the rule and the tree agree. It is narrow. A tool may read drbdoptions.json and properties.json from third_party/linstor-common as data and carry over only the interface facts a client depends on: key names, value types, enum values, ranges and units. Nothing else crosses: no descriptions or help text, no code, no comments, and nothing genproperties.py writes under its GPLv3 stamp, GeneratedPropertyRules.java included. A file built this way names its linstor-common commit.

drbdoptions.json itself is gendrbdoptions.py output over drbdsetup xml-help, so it holds the same facts as the drbdsetup man pages. The generated pkg/propwhitelist/drbdoptions.json keeps a type and the bounds per key and nothing more (no description field), and its source names linstor-common 64240e34a6e2. The same exception also covers the existing submodule and the hand port in pkg/drbd/options.go.

The licensing rules forbid anything generated from a GPL source, yet
the tree already reads linstor-common: the submodule, the hand port in
pkg/drbd/options.go and now the generated DrbdOptions whitelist. The
rule and the tree have to agree.

Record the exception narrowly. drbdoptions.json is gendrbdoptions.py
output over drbdsetup xml-help, the same facts the drbdsetup man pages
carry, and properties.json lists LINSTOR's accepted keys. Only those
interface facts may cross: key names, types, enum values, ranges and
units. Descriptions, code and everything genproperties.py writes under
its GPLv3 stamp stay out.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
@kvaps

Copy link
Copy Markdown
Member Author

Thanks for checking the parity against CtrlPropsHelper and WhitelistProps. The licensing point is answered inline, with the exception in AGENTS.md (8a829da). I also merged main into the branch in 30d59d6 (a normal merge); the conflicts were the imports in internal/cli/handlers.go, a changelog line in docs/cli-parity-known-deltas.md and the witness hold next to the whitelist check in createResources, and both sides are kept.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AGENTS.md exception answers my licensing point, and the committed drbdoptions.json stays inside it: only types, ranges, units and enum values, with the linstor-common commit named in source. The merge of main keeps the whitelist refusal ahead of the new witness hold in createResources, so a refused request returns before taking the hold. The red unit tests fail the same way on main.

The only conflict was the import block of internal/cli/handlers.go,
where main added pkg/naming next to this branch's pkg/propwhitelist;
both are kept.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I compared this head with the one I approved at 30d59d6. The patch is the same apart from one blank line; the rest is the merge of main.

@kvaps
Andrei Kvapil (kvaps) merged commit 65f3a2d into main Nov 24, 2026
16 checks passed
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.

2 participants