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

[ENHANCEMENT] introduce secure way of handling files #28

Open
ktanska opened this issue Jun 20, 2024 · 2 comments
Open

[ENHANCEMENT] introduce secure way of handling files #28

ktanska opened this issue Jun 20, 2024 · 2 comments

Comments

@ktanska
Copy link
Collaborator

ktanska commented Jun 20, 2024

Files opened by mdadm should be securely open. One (bad) example is check_one_sharer() function. The problem is that fopen does not put the lock on the file/path.
After opening the file, one can do following things:

  • alter or delete the file,

  • delete /run/mdadm and make it a soft link to another directory containing file with same name

Goal here is to analyze it and fix this issue globally so 3rd party access to the file is locked. Probably, this can be achieved with fstat.

In current implementation, opened file value is stored locally, messing with the file does not change its stored value.
Proposed scenario:

  1. Lock file (and path)
  2. Run checks
  3. Open file
@ktanska
Copy link
Collaborator Author

ktanska commented Aug 12, 2024

Process files can be used here to see if file is not removed or changed to another:
image

@ncroxon
Copy link
Collaborator

ncroxon commented Dec 9, 2024

Not all files need to be locked. Some inside /sys/block/mdx/md/ can be modified.

otherwise, immutable will work:
if (ioctl(fd, FS_IOC_GETFLAGS, &flags) == -1) {
perror("ioctl get flags");
return 1;
}

flags |= FS_IMMUTABLE_FL;
if (ioctl(fd, FS_IOC_SETFLAGS, &flags) == -1) {
perror("ioctl set flags");
return 1;
}

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

No branches or pull requests

2 participants