Skip to content
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

Skip directories and symlinks when mounting libraries #282

Merged
merged 1 commit into from
Sep 17, 2024

Conversation

elezar
Copy link
Member

@elezar elezar commented Sep 11, 2024

This ensures that only actual libraries from the compat folders are mounted into the container.

If symlinks or directories are detected an error is raised.

@elezar elezar self-assigned this Sep 11, 2024
src/nvc_container.c Outdated Show resolved Hide resolved
src/utils.c Outdated Show resolved Hide resolved
src/nvc_mount.c Outdated Show resolved Hide resolved
src/xfuncs.h Outdated Show resolved Hide resolved
src/utils.c Outdated Show resolved Hide resolved
@cdesiniotis
Copy link

LGTM besides the one nit.

This ensures that only actual libraries from the compat folders are
mounted into the container.

Signed-off-by: Evan Lezar <[email protected]>
@elezar elezar force-pushed the skip-directories-and-symlinks branch from db63f0e to ad1f8c8 Compare September 17, 2024 10:05
@elezar elezar merged commit d7dc76b into NVIDIA:main Sep 17, 2024
3 checks passed
@elezar elezar deleted the skip-directories-and-symlinks branch September 17, 2024 19:34
@@ -28,6 +28,7 @@ static char **mount_files(struct error *, const char *, const struct nvc_contain
static char **mount_driverstore_files(struct error *, const char *, const struct nvc_container *, const char *, const char *[], size_t);
static char *mount_directory(struct error *, const char *, const struct nvc_container *, const char *);
static char *mount_firmware(struct error *, const char *, const struct nvc_container *, const char *);
static char *mount_in_root(struct error *err, const char *src, const char *rootfs, const char *path, uid_t uid, uid_t gid, unsigned long mountflags);
Copy link
Contributor

Choose a reason for hiding this comment

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

For consistency, we shouldn't have the variable names here.

@@ -28,6 +28,7 @@ static char **mount_files(struct error *, const char *, const struct nvc_contain
static char **mount_driverstore_files(struct error *, const char *, const struct nvc_container *, const char *, const char *[], size_t);
static char *mount_directory(struct error *, const char *, const struct nvc_container *, const char *);
static char *mount_firmware(struct error *, const char *, const struct nvc_container *, const char *);
static char *mount_in_root(struct error *err, const char *src, const char *rootfs, const char *path, uid_t uid, uid_t gid, unsigned long mountflags);
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider renaming to mount_at_with_flags()

Comment on lines 53 to 54
if (path_join(err, src, root, dir) < 0)
return (NULL);
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider changing this to path_resolve_full() to be symmetrical with what we now do in mount_firmware().

return (NULL);
return mount_with_flags(err, src, dst, cnt->uid, cnt->gid, MS_RDONLY|MS_NODEV|MS_NOSUID);
return mount_with_flags(err, src, dst, uid, gid, mountflags);
Copy link
Contributor

Choose a reason for hiding this comment

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

If we can, let's just fold the logic for mount_with_flags() in here.

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.

3 participants