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 22:07:57 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2017-01-25 02:58:06 +08:00
|
|
|
/*
|
|
|
|
* fscrypt_supp.h
|
|
|
|
*
|
2017-10-10 03:15:34 +08:00
|
|
|
* Do not include this file directly. Use fscrypt.h instead!
|
2017-01-25 02:58:06 +08:00
|
|
|
*/
|
2017-10-10 03:15:34 +08:00
|
|
|
#ifndef _LINUX_FSCRYPT_H
|
|
|
|
#error "Incorrect include of linux/fscrypt_supp.h!"
|
|
|
|
#endif
|
2017-01-25 02:58:06 +08:00
|
|
|
|
|
|
|
#ifndef _LINUX_FSCRYPT_SUPP_H
|
|
|
|
#define _LINUX_FSCRYPT_SUPP_H
|
|
|
|
|
2018-01-06 02:45:00 +08:00
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
|
2018-01-06 02:44:57 +08:00
|
|
|
/*
|
|
|
|
* fscrypt superblock flags
|
|
|
|
*/
|
|
|
|
#define FS_CFLG_OWN_PAGES (1U << 1)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* crypto operations for filesystems
|
|
|
|
*/
|
|
|
|
struct fscrypt_operations {
|
|
|
|
unsigned int flags;
|
|
|
|
const char *key_prefix;
|
|
|
|
int (*get_context)(struct inode *, void *, size_t);
|
|
|
|
int (*set_context)(struct inode *, const void *, size_t, void *);
|
|
|
|
bool (*dummy_context)(struct inode *);
|
|
|
|
bool (*empty_dir)(struct inode *);
|
2018-05-01 06:51:44 +08:00
|
|
|
unsigned int max_namelen;
|
2018-01-06 02:44:57 +08:00
|
|
|
};
|
|
|
|
|
2018-01-06 02:44:55 +08:00
|
|
|
struct fscrypt_ctx {
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
struct page *bounce_page; /* Ciphertext page */
|
|
|
|
struct page *control_page; /* Original page */
|
|
|
|
} w;
|
|
|
|
struct {
|
|
|
|
struct bio *bio;
|
|
|
|
struct work_struct work;
|
|
|
|
} r;
|
|
|
|
struct list_head free_list; /* Free list */
|
|
|
|
};
|
|
|
|
u8 flags; /* Flags */
|
|
|
|
};
|
|
|
|
|
2018-01-06 02:44:52 +08:00
|
|
|
static inline bool fscrypt_has_encryption_key(const struct inode *inode)
|
|
|
|
{
|
|
|
|
return (inode->i_crypt_info != NULL);
|
|
|
|
}
|
|
|
|
|
2018-01-06 02:44:56 +08:00
|
|
|
static inline bool fscrypt_dummy_context_enabled(struct inode *inode)
|
|
|
|
{
|
|
|
|
return inode->i_sb->s_cop->dummy_context &&
|
|
|
|
inode->i_sb->s_cop->dummy_context(inode);
|
|
|
|
}
|
|
|
|
|
2017-01-25 02:58:06 +08:00
|
|
|
/* crypto.c */
|
2018-04-19 02:09:47 +08:00
|
|
|
extern void fscrypt_enqueue_decrypt_work(struct work_struct *);
|
2017-01-25 02:58:06 +08:00
|
|
|
extern struct fscrypt_ctx *fscrypt_get_ctx(const struct inode *, gfp_t);
|
|
|
|
extern void fscrypt_release_ctx(struct fscrypt_ctx *);
|
|
|
|
extern struct page *fscrypt_encrypt_page(const struct inode *, struct page *,
|
|
|
|
unsigned int, unsigned int,
|
|
|
|
u64, gfp_t);
|
|
|
|
extern int fscrypt_decrypt_page(const struct inode *, struct page *, unsigned int,
|
|
|
|
unsigned int, u64);
|
2018-01-06 02:44:53 +08:00
|
|
|
|
|
|
|
static inline struct page *fscrypt_control_page(struct page *page)
|
|
|
|
{
|
|
|
|
return ((struct fscrypt_ctx *)page_private(page))->w.control_page;
|
|
|
|
}
|
|
|
|
|
2017-01-25 02:58:06 +08:00
|
|
|
extern void fscrypt_restore_control_page(struct page *);
|
|
|
|
|
|
|
|
/* policy.c */
|
|
|
|
extern int fscrypt_ioctl_set_policy(struct file *, const void __user *);
|
|
|
|
extern int fscrypt_ioctl_get_policy(struct file *, void __user *);
|
|
|
|
extern int fscrypt_has_permitted_context(struct inode *, struct inode *);
|
|
|
|
extern int fscrypt_inherit_context(struct inode *, struct inode *,
|
|
|
|
void *, bool);
|
|
|
|
/* keyinfo.c */
|
|
|
|
extern int fscrypt_get_encryption_info(struct inode *);
|
2018-01-12 12:30:13 +08:00
|
|
|
extern void fscrypt_put_encryption_info(struct inode *);
|
2017-01-25 02:58:06 +08:00
|
|
|
|
|
|
|
/* fname.c */
|
|
|
|
extern int fscrypt_setup_filename(struct inode *, const struct qstr *,
|
|
|
|
int lookup, struct fscrypt_name *);
|
2017-05-23 09:14:06 +08:00
|
|
|
|
|
|
|
static inline void fscrypt_free_filename(struct fscrypt_name *fname)
|
|
|
|
{
|
|
|
|
kfree(fname->crypto_buf.name);
|
|
|
|
}
|
|
|
|
|
2017-01-25 02:58:06 +08:00
|
|
|
extern int fscrypt_fname_alloc_buffer(const struct inode *, u32,
|
|
|
|
struct fscrypt_str *);
|
|
|
|
extern void fscrypt_fname_free_buffer(struct fscrypt_str *);
|
|
|
|
extern int fscrypt_fname_disk_to_usr(struct inode *, u32, u32,
|
|
|
|
const struct fscrypt_str *, struct fscrypt_str *);
|
|
|
|
|
2017-04-25 01:00:10 +08:00
|
|
|
#define FSCRYPT_FNAME_MAX_UNDIGESTED_SIZE 32
|
|
|
|
|
|
|
|
/* Extracts the second-to-last ciphertext block; see explanation below */
|
|
|
|
#define FSCRYPT_FNAME_DIGEST(name, len) \
|
|
|
|
((name) + round_down((len) - FS_CRYPTO_BLOCK_SIZE - 1, \
|
|
|
|
FS_CRYPTO_BLOCK_SIZE))
|
|
|
|
|
|
|
|
#define FSCRYPT_FNAME_DIGEST_SIZE FS_CRYPTO_BLOCK_SIZE
|
|
|
|
|
|
|
|
/**
|
|
|
|
* fscrypt_digested_name - alternate identifier for an on-disk filename
|
|
|
|
*
|
|
|
|
* When userspace lists an encrypted directory without access to the key,
|
|
|
|
* filenames whose ciphertext is longer than FSCRYPT_FNAME_MAX_UNDIGESTED_SIZE
|
|
|
|
* bytes are shown in this abbreviated form (base64-encoded) rather than as the
|
|
|
|
* full ciphertext (base64-encoded). This is necessary to allow supporting
|
|
|
|
* filenames up to NAME_MAX bytes, since base64 encoding expands the length.
|
|
|
|
*
|
|
|
|
* To make it possible for filesystems to still find the correct directory entry
|
|
|
|
* despite not knowing the full on-disk name, we encode any filesystem-specific
|
|
|
|
* 'hash' and/or 'minor_hash' which the filesystem may need for its lookups,
|
|
|
|
* followed by the second-to-last ciphertext block of the filename. Due to the
|
|
|
|
* use of the CBC-CTS encryption mode, the second-to-last ciphertext block
|
|
|
|
* depends on the full plaintext. (Note that ciphertext stealing causes the
|
2017-05-02 02:43:32 +08:00
|
|
|
* last two blocks to appear "flipped".) This makes accidental collisions very
|
|
|
|
* unlikely: just a 1 in 2^128 chance for two filenames to collide even if they
|
|
|
|
* share the same filesystem-specific hashes.
|
2017-04-25 01:00:10 +08:00
|
|
|
*
|
2017-05-02 02:43:32 +08:00
|
|
|
* However, this scheme isn't immune to intentional collisions, which can be
|
|
|
|
* created by anyone able to create arbitrary plaintext filenames and view them
|
|
|
|
* without the key. Making the "digest" be a real cryptographic hash like
|
|
|
|
* SHA-256 over the full ciphertext would prevent this, although it would be
|
|
|
|
* less efficient and harder to implement, especially since the filesystem would
|
|
|
|
* need to calculate it for each directory entry examined during a search.
|
2017-04-25 01:00:10 +08:00
|
|
|
*/
|
|
|
|
struct fscrypt_digested_name {
|
|
|
|
u32 hash;
|
|
|
|
u32 minor_hash;
|
|
|
|
u8 digest[FSCRYPT_FNAME_DIGEST_SIZE];
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* fscrypt_match_name() - test whether the given name matches a directory entry
|
|
|
|
* @fname: the name being searched for
|
|
|
|
* @de_name: the name from the directory entry
|
|
|
|
* @de_name_len: the length of @de_name in bytes
|
|
|
|
*
|
|
|
|
* Normally @fname->disk_name will be set, and in that case we simply compare
|
|
|
|
* that to the name stored in the directory entry. The only exception is that
|
|
|
|
* if we don't have the key for an encrypted directory and a filename in it is
|
|
|
|
* very long, then we won't have the full disk_name and we'll instead need to
|
|
|
|
* match against the fscrypt_digested_name.
|
|
|
|
*
|
|
|
|
* Return: %true if the name matches, otherwise %false.
|
|
|
|
*/
|
|
|
|
static inline bool fscrypt_match_name(const struct fscrypt_name *fname,
|
|
|
|
const u8 *de_name, u32 de_name_len)
|
|
|
|
{
|
|
|
|
if (unlikely(!fname->disk_name.name)) {
|
|
|
|
const struct fscrypt_digested_name *n =
|
|
|
|
(const void *)fname->crypto_buf.name;
|
|
|
|
if (WARN_ON_ONCE(fname->usr_fname->name[0] != '_'))
|
|
|
|
return false;
|
|
|
|
if (de_name_len <= FSCRYPT_FNAME_MAX_UNDIGESTED_SIZE)
|
|
|
|
return false;
|
|
|
|
return !memcmp(FSCRYPT_FNAME_DIGEST(de_name, de_name_len),
|
|
|
|
n->digest, FSCRYPT_FNAME_DIGEST_SIZE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (de_name_len != fname->disk_name.len)
|
|
|
|
return false;
|
|
|
|
return !memcmp(de_name, fname->disk_name.name, fname->disk_name.len);
|
|
|
|
}
|
|
|
|
|
2017-01-25 02:58:06 +08:00
|
|
|
/* bio.c */
|
2018-04-19 02:09:47 +08:00
|
|
|
extern void fscrypt_decrypt_bio(struct bio *);
|
|
|
|
extern void fscrypt_enqueue_decrypt_bio(struct fscrypt_ctx *ctx,
|
|
|
|
struct bio *bio);
|
2017-01-25 02:58:06 +08:00
|
|
|
extern void fscrypt_pullback_bio_page(struct page **, bool);
|
|
|
|
extern int fscrypt_zeroout_range(const struct inode *, pgoff_t, sector_t,
|
|
|
|
unsigned int);
|
|
|
|
|
2017-10-10 03:15:40 +08:00
|
|
|
/* hooks.c */
|
|
|
|
extern int fscrypt_file_open(struct inode *inode, struct file *filp);
|
2017-10-10 03:15:41 +08:00
|
|
|
extern int __fscrypt_prepare_link(struct inode *inode, struct inode *dir);
|
2017-10-10 03:15:42 +08:00
|
|
|
extern int __fscrypt_prepare_rename(struct inode *old_dir,
|
|
|
|
struct dentry *old_dentry,
|
|
|
|
struct inode *new_dir,
|
|
|
|
struct dentry *new_dentry,
|
|
|
|
unsigned int flags);
|
2017-10-10 03:15:43 +08:00
|
|
|
extern int __fscrypt_prepare_lookup(struct inode *dir, struct dentry *dentry);
|
fscrypt: new helper functions for ->symlink()
Currently, filesystems supporting fscrypt need to implement some tricky
logic when creating encrypted symlinks, including handling a peculiar
on-disk format (struct fscrypt_symlink_data) and correctly calculating
the size of the encrypted symlink. Introduce helper functions to make
things a bit easier:
- fscrypt_prepare_symlink() computes and validates the size the symlink
target will require on-disk.
- fscrypt_encrypt_symlink() creates the encrypted target if needed.
The new helpers actually fix some subtle bugs. First, when checking
whether the symlink target was too long, filesystems didn't account for
the fact that the NUL padding is meant to be truncated if it would cause
the maximum length to be exceeded, as is done for filenames in
directories. Consequently users would receive ENAMETOOLONG when
creating symlinks close to what is supposed to be the maximum length.
For example, with EXT4 with a 4K block size, the maximum symlink target
length in an encrypted directory is supposed to be 4093 bytes (in
comparison to 4095 in an unencrypted directory), but in
FS_POLICY_FLAGS_PAD_32-mode only up to 4064 bytes were accepted.
Second, symlink targets of "." and ".." were not being encrypted, even
though they should be, as these names are special in *directory entries*
but not in symlink targets. Fortunately, we can fix this simply by
starting to encrypt them, as old kernels already accept them in
encrypted form.
Third, the output string length the filesystems were providing when
doing the actual encryption was incorrect, as it was forgotten to
exclude 'sizeof(struct fscrypt_symlink_data)'. Fortunately though, this
bug didn't make a difference.
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-01-06 02:45:01 +08:00
|
|
|
extern int __fscrypt_prepare_symlink(struct inode *dir, unsigned int len,
|
|
|
|
unsigned int max_len,
|
|
|
|
struct fscrypt_str *disk_link);
|
|
|
|
extern int __fscrypt_encrypt_symlink(struct inode *inode, const char *target,
|
|
|
|
unsigned int len,
|
|
|
|
struct fscrypt_str *disk_link);
|
2018-01-06 02:45:02 +08:00
|
|
|
extern const char *fscrypt_get_symlink(struct inode *inode, const void *caddr,
|
|
|
|
unsigned int max_size,
|
|
|
|
struct delayed_call *done);
|
2017-10-10 03:15:40 +08:00
|
|
|
|
2017-01-25 02:58:06 +08:00
|
|
|
#endif /* _LINUX_FSCRYPT_SUPP_H */
|