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 21:07:57 +07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* fs/isofs/export.c
|
|
|
|
*
|
|
|
|
* (C) 2004 Paul Serice - The new inode scheme requires switching
|
|
|
|
* from iget() to iget5_locked() which means
|
|
|
|
* the NFS export operations have to be hand
|
|
|
|
* coded because the default routines rely on
|
|
|
|
* iget().
|
|
|
|
*
|
|
|
|
* The following files are helpful:
|
|
|
|
*
|
2019-07-26 19:51:27 +07:00
|
|
|
* Documentation/filesystems/nfs/exporting.rst
|
2005-04-17 05:20:36 +07:00
|
|
|
* fs/exportfs/expfs.c.
|
|
|
|
*/
|
|
|
|
|
2005-04-26 08:32:12 +07:00
|
|
|
#include "isofs.h"
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
static struct dentry *
|
|
|
|
isofs_export_iget(struct super_block *sb,
|
|
|
|
unsigned long block,
|
|
|
|
unsigned long offset,
|
|
|
|
__u32 generation)
|
|
|
|
{
|
|
|
|
struct inode *inode;
|
2008-08-11 20:49:04 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
if (block == 0)
|
|
|
|
return ERR_PTR(-ESTALE);
|
|
|
|
inode = isofs_iget(sb, block, offset);
|
2008-02-07 15:15:41 +07:00
|
|
|
if (IS_ERR(inode))
|
|
|
|
return ERR_CAST(inode);
|
|
|
|
if (generation && inode->i_generation != generation) {
|
2005-04-17 05:20:36 +07:00
|
|
|
iput(inode);
|
|
|
|
return ERR_PTR(-ESTALE);
|
|
|
|
}
|
2008-08-11 20:49:04 +07:00
|
|
|
return d_obtain_alias(inode);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* This function is surprisingly simple. The trick is understanding
|
|
|
|
* that "child" is always a directory. So, to find its parent, you
|
|
|
|
* simply need to find its ".." entry, normalize its block and offset,
|
|
|
|
* and return the underlying inode. See the comments for
|
|
|
|
* isofs_normalize_block_and_offset(). */
|
|
|
|
static struct dentry *isofs_export_get_parent(struct dentry *child)
|
|
|
|
{
|
|
|
|
unsigned long parent_block = 0;
|
|
|
|
unsigned long parent_offset = 0;
|
2015-03-18 05:25:59 +07:00
|
|
|
struct inode *child_inode = d_inode(child);
|
2005-04-17 05:20:36 +07:00
|
|
|
struct iso_inode_info *e_child_inode = ISOFS_I(child_inode);
|
|
|
|
struct iso_directory_record *de = NULL;
|
|
|
|
struct buffer_head * bh = NULL;
|
|
|
|
struct dentry *rv = NULL;
|
|
|
|
|
|
|
|
/* "child" must always be a directory. */
|
|
|
|
if (!S_ISDIR(child_inode->i_mode)) {
|
|
|
|
printk(KERN_ERR "isofs: isofs_export_get_parent(): "
|
|
|
|
"child is not a directory!\n");
|
|
|
|
rv = ERR_PTR(-EACCES);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* It is an invariant that the directory offset is zero. If
|
|
|
|
* it is not zero, it means the directory failed to be
|
|
|
|
* normalized for some reason. */
|
|
|
|
if (e_child_inode->i_iget5_offset != 0) {
|
|
|
|
printk(KERN_ERR "isofs: isofs_export_get_parent(): "
|
|
|
|
"child directory not normalized!\n");
|
|
|
|
rv = ERR_PTR(-EACCES);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The child inode has been normalized such that its
|
|
|
|
* i_iget5_block value points to the "." entry. Fortunately,
|
|
|
|
* the ".." entry is located in the same block. */
|
|
|
|
parent_block = e_child_inode->i_iget5_block;
|
|
|
|
|
|
|
|
/* Get the block in question. */
|
|
|
|
bh = sb_bread(child_inode->i_sb, parent_block);
|
|
|
|
if (bh == NULL) {
|
|
|
|
rv = ERR_PTR(-EACCES);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is the "." entry. */
|
|
|
|
de = (struct iso_directory_record*)bh->b_data;
|
|
|
|
|
|
|
|
/* The ".." entry is always the second entry. */
|
|
|
|
parent_offset = (unsigned long)isonum_711(de->length);
|
|
|
|
de = (struct iso_directory_record*)(bh->b_data + parent_offset);
|
|
|
|
|
|
|
|
/* Verify it is in fact the ".." entry. */
|
|
|
|
if ((isonum_711(de->name_len) != 1) || (de->name[0] != 1)) {
|
|
|
|
printk(KERN_ERR "isofs: Unable to find the \"..\" "
|
|
|
|
"directory for NFS.\n");
|
|
|
|
rv = ERR_PTR(-EACCES);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Normalize */
|
|
|
|
isofs_normalize_block_and_offset(de, &parent_block, &parent_offset);
|
|
|
|
|
2008-08-11 20:49:04 +07:00
|
|
|
rv = d_obtain_alias(isofs_iget(child_inode->i_sb, parent_block,
|
|
|
|
parent_offset));
|
2005-04-17 05:20:36 +07:00
|
|
|
out:
|
2008-08-11 20:49:04 +07:00
|
|
|
if (bh)
|
2005-04-17 05:20:36 +07:00
|
|
|
brelse(bh);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-04-03 01:34:06 +07:00
|
|
|
isofs_export_encode_fh(struct inode *inode,
|
2005-04-17 05:20:36 +07:00
|
|
|
__u32 *fh32,
|
|
|
|
int *max_len,
|
2012-04-03 01:34:06 +07:00
|
|
|
struct inode *parent)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
struct iso_inode_info * ei = ISOFS_I(inode);
|
|
|
|
int len = *max_len;
|
|
|
|
int type = 1;
|
|
|
|
__u16 *fh16 = (__u16*)fh32;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* WARNING: max_len is 5 for NFSv2. Because of this
|
|
|
|
* limitation, we use the lower 16 bits of fh32[1] to hold the
|
|
|
|
* offset of the inode and the upper 16 bits of fh32[1] to
|
|
|
|
* hold the offset of the parent.
|
|
|
|
*/
|
2012-04-03 01:34:06 +07:00
|
|
|
if (parent && (len < 5)) {
|
2011-01-29 20:13:25 +07:00
|
|
|
*max_len = 5;
|
2013-02-17 13:48:11 +07:00
|
|
|
return FILEID_INVALID;
|
2011-01-29 20:13:25 +07:00
|
|
|
} else if (len < 3) {
|
|
|
|
*max_len = 3;
|
2013-02-17 13:48:11 +07:00
|
|
|
return FILEID_INVALID;
|
2011-01-29 20:13:25 +07:00
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
len = 3;
|
|
|
|
fh32[0] = ei->i_iget5_block;
|
|
|
|
fh16[2] = (__u16)ei->i_iget5_offset; /* fh16 [sic] */
|
2012-07-12 13:46:54 +07:00
|
|
|
fh16[3] = 0; /* avoid leaking uninitialized data */
|
2005-04-17 05:20:36 +07:00
|
|
|
fh32[2] = inode->i_generation;
|
2012-04-03 01:34:06 +07:00
|
|
|
if (parent) {
|
2005-04-17 05:20:36 +07:00
|
|
|
struct iso_inode_info *eparent;
|
|
|
|
eparent = ISOFS_I(parent);
|
|
|
|
fh32[3] = eparent->i_iget5_block;
|
|
|
|
fh16[3] = (__u16)eparent->i_iget5_offset; /* fh16 [sic] */
|
|
|
|
fh32[4] = parent->i_generation;
|
|
|
|
len = 5;
|
|
|
|
type = 2;
|
|
|
|
}
|
|
|
|
*max_len = len;
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
2007-10-22 06:42:12 +07:00
|
|
|
struct isofs_fid {
|
|
|
|
u32 block;
|
|
|
|
u16 offset;
|
|
|
|
u16 parent_offset;
|
|
|
|
u32 generation;
|
|
|
|
u32 parent_block;
|
|
|
|
u32 parent_generation;
|
|
|
|
};
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-10-22 06:42:12 +07:00
|
|
|
static struct dentry *isofs_fh_to_dentry(struct super_block *sb,
|
|
|
|
struct fid *fid, int fh_len, int fh_type)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2007-10-22 06:42:12 +07:00
|
|
|
struct isofs_fid *ifid = (struct isofs_fid *)fid;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-10-22 06:42:12 +07:00
|
|
|
if (fh_len < 3 || fh_type > 2)
|
2005-04-17 05:20:36 +07:00
|
|
|
return NULL;
|
|
|
|
|
2007-10-22 06:42:12 +07:00
|
|
|
return isofs_export_iget(sb, ifid->block, ifid->offset,
|
|
|
|
ifid->generation);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2007-10-22 06:42:12 +07:00
|
|
|
static struct dentry *isofs_fh_to_parent(struct super_block *sb,
|
|
|
|
struct fid *fid, int fh_len, int fh_type)
|
|
|
|
{
|
|
|
|
struct isofs_fid *ifid = (struct isofs_fid *)fid;
|
|
|
|
|
tmpfs,ceph,gfs2,isofs,reiserfs,xfs: fix fh_len checking
Fuzzing with trinity oopsed on the 1st instruction of shmem_fh_to_dentry(),
u64 inum = fid->raw[2];
which is unhelpfully reported as at the end of shmem_alloc_inode():
BUG: unable to handle kernel paging request at ffff880061cd3000
IP: [<ffffffff812190d0>] shmem_alloc_inode+0x40/0x40
Oops: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC
Call Trace:
[<ffffffff81488649>] ? exportfs_decode_fh+0x79/0x2d0
[<ffffffff812d77c3>] do_handle_open+0x163/0x2c0
[<ffffffff812d792c>] sys_open_by_handle_at+0xc/0x10
[<ffffffff83a5f3f8>] tracesys+0xe1/0xe6
Right, tmpfs is being stupid to access fid->raw[2] before validating that
fh_len includes it: the buffer kmalloc'ed by do_sys_name_to_handle() may
fall at the end of a page, and the next page not be present.
But some other filesystems (ceph, gfs2, isofs, reiserfs, xfs) are being
careless about fh_len too, in fh_to_dentry() and/or fh_to_parent(), and
could oops in the same way: add the missing fh_len checks to those.
Reported-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Hugh Dickins <hughd@google.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Sage Weil <sage@inktank.com>
Cc: Steven Whitehouse <swhiteho@redhat.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: stable@vger.kernel.org
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-10-08 10:32:51 +07:00
|
|
|
if (fh_len < 2 || fh_type != 2)
|
2007-10-22 06:42:12 +07:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return isofs_export_iget(sb,
|
|
|
|
fh_len > 2 ? ifid->parent_block : 0,
|
|
|
|
ifid->parent_offset,
|
|
|
|
fh_len > 4 ? ifid->parent_generation : 0);
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-10-22 06:42:17 +07:00
|
|
|
const struct export_operations isofs_export_ops = {
|
2005-04-17 05:20:36 +07:00
|
|
|
.encode_fh = isofs_export_encode_fh,
|
2007-10-22 06:42:12 +07:00
|
|
|
.fh_to_dentry = isofs_fh_to_dentry,
|
|
|
|
.fh_to_parent = isofs_fh_to_parent,
|
2005-04-17 05:20:36 +07:00
|
|
|
.get_parent = isofs_export_get_parent,
|
|
|
|
};
|