hashicorp / nomad

Nomad is an easy-to-use, flexible, and performant workload orchestrator that can deploy a mix of microservice, batch, containerized, and non-containerized applications. Nomad is easy to operate and scale and has native Consul and Vault integrations.
https://www.nomadproject.io/
Other
14.87k stars 1.95k forks source link

[CSI] Do not allow stage_publish_base_dir to be a sub-directory of mount_dir #19440

Closed ggriffiths closed 10 months ago

ggriffiths commented 10 months ago

Nomad version

Any nomad version 1.3.0 or greater

Operating system and Environment details

Any OS

Issue

If a CSI plugin uses mount_dir = /var/lib/test and stage_publish_base_dir = /var/lib/test/publish, then this line will cause all mount points and underlying data to be at risk: https://github.com/hashicorp/nomad/blob/v1.3.0/client/allocrunner/taskrunner/plugin_supervisor_hook.go#L427-L430

Reproduction steps

Use mount_dir = /var/lib/test and stage_publish_base_dir = /var/lib/test/publish for any CSI driver, and the mount point will not resolve properly and data could be at risk on CSI Plugin restart.

Expected Result

CSI Plugin Stanza validation should fail if stage_publish_base_dir is inside of mount_dir

Actual Result

CSI plugin stanza validation succeeds

Job file (if appropriate)

n/a - CSI plugin and job configuration

Nomad Server logs (if appropriate)

n/a

Nomad Client logs (if appropriate)

n/a

tgross commented 10 months ago

Hi @ggriffiths! This makes sense to me. I've reviewed your PR and made some comments.

tgross commented 10 months ago

19441 has been merged and will ship in Nomad 1.7.2 (plus backports to 1.6 and 1.5)

ggriffiths commented 10 months ago

Thank you @tgross !