Skip to content

Commit

Permalink
[vpsAdminOS] procfs: fake uid_map for Docker v2
Browse files Browse the repository at this point in the history
Docker detects, whether it runs in an User namespace and when it does, it acts
whacky, the code is full of bugs.

So let's fake what Docker sees, so it thinks it doesn't run in userns.

v2:
- fix memleak (exe)
- no warn anymore

Signed-off-by: Pavel Snajdr <snajpa@snajpa.net>
  • Loading branch information
snajpa committed Jun 1, 2024
1 parent cfd4a79 commit fb383dc
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions kernel/user_namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,27 @@ static void *m_start(struct seq_file *seq, loff_t *ppos,
static void *uid_m_start(struct seq_file *seq, loff_t *ppos)
{
struct user_namespace *ns = seq->private;
struct file *exe = get_task_exe_file(current);
char buff[1024];
char *p = NULL;
int pathlen = 0;
bool fake = false;

if (((ns == &init_user_ns) || (ns->parent == &init_user_ns)) &&
(exe)) {
p = d_path(&exe->f_path, buff, 1024);
pathlen = strnlen(p, 1024);

if (strncmp(p + pathlen - 11, "bin/dockerd", 11) == 0)
fake = true;

}

if (exe)
fput(exe);

if (fake)
return NULL;

return m_start(seq, ppos, &ns->uid_map);
}
Expand Down

0 comments on commit fb383dc

Please sign in to comment.