mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-13 18:02:40 +00:00
Merge pull request #4245 from MaherAzzouzi/master
Patching an incoming CVE (CVE-2022-47952)
This commit is contained in:
commit
1b25a401b7
@ -1085,20 +1085,17 @@ int main(int argc, char *argv[])
|
|||||||
} else if (request == LXC_USERNIC_DELETE) {
|
} else if (request == LXC_USERNIC_DELETE) {
|
||||||
char opath[LXC_PROC_PID_FD_LEN];
|
char opath[LXC_PROC_PID_FD_LEN];
|
||||||
|
|
||||||
/* Open the path with O_PATH which will not trigger an actual
|
// Keep in mind CVE-2022-47952: It's crucial not to leak any
|
||||||
* open(). Don't report an errno to the caller to not leak
|
// information whether open() succeeded of failed.
|
||||||
* information whether the path exists or not.
|
|
||||||
* When stracing setuid is stripped so this is not a concern
|
|
||||||
* either.
|
|
||||||
*/
|
|
||||||
netns_fd = open(args.pid, O_PATH | O_CLOEXEC);
|
netns_fd = open(args.pid, O_PATH | O_CLOEXEC);
|
||||||
if (netns_fd < 0) {
|
if (netns_fd < 0) {
|
||||||
usernic_error("Failed to open \"%s\"\n", args.pid);
|
usernic_error("Failed while opening netns file for \"%s\"\n", args.pid);
|
||||||
_exit(EXIT_FAILURE);
|
_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fhas_fs_type(netns_fd, NSFS_MAGIC)) {
|
if (!fhas_fs_type(netns_fd, NSFS_MAGIC)) {
|
||||||
usernic_error("Path \"%s\" does not refer to a network namespace path\n", args.pid);
|
usernic_error("Failed while opening netns file for \"%s\"\n", args.pid);
|
||||||
close(netns_fd);
|
close(netns_fd);
|
||||||
_exit(EXIT_FAILURE);
|
_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@ -1112,7 +1109,7 @@ int main(int argc, char *argv[])
|
|||||||
/* Now get an fd that we can use in setns() calls. */
|
/* Now get an fd that we can use in setns() calls. */
|
||||||
ret = open(opath, O_RDONLY | O_CLOEXEC);
|
ret = open(opath, O_RDONLY | O_CLOEXEC);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
CMD_SYSERROR("Failed to open \"%s\"\n", args.pid);
|
CMD_SYSERROR("Failed while opening netns file for \"%s\"\n", args.pid);
|
||||||
close(netns_fd);
|
close(netns_fd);
|
||||||
_exit(EXIT_FAILURE);
|
_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user