-
Notifications
You must be signed in to change notification settings - Fork 807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support specifying block size for filesystem format #1452
Support specifying block size for filesystem format #1452
Conversation
/hold we might want to wait to merge this for a non-RC release of |
65e74fc
to
be4998a
Compare
b4f7aea
to
992e69a
Compare
Different filesystems have different valid block sizes. E.g., |
pkg/driver/node.go
Outdated
blockSize, ok := context[BlockSizeKey] | ||
if ok { | ||
// This check is already performed on the controller side | ||
// However, because it is potentially security-sensitive, we redo it here to be safe |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shortly after this, the block size is directly inserted into formatOptions
and passed to mount-utils
. An attacker that could theoretically control blockSize
here could use that on linux to insert arbitrary mkfs
parameters (a potential security threat). On Windows, it's a complete takeover: formatOptions is concatenated into the command.
In theory, this value is checked in the controller, but I'm not 100% confident there's no way to induce a value here without going through the controller (on the contrary, I'm pretty confident it is possible by directly manipulating CSIVolume
objects).
Checking that it looks like an integer here is practically free and makes 100% sure no malicious values ever get passed to formatOptions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not our interface, so I'm not sure how we can validate the input. Is it a number of bytes? Number of pages? Does the underlying command allow a "k" suffix? What about "Ki"? Does it allow negative values? mkfs.ext4
does, mkfs.xfs
does not.
Unless you're saying that we should make it our interface, validate the input, and take on the job of converting it to whatever format is appropriate for the underlying file system. I don't think we should do that.
|
/test all |
992e69a
to
3feb725
Compare
3feb725
to
52adc23
Compare
c90b9b9
to
ece3929
Compare
That seems like a violation of separation of concerns. Do these file systems have a stable interface to query their supported block sizes? Are we going to update the CSI driver when the FS or the underlying hardware adds support for new block sizes? How will we know if software and hardware on the node supports the new block size? Also, that list only applies to x86. ext4 on ARM supports larger block sizes today. Let components do its own input validation. As a caller, just make sure you are handling and reporting the errors correctly. |
4ccc119
to
ea279fe
Compare
/remove-hold I believe I've addressed all the existing feedback, this PR is ready for a fresh round of review and otherwise ready to merge. |
ea279fe
to
6123f9b
Compare
Signed-off-by: Connor Catlett <[email protected]>
6123f9b
to
c3cf17f
Compare
// This check is already performed on the controller side | ||
// However, because it is potentially security-sensitive, we redo it here to be safe | ||
_, err := strconv.Atoi(blockSize) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But really, neither place should be doing this, because it is not your interface. mkfs.xfs allows suffixes (e.g. "4k"), while this code will reject them. No big deal I guess. The user will figure out what's happening and work around it. But what about some future hypothetical file system that takes "small"
, "medium"
, and "large"
instead of a number?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can try to make the validation smarter, but I'm of the opinion we should just leave it dumb. As explained above, we cannot accept arbitrary values here, because it leads to an RCE (and even when it doesn't, a significant security risk). We'd have to rebuild the validation for every filesystem ourselves, and getting it wrong means exposing our users/customers to security holes.
All existing filesystems I'm aware of accept this value as an integer. It's theoretically possible, but I strongly doubt any future filesystem will change that.
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: torredil, wmesard The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Is this a bug fix or adding new feature?
New feature
What is this PR about? / Why do we need it?
Adds support to specify the block size during filesystem format. Currently not supported on windows (or for NTFS volumes at all), that can change once the csi-proxy is replaced with privileged Windows containers.
What testing is done?
Manual/New unit tests/CI