License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 14:07:57 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/unistd.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/minix_fs.h>
|
|
|
|
#include <linux/romfs_fs.h>
|
|
|
|
#include <linux/initrd.h>
|
|
|
|
#include <linux/sched.h>
|
2006-12-07 04:34:23 +00:00
|
|
|
#include <linux/freezer.h>
|
2012-10-02 19:29:10 +00:00
|
|
|
#include <linux/kmod.h>
|
2018-11-01 23:07:23 +00:00
|
|
|
#include <uapi/linux/mount.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#include "do_mounts.h"
|
|
|
|
|
|
|
|
unsigned long initrd_start, initrd_end;
|
|
|
|
int initrd_below_start_ok;
|
|
|
|
unsigned int real_root_dev; /* do_proc_dointvec cannot handle kdev_t */
|
|
|
|
static int __initdata mount_initrd = 1;
|
|
|
|
|
2018-11-05 22:54:27 +00:00
|
|
|
phys_addr_t phys_initrd_start __initdata;
|
|
|
|
unsigned long phys_initrd_size __initdata;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
static int __init no_initrd(char *str)
|
|
|
|
{
|
|
|
|
mount_initrd = 0;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
__setup("noinitrd", no_initrd);
|
|
|
|
|
x86/setup: Add an initrdmem= option to specify initrd physical address
Add the initrdmem option:
initrdmem=ss[KMG],nn[KMG]
which is used to specify the physical address of the initrd, almost
always an address in FLASH. Also add code for x86 to use the existing
phys_init_start and phys_init_size variables in the kernel.
This is useful in cases where a kernel and an initrd is placed in FLASH,
but there is no firmware file system structure in the FLASH.
One such situation occurs when unused FLASH space on UEFI systems has
been reclaimed by, e.g., taking it from the Management Engine. For
example, on many systems, the ME is given half the FLASH part; not only
is 2.75M of an 8M part unused; but 10.75M of a 16M part is unused. This
space can be used to contain an initrd, but need to tell Linux where it
is.
This space is "raw": due to, e.g., UEFI limitations: it can not be added
to UEFI firmware volumes without rebuilding UEFI from source or writing
a UEFI device driver. It can be referenced only as a physical address
and size.
At the same time, if a kernel can be "netbooted" or loaded from GRUB or
syslinux, the option of not using the physical address specification
should be available.
Then, it is easy to boot the kernel and provide an initrd; or boot the
the kernel and let it use the initrd in FLASH. In practice, this has
proven to be very helpful when integrating Linux into FLASH on x86.
Hence, the most flexible and convenient path is to enable the initrdmem
command line option in a way that it is the last choice tried.
For example, on the DigitalLoggers Atomic Pi, an image into FLASH can be
burnt in with a built-in command line which includes:
initrdmem=0xff968000,0x200000
which specifies a location and size.
[ bp: Massage commit message, make it passive. ]
[akpm@linux-foundation.org: coding style fixes]
Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Link: http://lkml.kernel.org/r/CAP6exYLK11rhreX=6QPyDQmW7wPHsKNEFtXE47pjx41xS6O7-A@mail.gmail.com
Link: https://lkml.kernel.org/r/20200426011021.1cskg0AGd%akpm@linux-foundation.org
2020-04-26 01:10:21 +00:00
|
|
|
static int __init early_initrdmem(char *p)
|
2018-11-05 22:54:31 +00:00
|
|
|
{
|
|
|
|
phys_addr_t start;
|
|
|
|
unsigned long size;
|
|
|
|
char *endp;
|
|
|
|
|
|
|
|
start = memparse(p, &endp);
|
|
|
|
if (*endp == ',') {
|
|
|
|
size = memparse(endp + 1, NULL);
|
|
|
|
|
|
|
|
phys_initrd_start = start;
|
|
|
|
phys_initrd_size = size;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
x86/setup: Add an initrdmem= option to specify initrd physical address
Add the initrdmem option:
initrdmem=ss[KMG],nn[KMG]
which is used to specify the physical address of the initrd, almost
always an address in FLASH. Also add code for x86 to use the existing
phys_init_start and phys_init_size variables in the kernel.
This is useful in cases where a kernel and an initrd is placed in FLASH,
but there is no firmware file system structure in the FLASH.
One such situation occurs when unused FLASH space on UEFI systems has
been reclaimed by, e.g., taking it from the Management Engine. For
example, on many systems, the ME is given half the FLASH part; not only
is 2.75M of an 8M part unused; but 10.75M of a 16M part is unused. This
space can be used to contain an initrd, but need to tell Linux where it
is.
This space is "raw": due to, e.g., UEFI limitations: it can not be added
to UEFI firmware volumes without rebuilding UEFI from source or writing
a UEFI device driver. It can be referenced only as a physical address
and size.
At the same time, if a kernel can be "netbooted" or loaded from GRUB or
syslinux, the option of not using the physical address specification
should be available.
Then, it is easy to boot the kernel and provide an initrd; or boot the
the kernel and let it use the initrd in FLASH. In practice, this has
proven to be very helpful when integrating Linux into FLASH on x86.
Hence, the most flexible and convenient path is to enable the initrdmem
command line option in a way that it is the last choice tried.
For example, on the DigitalLoggers Atomic Pi, an image into FLASH can be
burnt in with a built-in command line which includes:
initrdmem=0xff968000,0x200000
which specifies a location and size.
[ bp: Massage commit message, make it passive. ]
[akpm@linux-foundation.org: coding style fixes]
Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Link: http://lkml.kernel.org/r/CAP6exYLK11rhreX=6QPyDQmW7wPHsKNEFtXE47pjx41xS6O7-A@mail.gmail.com
Link: https://lkml.kernel.org/r/20200426011021.1cskg0AGd%akpm@linux-foundation.org
2020-04-26 01:10:21 +00:00
|
|
|
early_param("initrdmem", early_initrdmem);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is here as the initrd keyword has been in use since 11/2018
|
|
|
|
* on ARM, PowerPC, and MIPS.
|
|
|
|
* It should not be; it is reserved for bootloaders.
|
|
|
|
*/
|
|
|
|
static int __init early_initrd(char *p)
|
|
|
|
{
|
|
|
|
return early_initrdmem(p);
|
|
|
|
}
|
2018-11-05 22:54:31 +00:00
|
|
|
early_param("initrd", early_initrd);
|
|
|
|
|
2020-06-06 13:54:39 +00:00
|
|
|
static int __init init_linuxrc(struct subprocess_info *info, struct cred *new)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2018-03-11 10:34:42 +00:00
|
|
|
ksys_unshare(CLONE_FS | CLONE_FILES);
|
2018-10-23 14:00:10 +00:00
|
|
|
console_on_rootfs();
|
2012-10-02 19:29:10 +00:00
|
|
|
/* move initrd over / and chdir/chroot in initrd root */
|
2018-03-11 10:34:46 +00:00
|
|
|
ksys_chdir("/root");
|
2020-07-21 09:12:08 +00:00
|
|
|
init_mount(".", "/", NULL, MS_MOVE, NULL);
|
2018-03-11 10:34:41 +00:00
|
|
|
ksys_chroot(".");
|
2018-03-16 11:36:06 +00:00
|
|
|
ksys_setsid();
|
2012-10-02 19:29:10 +00:00
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __init handle_initrd(void)
|
|
|
|
{
|
2013-04-30 22:28:07 +00:00
|
|
|
struct subprocess_info *info;
|
2012-10-02 19:29:10 +00:00
|
|
|
static char *argv[] = { "linuxrc", NULL, };
|
|
|
|
extern char *envp_init[];
|
2005-04-16 22:20:36 +00:00
|
|
|
int error;
|
|
|
|
|
2020-07-08 16:18:54 +00:00
|
|
|
pr_warn("using deprecated initrd support, will be removed in 2021.\n");
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
real_root_dev = new_encode_dev(ROOT_DEV);
|
2005-06-21 04:15:16 +00:00
|
|
|
create_dev("/dev/root.old", Root_RAM0);
|
2005-04-16 22:20:36 +00:00
|
|
|
/* mount initrd on rootfs' /root */
|
|
|
|
mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
|
2018-03-11 10:34:49 +00:00
|
|
|
ksys_mkdir("/old", 0700);
|
2018-03-11 10:34:46 +00:00
|
|
|
ksys_chdir("/old");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-11-21 01:50:17 +00:00
|
|
|
/*
|
|
|
|
* In case that a resume from disk is carried out by linuxrc or one of
|
|
|
|
* its children, we need to tell the freezer not to wait for us.
|
|
|
|
*/
|
|
|
|
current->flags |= PF_FREEZER_SKIP;
|
|
|
|
|
2013-04-30 22:28:07 +00:00
|
|
|
info = call_usermodehelper_setup("/linuxrc", argv, envp_init,
|
|
|
|
GFP_KERNEL, init_linuxrc, NULL, NULL);
|
|
|
|
if (!info)
|
|
|
|
return;
|
|
|
|
call_usermodehelper_exec(info, UMH_WAIT_PROC);
|
2007-11-21 01:50:17 +00:00
|
|
|
|
|
|
|
current->flags &= ~PF_FREEZER_SKIP;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* move initrd to rootfs' /old */
|
2020-07-21 09:12:08 +00:00
|
|
|
init_mount("..", ".", NULL, MS_MOVE, NULL);
|
2005-04-16 22:20:36 +00:00
|
|
|
/* switch root and cwd back to / of rootfs */
|
2018-03-11 10:34:41 +00:00
|
|
|
ksys_chroot("..");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (new_decode_dev(real_root_dev) == Root_RAM0) {
|
2018-03-11 10:34:46 +00:00
|
|
|
ksys_chdir("/old");
|
2005-04-16 22:20:36 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-03-11 10:34:46 +00:00
|
|
|
ksys_chdir("/");
|
2005-04-16 22:20:36 +00:00
|
|
|
ROOT_DEV = new_decode_dev(real_root_dev);
|
|
|
|
mount_root();
|
|
|
|
|
|
|
|
printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
|
2020-07-21 09:12:08 +00:00
|
|
|
error = init_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!error)
|
|
|
|
printk("okay\n");
|
|
|
|
else {
|
2005-06-30 09:59:03 +00:00
|
|
|
if (error == -ENOENT)
|
|
|
|
printk("/initrd does not exist. Ignored.\n");
|
|
|
|
else
|
|
|
|
printk("failed\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
printk(KERN_NOTICE "Unmounting old root\n");
|
2020-07-23 06:23:08 +00:00
|
|
|
init_umount("/old", MNT_DETACH);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-20 22:59:29 +00:00
|
|
|
bool __init initrd_load(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
if (mount_initrd) {
|
2005-06-21 04:15:16 +00:00
|
|
|
create_dev("/dev/ram", Root_RAM0);
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Load the initrd data into /dev/ram0. Execute it as initrd
|
|
|
|
* unless /dev/ram0 is supposed to be our actual root device,
|
|
|
|
* in that case the ram disk is just set up here, and gets
|
|
|
|
* mounted in the normal path.
|
|
|
|
*/
|
|
|
|
if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
|
2018-03-11 10:34:47 +00:00
|
|
|
ksys_unlink("/initrd.image");
|
2005-04-16 22:20:36 +00:00
|
|
|
handle_initrd();
|
2016-01-20 22:59:29 +00:00
|
|
|
return true;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
2018-03-11 10:34:47 +00:00
|
|
|
ksys_unlink("/initrd.image");
|
2016-01-20 22:59:29 +00:00
|
|
|
return false;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|