mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
Sync to mainline for security submaintainers to work against
This commit is contained in:
commit
d68c51e0b3
12277 changed files with 1315406 additions and 283883 deletions
|
|
@ -130,17 +130,8 @@ config HAVE_HARDENED_USERCOPY_ALLOCATOR
|
|||
validating memory ranges against heap object sizes in
|
||||
support of CONFIG_HARDENED_USERCOPY.
|
||||
|
||||
config HAVE_ARCH_HARDENED_USERCOPY
|
||||
bool
|
||||
help
|
||||
The architecture supports CONFIG_HARDENED_USERCOPY by
|
||||
calling check_object_size() just before performing the
|
||||
userspace copies in the low level implementation of
|
||||
copy_to_user() and copy_from_user().
|
||||
|
||||
config HARDENED_USERCOPY
|
||||
bool "Harden memory copies between kernel and userspace"
|
||||
depends on HAVE_ARCH_HARDENED_USERCOPY
|
||||
depends on HAVE_HARDENED_USERCOPY_ALLOCATOR
|
||||
select BUG
|
||||
help
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ static struct aa_loaddata *aa_simple_write_to_buffer(const char __user *userbuf,
|
|||
return ERR_PTR(-ESPIPE);
|
||||
|
||||
/* freed by caller to simple_write_to_buffer */
|
||||
data = kvmalloc(sizeof(*data) + alloc_size);
|
||||
data = kvmalloc(sizeof(*data) + alloc_size, GFP_KERNEL);
|
||||
if (data == NULL)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
kref_init(&data->count);
|
||||
|
|
@ -1357,7 +1357,7 @@ static int aa_mk_null_file(struct dentry *parent)
|
|||
|
||||
inode->i_ino = get_next_ino();
|
||||
inode->i_mode = S_IFCHR | S_IRUGO | S_IWUGO;
|
||||
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
|
||||
inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
|
||||
init_special_inode(inode, S_IFCHR | S_IRUGO | S_IWUGO,
|
||||
MKDEV(MEM_MAJOR, 3));
|
||||
d_instantiate(dentry, inode);
|
||||
|
|
|
|||
|
|
@ -64,17 +64,6 @@ char *aa_split_fqname(char *args, char **ns_name);
|
|||
const char *aa_splitn_fqname(const char *fqname, size_t n, const char **ns_name,
|
||||
size_t *ns_len);
|
||||
void aa_info_message(const char *str);
|
||||
void *__aa_kvmalloc(size_t size, gfp_t flags);
|
||||
|
||||
static inline void *kvmalloc(size_t size)
|
||||
{
|
||||
return __aa_kvmalloc(size, 0);
|
||||
}
|
||||
|
||||
static inline void *kvzalloc(size_t size)
|
||||
{
|
||||
return __aa_kvmalloc(size, __GFP_ZERO);
|
||||
}
|
||||
|
||||
/**
|
||||
* aa_strneq - compare null terminated @str to a non null terminated substring
|
||||
|
|
|
|||
|
|
@ -128,36 +128,6 @@ void aa_info_message(const char *str)
|
|||
printk(KERN_INFO "AppArmor: %s\n", str);
|
||||
}
|
||||
|
||||
/**
|
||||
* __aa_kvmalloc - do allocation preferring kmalloc but falling back to vmalloc
|
||||
* @size: how many bytes of memory are required
|
||||
* @flags: the type of memory to allocate (see kmalloc).
|
||||
*
|
||||
* Return: allocated buffer or NULL if failed
|
||||
*
|
||||
* It is possible that policy being loaded from the user is larger than
|
||||
* what can be allocated by kmalloc, in those cases fall back to vmalloc.
|
||||
*/
|
||||
void *__aa_kvmalloc(size_t size, gfp_t flags)
|
||||
{
|
||||
void *buffer = NULL;
|
||||
|
||||
if (size == 0)
|
||||
return NULL;
|
||||
|
||||
/* do not attempt kmalloc if we need more than 16 pages at once */
|
||||
if (size <= (16*PAGE_SIZE))
|
||||
buffer = kmalloc(size, flags | GFP_KERNEL | __GFP_NORETRY |
|
||||
__GFP_NOWARN);
|
||||
if (!buffer) {
|
||||
if (flags & __GFP_ZERO)
|
||||
buffer = vzalloc(size);
|
||||
else
|
||||
buffer = vmalloc(size);
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* aa_policy_init - initialize a policy structure
|
||||
* @policy: policy to initialize (NOT NULL)
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ static struct table_header *unpack_table(char *blob, size_t bsize)
|
|||
if (bsize < tsize)
|
||||
goto out;
|
||||
|
||||
table = kvzalloc(tsize);
|
||||
table = kvzalloc(tsize, GFP_KERNEL);
|
||||
if (table) {
|
||||
table->td_id = th.td_id;
|
||||
table->td_flags = th.td_flags;
|
||||
|
|
|
|||
|
|
@ -487,7 +487,7 @@ fail:
|
|||
|
||||
static void *kvmemdup(const void *src, size_t len)
|
||||
{
|
||||
void *p = kvmalloc(len);
|
||||
void *p = kvmalloc(len, GFP_KERNEL);
|
||||
|
||||
if (p)
|
||||
memcpy(p, src, len);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ static int mount_count;
|
|||
|
||||
static int fill_super(struct super_block *sb, void *data, int silent)
|
||||
{
|
||||
static struct tree_descr files[] = {{""}};
|
||||
static const struct tree_descr files[] = {{""}};
|
||||
|
||||
return simple_fill_super(sb, SECURITYFS_MAGIC, files);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ static unsigned long key_gc_flags;
|
|||
* immediately unlinked.
|
||||
*/
|
||||
struct key_type key_type_dead = {
|
||||
.name = "dead",
|
||||
.name = ".dead",
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -101,14 +101,9 @@ SYSCALL_DEFINE5(add_key, const char __user *, _type,
|
|||
|
||||
if (_payload) {
|
||||
ret = -ENOMEM;
|
||||
payload = kmalloc(plen, GFP_KERNEL | __GFP_NOWARN);
|
||||
if (!payload) {
|
||||
if (plen <= PAGE_SIZE)
|
||||
goto error2;
|
||||
payload = vmalloc(plen);
|
||||
if (!payload)
|
||||
goto error2;
|
||||
}
|
||||
payload = kvmalloc(plen, GFP_KERNEL);
|
||||
if (!payload)
|
||||
goto error2;
|
||||
|
||||
ret = -EFAULT;
|
||||
if (copy_from_user(payload, _payload, plen) != 0)
|
||||
|
|
@ -273,7 +268,8 @@ error:
|
|||
* Create and join an anonymous session keyring or join a named session
|
||||
* keyring, creating it if necessary. A named session keyring must have Search
|
||||
* permission for it to be joined. Session keyrings without this permit will
|
||||
* be skipped over.
|
||||
* be skipped over. It is not permitted for userspace to create or join
|
||||
* keyrings whose name begin with a dot.
|
||||
*
|
||||
* If successful, the ID of the joined session keyring will be returned.
|
||||
*/
|
||||
|
|
@ -290,12 +286,16 @@ long keyctl_join_session_keyring(const char __user *_name)
|
|||
ret = PTR_ERR(name);
|
||||
goto error;
|
||||
}
|
||||
|
||||
ret = -EPERM;
|
||||
if (name[0] == '.')
|
||||
goto error_name;
|
||||
}
|
||||
|
||||
/* join the session */
|
||||
ret = join_session_keyring(name);
|
||||
error_name:
|
||||
kfree(name);
|
||||
|
||||
error:
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1066,14 +1066,9 @@ long keyctl_instantiate_key_common(key_serial_t id,
|
|||
|
||||
if (from) {
|
||||
ret = -ENOMEM;
|
||||
payload = kmalloc(plen, GFP_KERNEL);
|
||||
if (!payload) {
|
||||
if (plen <= PAGE_SIZE)
|
||||
goto error;
|
||||
payload = vmalloc(plen);
|
||||
if (!payload)
|
||||
goto error;
|
||||
}
|
||||
payload = kvmalloc(plen, GFP_KERNEL);
|
||||
if (!payload)
|
||||
goto error;
|
||||
|
||||
ret = -EFAULT;
|
||||
if (!copy_from_iter_full(payload, plen, from))
|
||||
|
|
@ -1253,8 +1248,8 @@ error:
|
|||
* Read or set the default keyring in which request_key() will cache keys and
|
||||
* return the old setting.
|
||||
*
|
||||
* If a process keyring is specified then this will be created if it doesn't
|
||||
* yet exist. The old setting will be returned if successful.
|
||||
* If a thread or process keyring is specified then it will be created if it
|
||||
* doesn't yet exist. The old setting will be returned if successful.
|
||||
*/
|
||||
long keyctl_set_reqkey_keyring(int reqkey_defl)
|
||||
{
|
||||
|
|
@ -1279,11 +1274,8 @@ long keyctl_set_reqkey_keyring(int reqkey_defl)
|
|||
|
||||
case KEY_REQKEY_DEFL_PROCESS_KEYRING:
|
||||
ret = install_process_keyring_to_cred(new);
|
||||
if (ret < 0) {
|
||||
if (ret != -EEXIST)
|
||||
goto error;
|
||||
ret = 0;
|
||||
}
|
||||
if (ret < 0)
|
||||
goto error;
|
||||
goto set;
|
||||
|
||||
case KEY_REQKEY_DEFL_DEFAULT:
|
||||
|
|
|
|||
|
|
@ -128,13 +128,18 @@ error:
|
|||
}
|
||||
|
||||
/*
|
||||
* Install a fresh thread keyring directly to new credentials. This keyring is
|
||||
* allowed to overrun the quota.
|
||||
* Install a thread keyring to the given credentials struct if it didn't have
|
||||
* one already. This is allowed to overrun the quota.
|
||||
*
|
||||
* Return: 0 if a thread keyring is now present; -errno on failure.
|
||||
*/
|
||||
int install_thread_keyring_to_cred(struct cred *new)
|
||||
{
|
||||
struct key *keyring;
|
||||
|
||||
if (new->thread_keyring)
|
||||
return 0;
|
||||
|
||||
keyring = keyring_alloc("_tid", new->uid, new->gid, new,
|
||||
KEY_POS_ALL | KEY_USR_VIEW,
|
||||
KEY_ALLOC_QUOTA_OVERRUN,
|
||||
|
|
@ -147,7 +152,9 @@ int install_thread_keyring_to_cred(struct cred *new)
|
|||
}
|
||||
|
||||
/*
|
||||
* Install a fresh thread keyring, discarding the old one.
|
||||
* Install a thread keyring to the current task if it didn't have one already.
|
||||
*
|
||||
* Return: 0 if a thread keyring is now present; -errno on failure.
|
||||
*/
|
||||
static int install_thread_keyring(void)
|
||||
{
|
||||
|
|
@ -158,8 +165,6 @@ static int install_thread_keyring(void)
|
|||
if (!new)
|
||||
return -ENOMEM;
|
||||
|
||||
BUG_ON(new->thread_keyring);
|
||||
|
||||
ret = install_thread_keyring_to_cred(new);
|
||||
if (ret < 0) {
|
||||
abort_creds(new);
|
||||
|
|
@ -170,17 +175,17 @@ static int install_thread_keyring(void)
|
|||
}
|
||||
|
||||
/*
|
||||
* Install a process keyring directly to a credentials struct.
|
||||
* Install a process keyring to the given credentials struct if it didn't have
|
||||
* one already. This is allowed to overrun the quota.
|
||||
*
|
||||
* Returns -EEXIST if there was already a process keyring, 0 if one installed,
|
||||
* and other value on any other error
|
||||
* Return: 0 if a process keyring is now present; -errno on failure.
|
||||
*/
|
||||
int install_process_keyring_to_cred(struct cred *new)
|
||||
{
|
||||
struct key *keyring;
|
||||
|
||||
if (new->process_keyring)
|
||||
return -EEXIST;
|
||||
return 0;
|
||||
|
||||
keyring = keyring_alloc("_pid", new->uid, new->gid, new,
|
||||
KEY_POS_ALL | KEY_USR_VIEW,
|
||||
|
|
@ -194,11 +199,9 @@ int install_process_keyring_to_cred(struct cred *new)
|
|||
}
|
||||
|
||||
/*
|
||||
* Make sure a process keyring is installed for the current process. The
|
||||
* existing process keyring is not replaced.
|
||||
* Install a process keyring to the current task if it didn't have one already.
|
||||
*
|
||||
* Returns 0 if there is a process keyring by the end of this function, some
|
||||
* error otherwise.
|
||||
* Return: 0 if a process keyring is now present; -errno on failure.
|
||||
*/
|
||||
static int install_process_keyring(void)
|
||||
{
|
||||
|
|
@ -212,14 +215,18 @@ static int install_process_keyring(void)
|
|||
ret = install_process_keyring_to_cred(new);
|
||||
if (ret < 0) {
|
||||
abort_creds(new);
|
||||
return ret != -EEXIST ? ret : 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
return commit_creds(new);
|
||||
}
|
||||
|
||||
/*
|
||||
* Install a session keyring directly to a credentials struct.
|
||||
* Install the given keyring as the session keyring of the given credentials
|
||||
* struct, replacing the existing one if any. If the given keyring is NULL,
|
||||
* then install a new anonymous session keyring.
|
||||
*
|
||||
* Return: 0 on success; -errno on failure.
|
||||
*/
|
||||
int install_session_keyring_to_cred(struct cred *cred, struct key *keyring)
|
||||
{
|
||||
|
|
@ -254,8 +261,11 @@ int install_session_keyring_to_cred(struct cred *cred, struct key *keyring)
|
|||
}
|
||||
|
||||
/*
|
||||
* Install a session keyring, discarding the old one. If a keyring is not
|
||||
* supplied, an empty one is invented.
|
||||
* Install the given keyring as the session keyring of the current task,
|
||||
* replacing the existing one if any. If the given keyring is NULL, then
|
||||
* install a new anonymous session keyring.
|
||||
*
|
||||
* Return: 0 on success; -errno on failure.
|
||||
*/
|
||||
static int install_session_keyring(struct key *keyring)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -129,10 +129,14 @@ static int lsm_append(char *new, char **result)
|
|||
* to avoid security registration races. This method may also be used
|
||||
* to check if your LSM is currently loaded during kernel initialization.
|
||||
*
|
||||
* Return true if:
|
||||
* -The passed LSM is the one chosen by user at boot time,
|
||||
* -or the passed LSM is configured as the default and the user did not
|
||||
* choose an alternate LSM at boot time.
|
||||
* Returns:
|
||||
*
|
||||
* true if:
|
||||
*
|
||||
* - The passed LSM is the one chosen by user at boot time,
|
||||
* - or the passed LSM is configured as the default and the user did not
|
||||
* choose an alternate LSM at boot time.
|
||||
*
|
||||
* Otherwise, return false.
|
||||
*/
|
||||
int __init security_module_enable(const char *module)
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ static const struct nlmsg_perm nlmsg_route_perms[] =
|
|||
{ RTM_GETDCB, NETLINK_ROUTE_SOCKET__NLMSG_READ },
|
||||
{ RTM_SETDCB, NETLINK_ROUTE_SOCKET__NLMSG_WRITE },
|
||||
{ RTM_NEWNETCONF, NETLINK_ROUTE_SOCKET__NLMSG_WRITE },
|
||||
{ RTM_DELNETCONF, NETLINK_ROUTE_SOCKET__NLMSG_WRITE },
|
||||
{ RTM_GETNETCONF, NETLINK_ROUTE_SOCKET__NLMSG_READ },
|
||||
{ RTM_NEWMDB, NETLINK_ROUTE_SOCKET__NLMSG_WRITE },
|
||||
{ RTM_DELMDB, NETLINK_ROUTE_SOCKET__NLMSG_WRITE },
|
||||
|
|
|
|||
|
|
@ -1496,7 +1496,7 @@ static const struct file_operations sel_avc_cache_stats_ops = {
|
|||
static int sel_make_avc_files(struct dentry *dir)
|
||||
{
|
||||
int i;
|
||||
static struct tree_descr files[] = {
|
||||
static const struct tree_descr files[] = {
|
||||
{ "cache_threshold",
|
||||
&sel_avc_cache_threshold_ops, S_IRUGO|S_IWUSR },
|
||||
{ "hash_stats", &sel_avc_hash_stats_ops, S_IRUGO },
|
||||
|
|
@ -1805,7 +1805,7 @@ static int sel_fill_super(struct super_block *sb, void *data, int silent)
|
|||
struct inode *inode;
|
||||
struct inode_security_struct *isec;
|
||||
|
||||
static struct tree_descr selinux_files[] = {
|
||||
static const struct tree_descr selinux_files[] = {
|
||||
[SEL_LOAD] = {"load", &sel_load_ops, S_IRUSR|S_IWUSR},
|
||||
[SEL_ENFORCE] = {"enforce", &sel_enforce_ops, S_IRUGO|S_IWUSR},
|
||||
[SEL_CONTEXT] = {"context", &transaction_ops, S_IRUGO|S_IWUGO},
|
||||
|
|
|
|||
|
|
@ -2855,7 +2855,7 @@ static int smk_fill_super(struct super_block *sb, void *data, int silent)
|
|||
int rc;
|
||||
struct inode *root_inode;
|
||||
|
||||
static struct tree_descr smack_files[] = {
|
||||
static const struct tree_descr smack_files[] = {
|
||||
[SMK_LOAD] = {
|
||||
"load", &smk_load_ops, S_IRUGO|S_IWUSR},
|
||||
[SMK_CIPSO] = {
|
||||
|
|
|
|||
|
|
@ -608,7 +608,7 @@ static int tomoyo_check_unix_address(struct sockaddr *addr,
|
|||
static bool tomoyo_kernel_service(void)
|
||||
{
|
||||
/* Nothing to do if I am a kernel service. */
|
||||
return segment_eq(get_fs(), KERNEL_DS);
|
||||
return uaccess_kernel();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue