summaryrefslogtreecommitdiffstats
path: root/init
diff options
context:
space:
mode:
Diffstat (limited to 'init')
-rw-r--r--init/Kconfig2
-rw-r--r--init/do_mounts.c271
-rw-r--r--init/init_task.c4
-rw-r--r--init/initramfs.c2
-rw-r--r--init/main.c16
-rw-r--r--init/version.c2
6 files changed, 144 insertions, 153 deletions
diff --git a/init/Kconfig b/init/Kconfig
index 0872a5a2e759..b77c60f8b963 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -114,7 +114,7 @@ config INIT_ENV_ARG_LIMIT
config COMPILE_TEST
bool "Compile also drivers which will not load"
- depends on !UML
+ depends on !UML && !S390
default n
help
Some drivers can be compiled on a different platform than they are
diff --git a/init/do_mounts.c b/init/do_mounts.c
index b5f9604d0c98..a78e44ee6adb 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -76,21 +76,15 @@ struct uuidcmp {
*/
static int match_dev_by_uuid(struct device *dev, const void *data)
{
+ struct block_device *bdev = dev_to_bdev(dev);
const struct uuidcmp *cmp = data;
- struct hd_struct *part = dev_to_part(dev);
-
- if (!part->info)
- goto no_match;
-
- if (strncasecmp(cmp->uuid, part->info->uuid, cmp->len))
- goto no_match;
+ if (!bdev->bd_meta_info ||
+ strncasecmp(cmp->uuid, bdev->bd_meta_info->uuid, cmp->len))
+ return 0;
return 1;
-no_match:
- return 0;
}
-
/**
* devt_from_partuuid - looks up the dev_t of a partition by its UUID
* @uuid_str: char array containing ascii UUID
@@ -106,13 +100,10 @@ no_match:
*/
static dev_t devt_from_partuuid(const char *uuid_str)
{
- dev_t res = 0;
struct uuidcmp cmp;
struct device *dev = NULL;
- struct gendisk *disk;
- struct hd_struct *part;
+ dev_t devt = 0;
int offset = 0;
- bool clear_root_wait = false;
char *slash;
cmp.uuid = uuid_str;
@@ -121,52 +112,49 @@ static dev_t devt_from_partuuid(const char *uuid_str)
/* Check for optional partition number offset attributes. */
if (slash) {
char c = 0;
+
/* Explicitly fail on poor PARTUUID syntax. */
- if (sscanf(slash + 1,
- "PARTNROFF=%d%c", &offset, &c) != 1) {
- clear_root_wait = true;
- goto done;
- }
+ if (sscanf(slash + 1, "PARTNROFF=%d%c", &offset, &c) != 1)
+ goto clear_root_wait;
cmp.len = slash - uuid_str;
} else {
cmp.len = strlen(uuid_str);
}
- if (!cmp.len) {
- clear_root_wait = true;
- goto done;
- }
+ if (!cmp.len)
+ goto clear_root_wait;
- dev = class_find_device(&block_class, NULL, &cmp,
- &match_dev_by_uuid);
+ dev = class_find_device(&block_class, NULL, &cmp, &match_dev_by_uuid);
if (!dev)
- goto done;
-
- res = dev->devt;
+ return 0;
- /* Attempt to find the partition by offset. */
- if (!offset)
- goto no_offset;
+ if (offset) {
+ /*
+ * Attempt to find the requested partition by adding an offset
+ * to the partition number found by UUID.
+ */
+ struct block_device *part;
- res = 0;
- disk = part_to_disk(dev_to_part(dev));
- part = disk_get_part(disk, dev_to_part(dev)->partno + offset);
- if (part) {
- res = part_devt(part);
- put_device(part_to_dev(part));
+ part = bdget_disk(dev_to_disk(dev),
+ dev_to_bdev(dev)->bd_partno + offset);
+ if (part) {
+ devt = part->bd_dev;
+ bdput(part);
+ }
+ } else {
+ devt = dev->devt;
}
-no_offset:
put_device(dev);
-done:
- if (clear_root_wait) {
- pr_err("VFS: PARTUUID= is invalid.\n"
- "Expected PARTUUID=<valid-uuid-id>[/PARTNROFF=%%d]\n");
- if (root_wait)
- pr_err("Disabling rootwait; root= is invalid.\n");
- root_wait = 0;
- }
- return res;
+ return devt;
+
+clear_root_wait:
+ pr_err("VFS: PARTUUID= is invalid.\n"
+ "Expected PARTUUID=<valid-uuid-id>[/PARTNROFF=%%d]\n");
+ if (root_wait)
+ pr_err("Disabling rootwait; root= is invalid.\n");
+ root_wait = 0;
+ return 0;
}
/**
@@ -178,15 +166,90 @@ done:
*/
static int match_dev_by_label(struct device *dev, const void *data)
{
+ struct block_device *bdev = dev_to_bdev(dev);
const char *label = data;
- struct hd_struct *part = dev_to_part(dev);
- if (part->info && !strcmp(label, part->info->volname))
- return 1;
+ if (!bdev->bd_meta_info || strcmp(label, bdev->bd_meta_info->volname))
+ return 0;
+ return 1;
+}
+
+static dev_t devt_from_partlabel(const char *label)
+{
+ struct device *dev;
+ dev_t devt = 0;
- return 0;
+ dev = class_find_device(&block_class, NULL, label, &match_dev_by_label);
+ if (dev) {
+ devt = dev->devt;
+ put_device(dev);
+ }
+
+ return devt;
+}
+
+static dev_t devt_from_devname(const char *name)
+{
+ dev_t devt = 0;
+ int part;
+ char s[32];
+ char *p;
+
+ if (strlen(name) > 31)
+ return 0;
+ strcpy(s, name);
+ for (p = s; *p; p++) {
+ if (*p == '/')
+ *p = '!';
+ }
+
+ devt = blk_lookup_devt(s, 0);
+ if (devt)
+ return devt;
+
+ /*
+ * Try non-existent, but valid partition, which may only exist after
+ * opening the device, like partitioned md devices.
+ */
+ while (p > s && isdigit(p[-1]))
+ p--;
+ if (p == s || !*p || *p == '0')
+ return 0;
+
+ /* try disk name without <part number> */
+ part = simple_strtoul(p, NULL, 10);
+ *p = '\0';
+ devt = blk_lookup_devt(s, part);
+ if (devt)
+ return devt;
+
+ /* try disk name without p<part number> */
+ if (p < s + 2 || !isdigit(p[-2]) || p[-1] != 'p')
+ return 0;
+ p[-1] = '\0';
+ return blk_lookup_devt(s, part);
+}
+#endif /* CONFIG_BLOCK */
+
+static dev_t devt_from_devnum(const char *name)
+{
+ unsigned maj, min, offset;
+ dev_t devt = 0;
+ char *p, dummy;
+
+ if (sscanf(name, "%u:%u%c", &maj, &min, &dummy) == 2 ||
+ sscanf(name, "%u:%u:%u:%c", &maj, &min, &offset, &dummy) == 3) {
+ devt = MKDEV(maj, min);
+ if (maj != MAJOR(devt) || min != MINOR(devt))
+ return 0;
+ } else {
+ devt = new_decode_dev(simple_strtoul(name, &p, 16));
+ if (*p)
+ return 0;
+ }
+
+ return devt;
}
-#endif
/*
* Convert a name into device number. We accept the following variants:
@@ -218,101 +281,23 @@ static int match_dev_by_label(struct device *dev, const void *data)
* name contains slashes, the device name has them replaced with
* bangs.
*/
-
dev_t name_to_dev_t(const char *name)
{
- char s[32];
- char *p;
- dev_t res = 0;
- int part;
-
+ if (strcmp(name, "/dev/nfs") == 0)
+ return Root_NFS;
+ if (strcmp(name, "/dev/cifs") == 0)
+ return Root_CIFS;
+ if (strcmp(name, "/dev/ram") == 0)
+ return Root_RAM0;
#ifdef CONFIG_BLOCK
- if (strncmp(name, "PARTUUID=", 9) == 0) {
- name += 9;
- res = devt_from_partuuid(name);
- if (!res)
- goto fail;
- goto done;
- } else if (strncmp(name, "PARTLABEL=", 10) == 0) {
- struct device *dev;
-
- dev = class_find_device(&block_class, NULL, name + 10,
- &match_dev_by_label);
- if (!dev)
- goto fail;
-
- res = dev->devt;
- put_device(dev);
- goto done;
- }
+ if (strncmp(name, "PARTUUID=", 9) == 0)
+ return devt_from_partuuid(name + 9);
+ if (strncmp(name, "PARTLABEL=", 10) == 0)
+ return devt_from_partlabel(name + 10);
+ if (strncmp(name, "/dev/", 5) == 0)
+ return devt_from_devname(name + 5);
#endif
-
- if (strncmp(name, "/dev/", 5) != 0) {
- unsigned maj, min, offset;
- char dummy;
-
- if ((sscanf(name, "%u:%u%c", &maj, &min, &dummy) == 2) ||
- (sscanf(name, "%u:%u:%u:%c", &maj, &min, &offset, &dummy) == 3)) {
- res = MKDEV(maj, min);
- if (maj != MAJOR(res) || min != MINOR(res))
- goto fail;
- } else {
- res = new_decode_dev(simple_strtoul(name, &p, 16));
- if (*p)
- goto fail;
- }
- goto done;
- }
-
- name += 5;
- res = Root_NFS;
- if (strcmp(name, "nfs") == 0)
- goto done;
- res = Root_CIFS;
- if (strcmp(name, "cifs") == 0)
- goto done;
- res = Root_RAM0;
- if (strcmp(name, "ram") == 0)
- goto done;
-
- if (strlen(name) > 31)
- goto fail;
- strcpy(s, name);
- for (p = s; *p; p++)
- if (*p == '/')
- *p = '!';
- res = blk_lookup_devt(s, 0);
- if (res)
- goto done;
-
- /*
- * try non-existent, but valid partition, which may only exist
- * after revalidating the disk, like partitioned md devices
- */
- while (p > s && isdigit(p[-1]))
- p--;
- if (p == s || !*p || *p == '0')
- goto fail;
-
- /* try disk name without <part number> */
- part = simple_strtoul(p, NULL, 10);
- *p = '\0';
- res = blk_lookup_devt(s, part);
- if (res)
- goto done;
-
- /* try disk name without p<part number> */
- if (p < s + 2 || !isdigit(p[-2]) || p[-1] != 'p')
- goto fail;
- p[-1] = '\0';
- res = blk_lookup_devt(s, part);
- if (res)
- goto done;
-
-fail:
- return 0;
-done:
- return res;
+ return devt_from_devnum(name);
}
EXPORT_SYMBOL_GPL(name_to_dev_t);
diff --git a/init/init_task.c b/init/init_task.c
index a56f0abb63e9..8a992d73e6fb 100644
--- a/init/init_task.c
+++ b/init/init_task.c
@@ -26,7 +26,7 @@ static struct signal_struct init_signals = {
.multiprocess = HLIST_HEAD_INIT,
.rlim = INIT_RLIMITS,
.cred_guard_mutex = __MUTEX_INITIALIZER(init_signals.cred_guard_mutex),
- .exec_update_mutex = __MUTEX_INITIALIZER(init_signals.exec_update_mutex),
+ .exec_update_lock = __RWSEM_INITIALIZER(init_signals.exec_update_lock),
#ifdef CONFIG_POSIX_TIMERS
.posix_timers = LIST_HEAD_INIT(init_signals.posix_timers),
.cputimer = {
@@ -176,7 +176,7 @@ struct task_struct init_task
.numa_group = NULL,
.numa_faults = NULL,
#endif
-#ifdef CONFIG_KASAN
+#if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)
.kasan_depth = 1,
#endif
#ifdef CONFIG_KCSAN
diff --git a/init/initramfs.c b/init/initramfs.c
index 1f97c0328a7a..55b74d7e5260 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -535,7 +535,7 @@ extern unsigned long __initramfs_size;
#include <linux/initrd.h>
#include <linux/kexec.h>
-void __weak free_initrd_mem(unsigned long start, unsigned long end)
+void __weak __init free_initrd_mem(unsigned long start, unsigned long end)
{
#ifdef CONFIG_ARCH_KEEP_MEMBLOCK
unsigned long aligned_start = ALIGN_DOWN(start, PAGE_SIZE);
diff --git a/init/main.c b/init/main.c
index 9d964511fe0c..421640fca375 100644
--- a/init/main.c
+++ b/init/main.c
@@ -58,7 +58,6 @@
#include <linux/rmap.h>
#include <linux/mempolicy.h>
#include <linux/key.h>
-#include <linux/buffer_head.h>
#include <linux/page_ext.h>
#include <linux/debug_locks.h>
#include <linux/debugobjects.h>
@@ -825,9 +824,11 @@ static void __init mm_init(void)
* bigger than MAX_ORDER unless SPARSEMEM.
*/
page_ext_init_flatmem();
- init_debug_pagealloc();
+ init_mem_debugging_and_hardening();
report_meminit();
mem_init();
+ /* page_owner must be initialized after buddy is ready */
+ page_ext_init_flatmem_late();
kmem_cache_init();
kmemleak_init();
pgtable_init();
@@ -1034,7 +1035,6 @@ asmlinkage __visible void __init __no_sanitize_address start_kernel(void)
fork_init();
proc_caches_init();
uts_ns_init();
- buffer_init();
key_init();
security_init();
dbg_late_init();
@@ -1480,8 +1480,14 @@ void __init console_on_rootfs(void)
struct file *file = filp_open("/dev/console", O_RDWR, 0);
if (IS_ERR(file)) {
- pr_err("Warning: unable to open an initial console.\n");
- return;
+ pr_err("Warning: unable to open an initial console. Fallback to ttynull.\n");
+ register_ttynull_console();
+
+ file = filp_open("/dev/console", O_RDWR, 0);
+ if (IS_ERR(file)) {
+ pr_err("Warning: Failed to add ttynull console. No stdin, stdout, and stderr for the init process!\n");
+ return;
+ }
}
init_dup(file);
init_dup(file);
diff --git a/init/version.c b/init/version.c
index cba341161b58..80d2b7566b39 100644
--- a/init/version.c
+++ b/init/version.c
@@ -25,7 +25,7 @@ int version_string(LINUX_VERSION_CODE);
#endif
struct uts_namespace init_uts_ns = {
- .kref = KREF_INIT(2),
+ .ns.count = REFCOUNT_INIT(2),
.name = {
.sysname = UTS_SYSNAME,
.nodename = UTS_NODENAME,