Skip to content

Commit

Permalink
Revert "proc: Remove SafetyNet flags from /proc/cmdline"
Browse files Browse the repository at this point in the history
This reverts commit 72b4c7d.

Signed-off-by: Khusika Dhamar Gusti <mail@khusika.com>
  • Loading branch information
Khusika Dhamar Gusti committed Aug 22, 2021
1 parent 47889c5 commit d975985
Showing 1 changed file with 1 addition and 32 deletions.
33 changes: 1 addition & 32 deletions fs/proc/cmdline.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@
#include <linux/init.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <asm/setup.h>

static char new_command_line[COMMAND_LINE_SIZE];

static int cmdline_proc_show(struct seq_file *m, void *v)
{
seq_printf(m, "%s\n", new_command_line);
seq_printf(m, "%s\n", saved_command_line);
return 0;
}

Expand All @@ -24,36 +21,8 @@ static const struct file_operations cmdline_proc_fops = {
.release = single_release,
};

static void remove_flag(char *cmd, const char *flag)
{
char *start_addr, *end_addr;

/* Ensure all instances of a flag are removed */
while ((start_addr = strstr(cmd, flag))) {
end_addr = strchr(start_addr, ' ');
if (end_addr)
memmove(start_addr, end_addr + 1, strlen(end_addr));
else
*(max(cmd, start_addr - 1)) = '\0';
}
}

static void remove_safetynet_flags(char *cmd)
{
remove_flag(cmd, "androidboot.verifiedbootstate=");
remove_flag(cmd, "androidboot.veritymode=");
}

static int __init proc_cmdline_init(void)
{
strcpy(new_command_line, saved_command_line);

/*
* Remove various flags from command line seen by userspace in order to
* pass SafetyNet CTS check.
*/
remove_safetynet_flags(new_command_line);

proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
return 0;
}
Expand Down

0 comments on commit d975985

Please sign in to comment.