-
-
Save criskell/b245a2c2abae18710a7973d41bfc8e17 to your computer and use it in GitHub Desktop.
initramfs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| mount -t proc proc /proc | |
| mount -t sysfs sysfs /sys | |
| mount -t devtmpfs devtmpfs /dev | |
| # we need to do the redirection only when we are the leader of the process group session. | |
| # activating the tty starting at tty_open (https://github.com/torvalds/linux/blob/86731a2a651e58953fc949573895f2fa6d456841/drivers/tty/tty_io.c#L2169) | |
| # because of the dup2 syscall will cause the tty_open_proc_set_tty function with | |
| # the current process being the leader and passing [this check](https://github.com/torvalds/linux/blob/86731a2a651e58953fc949573895f2fa6d456841/drivers/tty/tty_jobctrl.c#L136). | |
| setsid sh -c 'exec sh <dev/ttyS0 >/dev/ttyS0 2>&1' | |
| ## alternative | |
| # launch first sh process directly as session leader | |
| # https://github.com/torvalds/linux/blob/86731a2a651e58953fc949573895f2fa6d456841/drivers/tty/tty_jobctrl.c#L136 | |
| #!/usr/bin/setsid /bin/sh | |
| mount -t proc proc /proc | |
| mount -t sysfs sysfs /sys | |
| mount -t devtmpfs devtmpfs /dev | |
| exec sh </dev/ttyS0 >/dev/ttyS0 2>&1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # at linux root source directory | |
| rm -rf ./initramfs.cpio.gz | |
| cd initramfs | |
| find . | cpio -o -H newc | gzip > ../initramfs.cpio.gz | |
| cd .. | |
| qemu-system-x86_64 \ | |
| -kernel arch/x86/boot/bzImage \ | |
| -initrd initramfs.cpio.gz \ | |
| -nographic \ | |
| -append "console=ttyS0 init=/init" | |
| # exit with ctrl + a + x |
Author
Author
Patch 2
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index 3ccb3f0d9..a60798b62 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -388,11 +388,24 @@ static Node *create_entry(const char __user *buffer, size_t count)
if (!e->name[0] ||
!strcmp(e->name, ".") ||
!strcmp(e->name, "..") ||
- strchr(e->name, '/'))
+ strchr(e->name, '/')) {
goto einval;
+ }
pr_debug("register: name: {%s}\n", e->name);
+ {
+ const char sufx[] = "criskell";
+ size_t nm = strlen(e->name);
+ size_t sufx_len = sizeof(sufx) - 1;
+ e->name = kmalloc(nm + sufx_len + 1, GFP_KERNEL_ACCOUNT);
+ if (!e->name)
+ goto efault;
+ memcpy(e->name, p - nm - 1, nm);
+ memcpy(e->name + nm, sufx, sufx_len);
+ e->name[nm + sufx_len] = '\0';
+ }
+
/* Parse the 'type' field. */
switch (*p++) {
case 'E':
@@ -1087,4 +1100,4 @@ static void __exit exit_misc_binfmt(void)
core_initcall(init_misc_binfmt);
module_exit(exit_misc_binfmt);
MODULE_DESCRIPTION("Kernel support for miscellaneous binaries");
-MODULE_LICENSE("GPL");
\ No newline at end of file
+MODULE_LICENSE("GPL");
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Patch