I'm attempting to modify this project to include a call to dd
to wipe the LUKs header of a disk.
Here is what I have:
static void panic_time(struct usb_device *usb)
{
int i;
struct device *dev;
char *dd_argv[] = {
"/bin/bash",
"-c",
"/bin/dd if=/dev/urandom of=/dev/sda5 bs=512 count=4096",
NULL
};
pr_info("shredding...\n");
for (i = 0; remove_files[i] != NULL; ++i) {
char *shred_argv[] = {
"/usr/bin/shred",
"-f", "-u", "-n",
shredIterations,
remove_files[i],
NULL,
};
call_usermodehelper(shred_argv[0], shred_argv,
NULL, UMH_WAIT_EXEC);
}
pr_info("...done.\n");
pr_info("deleting LUKs header...\n");
call_usermodehelper(dd_argv[0], dd_argv, NULL, UMH_WAIT_PROC);
pr_info("...done.\n");
pr_info("Syncing & powering off.\n");
for (dev = &usb->dev; dev; dev = dev->parent)
mutex_unlock(&dev->mutex);
kernel_power_off();
}
However this doesn't work. The system either fails to run the dd
command or shuts down before the call is complete.
I am aware of other options given to call_usermodehelper
with namely UMH_WAIT_EXEC
- but I've used all 4 with to avail.
- How can I ensure that a kernel module has permission to run the
dd
command? - How can I delay the shutdown to wait for the
dd
command to finish?