Skip to content

CON-4645: fsRepair param does not validate the input and no error is reported, silently applies any values input#536

Open
rashi-jain1 wants to merge 4 commits into
hpe-storage:masterfrom
rashi-jain1:CON-4645
Open

CON-4645: fsRepair param does not validate the input and no error is reported, silently applies any values input#536
rashi-jain1 wants to merge 4 commits into
hpe-storage:masterfrom
rashi-jain1:CON-4645

Conversation

@rashi-jain1

Copy link
Copy Markdown
Contributor

BUG Link : https://jira.storage.hpecorp.net/browse/CON-4645

BUG Description: fsRepair param does not validate the input and no error is reported, silently applies any values input

BUG Fix :
Added a new validateFsRepairParameter() function that rejects any invalid value of fsRepair that is not exactly "true" or "false" (lowercase only)
Attached Logs on JIRA.

…reported, silently applies any values input

Signed-off-by: Rashi Jain <rashi.jain@hpe.com>
Comment thread pkg/driver/node_server.go Outdated
// Validate fsRepair value from volumeContext -- catches PVs that may have been
// created before this validation existed and have an invalid (non-boolean) value.
if fsRepairVal := volumeContext[fsRepairKey]; fsRepairVal != "" && fsRepairVal != trueKey && fsRepairVal != falseKey {
return nil, fmt.Errorf("invalid value %q for fsRepair parameter on volume %s, it must be either [true, false] (lowercase only)", fsRepairVal, volumeID)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We need to return the gRPC error code InvalidArgument here. But the issue is that the NodeStageVolume masks all the error codes into codes.Internal when responding to the CO. We should change this function and the calling function and fix it so that NodeStageVolume can pass err and the actual gRPC error code is prepared in the nodeStageVolume function. Please check the pattern used in NodeUnstageVolume/nodeUnstageVolume.

While you are changing this, please also fix the same in line no: 763, 771, 777

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Signed-off-by: Rashi Jain <rashi.jain@hpe.com>
Comment thread pkg/driver/node_server.go Outdated
mountInfo := getMountInfo(volumeID, volCap, publishContext, stagingMountPoint)

// Validate fsRepair value from volumeContext -- catches PVs that may have been
// created before this validation existed and have an invalid (non-boolean) value.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If there are customers who had configured this incorrectly before and without this check, it was working without throwing errors, adding this check will cause unnecessary regressions. I dont think, we should have this check.

CC: @dileepds , @datamattsson

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So, shall I remove this check?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yes, please remove this check.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment thread pkg/driver/node_server.go
if err != nil {
log.Errorln(err.Error())
return err
return status.Errorf(codes.Internal, "failed to retrieve encryption passphrase for volume: %s", err.Error())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

the issues also exist at line no: 211, 269, 305, 450, 486, 490, 506, 512, 515, 518. Please change these as well.
Also at line no: 252(isVolumeStaged already add a proper error code) no change needed.
Once you fix the above and add proper error codes in the stageVolume function, you should remove the error code masking at line no: 297.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added.

Signed-off-by: Rashi Jain <rashi.jain@hpe.com>
Comment thread pkg/driver/node_server_test.go Outdated
}
}

func contains(s, substr string) bool {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

string module already has function for both contains and containsSubstring, why are we adding our own code. please remove these functions and use the inbuilt string functions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@datamattsson datamattsson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Besides my comment, can we validate "nfsResources" and "hostEncryption" the same way as they are string booleans too.

Comment thread pkg/driver/controller_server.go Outdated

// validateFsRepairParameter validates that the fsRepair StorageClass parameter,
// if specified, is strictly "true" or "false" (lowercase only).
func (driver *Driver) validateFsRepairParameter(createParameters map[string]string) error {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we use a generic library for boolean string validation instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done. Added validation for "nfsResources" and for "hostEncryption" we're already validating by "validateHostEncryptionParameters"

Signed-off-by: Rashi Jain <rashi.jain@hpe.com>
@rashi-jain1 rashi-jain1 requested a review from datamattsson June 22, 2026 06:20

@dileepds dileepds left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

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.

4 participants