Skip to content

Commit

Permalink
Merge pull request #2 from CryToCry96/cm-14.0-test
Browse files Browse the repository at this point in the history
pull request
  • Loading branch information
linhphi9x94 committed Nov 30, 2016
2 parents 1a12bad + 62cd8d2 commit 2288023
Show file tree
Hide file tree
Showing 27 changed files with 390 additions and 175 deletions.
1 change: 1 addition & 0 deletions block/genhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,7 @@ static void disk_seqf_stop(struct seq_file *seqf, void *v)
if (iter) {
class_dev_iter_exit(iter);
kfree(iter);
seqf->private = NULL;
}
}

Expand Down
68 changes: 30 additions & 38 deletions drivers/crypto/msm/qcedev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1610,44 +1610,6 @@ static int qcedev_vbuf_ablk_cipher(struct qcedev_async_req *areq,
struct qcedev_cipher_op_req *saved_req;
struct qcedev_cipher_op_req *creq = &areq->cipher_op_req;

/* Verify Source Address's */
for (i = 0; i < areq->cipher_op_req.entries; i++)
if (!access_ok(VERIFY_READ,
(void __user *)areq->cipher_op_req.vbuf.src[i].vaddr,
areq->cipher_op_req.vbuf.src[i].len))
return -EFAULT;

/* Verify Destination Address's */
if (creq->in_place_op != 1) {
for (i = 0, total = 0; i < QCEDEV_MAX_BUFFERS; i++) {
if ((areq->cipher_op_req.vbuf.dst[i].vaddr != 0) &&
(total < creq->data_len)) {
if (!access_ok(VERIFY_WRITE,
(void __user *)creq->vbuf.dst[i].vaddr,
creq->vbuf.dst[i].len)) {
pr_err("%s:DST WR_VERIFY err %d=0x%x\n",
__func__, i,
(u32)creq->vbuf.dst[i].vaddr);
return -EFAULT;
}
total += creq->vbuf.dst[i].len;
}
}
} else {
for (i = 0, total = 0; i < creq->entries; i++) {
if (total < creq->data_len) {
if (!access_ok(VERIFY_WRITE,
(void __user *)creq->vbuf.src[i].vaddr,
creq->vbuf.src[i].len)) {
pr_err("%s:SRC WR_VERIFY err %d=0x%x\n",
__func__, i,
(u32)creq->vbuf.src[i].vaddr);
return -EFAULT;
}
total += creq->vbuf.src[i].len;
}
}
}
total = 0;

if (areq->cipher_op_req.mode == QCEDEV_AES_MODE_CTR)
Expand Down Expand Up @@ -1893,6 +1855,36 @@ static int qcedev_check_cipher_params(struct qcedev_cipher_op_req *req,
__func__, total, req->data_len);
goto error;
}
/* Verify Source Address's */
for (i = 0, total = 0; i < req->entries; i++) {
if (total < req->data_len) {
if (!access_ok(VERIFY_READ,
(void __user *)req->vbuf.src[i].vaddr,
req->vbuf.src[i].len)) {
pr_err("%s:SRC RD_VERIFY err %d=0x%lx\n",
__func__, i, (uintptr_t)
req->vbuf.src[i].vaddr);
goto error;
}
total += req->vbuf.src[i].len;
}
}

/* Verify Destination Address's */
for (i = 0, total = 0; i < QCEDEV_MAX_BUFFERS; i++) {
if ((req->vbuf.dst[i].vaddr != 0) &&
(total < req->data_len)) {
if (!access_ok(VERIFY_WRITE,
(void __user *)req->vbuf.dst[i].vaddr,
req->vbuf.dst[i].len)) {
pr_err("%s:DST WR_VERIFY err %d=0x%lx\n",
__func__, i, (uintptr_t)
req->vbuf.dst[i].vaddr);
goto error;
}
total += req->vbuf.dst[i].len;
}
}
return 0;
error:
return -EINVAL;
Expand Down
3 changes: 3 additions & 0 deletions drivers/hid/hid-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,7 @@ static void hid_input_field(struct hid_device *hid, struct hid_field *field,
/* Ignore report if ErrorRollOver */
if (!(field->flags & HID_MAIN_ITEM_VARIABLE) &&
value[n] >= min && value[n] <= max &&
value[n] - min < field->maxusage &&
field->usage[value[n] - min].hid == HID_UP_KEYBOARD + 1)
goto exit;
}
Expand All @@ -1006,11 +1007,13 @@ static void hid_input_field(struct hid_device *hid, struct hid_field *field,
}

if (field->value[n] >= min && field->value[n] <= max
&& field->value[n] - min < field->maxusage
&& field->usage[field->value[n] - min].hid
&& search(value, field->value[n], count))
hid_process_event(hid, field, &field->usage[field->value[n] - min], 0, interrupt);

if (value[n] >= min && value[n] <= max
&& value[n] - min < field->maxusage
&& field->usage[value[n] - min].hid
&& search(field->value, value[n], count))
hid_process_event(hid, field, &field->usage[value[n] - min], 1, interrupt);
Expand Down
7 changes: 6 additions & 1 deletion drivers/scsi/sg.c
Original file line number Diff line number Diff line change
Expand Up @@ -741,8 +741,13 @@ sg_common_write(Sg_fd * sfp, Sg_request * srp,
return k; /* probably out of space --> ENOMEM */
}
if (sdp->detached) {
if (srp->bio)
if (srp->bio) {
if (srp->rq->cmd != srp->rq->__cmd)
kfree(srp->rq->cmd);
blk_end_request_all(srp->rq, -EIO);
srp->rq = NULL;
}

sg_finish_rem_req(srp);
return -ENODEV;
}
Expand Down
28 changes: 18 additions & 10 deletions drivers/staging/android/binder.c
Original file line number Diff line number Diff line change
Expand Up @@ -1085,20 +1085,24 @@ static int binder_dec_node(struct binder_node *node, int strong, int internal)


static struct binder_ref *binder_get_ref(struct binder_proc *proc,
uint32_t desc)
uint32_t desc, bool need_strong_ref)
{
struct rb_node *n = proc->refs_by_desc.rb_node;
struct binder_ref *ref;

while (n) {
ref = rb_entry(n, struct binder_ref, rb_node_desc);

if (desc < ref->desc)
if (desc < ref->desc) {
n = n->rb_left;
else if (desc > ref->desc)
} else if (desc > ref->desc) {
n = n->rb_right;
else
} else if (need_strong_ref && !ref->strong) {
binder_user_error("tried to use weak ref as strong ref\n");
return NULL;
} else {
return ref;
}
}
return NULL;
}
Expand Down Expand Up @@ -1370,7 +1374,8 @@ static void binder_transaction_buffer_release(struct binder_proc *proc,
} break;
case BINDER_TYPE_HANDLE:
case BINDER_TYPE_WEAK_HANDLE: {
struct binder_ref *ref = binder_get_ref(proc, fp->handle);
struct binder_ref *ref = binder_get_ref(proc, fp->handle,
fp->type == BINDER_TYPE_HANDLE);
if (ref == NULL) {
printk(KERN_ERR "binder: transaction release %d"
" bad handle %ld\n", debug_id,
Expand Down Expand Up @@ -1469,7 +1474,7 @@ static void binder_transaction(struct binder_proc *proc,
} else {
if (tr->target.handle) {
struct binder_ref *ref;
ref = binder_get_ref(proc, tr->target.handle);
ref = binder_get_ref(proc, tr->target.handle, true);
if (ref == NULL) {
binder_user_error("binder: %d:%d got "
"transaction to invalid handle\n",
Expand Down Expand Up @@ -1674,7 +1679,8 @@ static void binder_transaction(struct binder_proc *proc,
} break;
case BINDER_TYPE_HANDLE:
case BINDER_TYPE_WEAK_HANDLE: {
struct binder_ref *ref = binder_get_ref(proc, fp->handle);
struct binder_ref *ref = binder_get_ref(proc, fp->handle,
fp->type == BINDER_TYPE_HANDLE);
if (ref == NULL) {
binder_user_error("binder: %d:%d got "
"transaction with invalid "
Expand Down Expand Up @@ -1881,7 +1887,9 @@ int binder_thread_write(struct binder_proc *proc, struct binder_thread *thread,
ref->desc);
}
} else
ref = binder_get_ref(proc, target);
ref = binder_get_ref(proc, target,
cmd == BC_ACQUIRE ||
cmd == BC_RELEASE);
if (ref == NULL) {
binder_user_error("binder: %d:%d refcou"
"nt change on invalid ref %d\n",
Expand Down Expand Up @@ -2092,7 +2100,7 @@ int binder_thread_write(struct binder_proc *proc, struct binder_thread *thread,
if (get_user(cookie, (void __user * __user *)ptr))
return -EFAULT;
ptr += sizeof(void *);
ref = binder_get_ref(proc, target);
ref = binder_get_ref(proc, target, false);
if (ref == NULL) {
binder_user_error("binder: %d:%d %s "
"invalid ref %d\n",
Expand Down Expand Up @@ -3363,7 +3371,7 @@ static void print_binder_node(struct seq_file *m, struct binder_node *node)

static void print_binder_ref(struct seq_file *m, struct binder_ref *ref)
{
seq_printf(m, " ref %d: desc %d %snode %d s %d w %d d %p\n",
seq_printf(m, " ref %d: desc %d %snode %d s %d w %d d %pK\n",
ref->debug_id, ref->desc, ref->node->proc ? "" : "dead ",
ref->node->debug_id, ref->strong, ref->weak, ref->death);
}
Expand Down
1 change: 1 addition & 0 deletions drivers/staging/android/lowmemorykiller.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ static int lowmem_shrink(struct shrinker *s, struct shrink_control *sc)
global_page_state(NR_FILE_PAGES))
other_file = global_page_state(NR_FILE_PAGES) -
global_page_state(NR_SHMEM) -
global_page_state(NR_UNEVICTABLE) -
total_swapcache_pages;
else
other_file = 0;
Expand Down
7 changes: 7 additions & 0 deletions drivers/tty/tty_ldisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,10 @@ EXPORT_SYMBOL_GPL(tty_ldisc_flush);
* they are not on hot paths so a little discipline won't do
* any harm.
*
* The line discipline-related tty_struct fields are reset to
* prevent the ldisc driver from re-using stale information for
* the new ldisc instance.
*
* Locking: takes termios_mutex
*/

Expand All @@ -414,6 +418,9 @@ static void tty_set_termios_ldisc(struct tty_struct *tty, int num)
mutex_lock(&tty->termios_mutex);
tty->termios->c_line = num;
mutex_unlock(&tty->termios_mutex);

tty->disc_data = NULL;
tty->receive_room = 0;
}

/**
Expand Down
7 changes: 7 additions & 0 deletions fs/ext4/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -3376,6 +3376,7 @@ int ext4_can_truncate(struct inode *inode)

int ext4_punch_hole(struct file *file, loff_t offset, loff_t length)
{
#if 0
struct inode *inode = file->f_path.dentry->d_inode;
if (!S_ISREG(inode->i_mode))
return -EOPNOTSUPP;
Expand All @@ -3391,6 +3392,12 @@ int ext4_punch_hole(struct file *file, loff_t offset, loff_t length)
}

return ext4_ext_punch_hole(file, offset, length);
#else
/*
* Disabled as per b/28760453
*/
return -EOPNOTSUPP;
#endif
}

/*
Expand Down
2 changes: 2 additions & 0 deletions fs/ioprio.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,11 @@ static int get_task_ioprio(struct task_struct *p)
ret = security_task_getioprio(p);
if (ret)
goto out;
task_lock(p);
ret = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, IOPRIO_NORM);
if (p->io_context)
ret = p->io_context->ioprio;
task_unlock(p);
out:
return ret;
}
Expand Down
3 changes: 0 additions & 3 deletions fs/proc/namespaces.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ static const struct proc_ns_operations *ns_entries[] = {
#endif
#ifdef CONFIG_IPC_NS
&ipcns_operations,
#endif
#ifdef CONFIG_PID_NS
&pidns_operations,
#endif
&mntns_operations,
};
Expand Down
4 changes: 2 additions & 2 deletions fs/sdcardfs/derived_perm.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void fixup_perms_recursive(struct dentry *dentry, const char* name, size_t len)
}
} else if (descendant_may_need_fixup(info->perm)) {
mutex_lock(&dentry->d_inode->i_mutex);
list_for_each_entry(child, &dentry->d_subdirs, d_u.d_child) {
list_for_each_entry(child, &dentry->d_subdirs, d_child) {
fixup_perms_recursive(child, name, len);
}
mutex_unlock(&dentry->d_inode->i_mutex);
Expand All @@ -164,7 +164,7 @@ void fixup_top_recursive(struct dentry *parent) {
return;
info = SDCARDFS_I(parent->d_inode);
spin_lock(&parent->d_lock);
list_for_each_entry(dentry, &parent->d_subdirs, d_u.d_child) {
list_for_each_entry(dentry, &parent->d_subdirs, d_child) {
if (dentry->d_inode) {
if (SDCARDFS_I(parent->d_inode)->top != SDCARDFS_I(dentry->d_inode)->top) {
get_derived_permission(parent, dentry);
Expand Down
8 changes: 8 additions & 0 deletions fs/sdcardfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ static int sdcardfs_open(struct inode *inode, struct file *file)
/* save current_cred and override it */
OVERRIDE_CRED(sbi, saved_cred);

file->f_mode |= FMODE_NONMAPPABLE;
file->private_data =
kzalloc(sizeof(struct sdcardfs_file_info), GFP_KERNEL);
if (!SDCARDFS_F(file)) {
Expand Down Expand Up @@ -323,6 +324,11 @@ static int sdcardfs_fasync(int fd, struct file *file, int flag)
return err;
}

static struct file *sdcardfs_get_lower_file(struct file *f)
{
return sdcardfs_lower_file(f);
}

const struct file_operations sdcardfs_main_fops = {
.llseek = generic_file_llseek,
.read = sdcardfs_read,
Expand All @@ -337,6 +343,7 @@ const struct file_operations sdcardfs_main_fops = {
.release = sdcardfs_file_release,
.fsync = sdcardfs_fsync,
.fasync = sdcardfs_fasync,
.get_lower_file = sdcardfs_get_lower_file,
};

/* trimmed directory options */
Expand All @@ -353,4 +360,5 @@ const struct file_operations sdcardfs_dir_fops = {
.flush = sdcardfs_flush,
.fsync = sdcardfs_fsync,
.fasync = sdcardfs_fasync,
.get_lower_file = sdcardfs_get_lower_file,
};
9 changes: 7 additions & 2 deletions fs/sdcardfs/lookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,13 @@ struct inode *sdcardfs_iget(struct super_block *sb, struct inode *lower_inode, u
return ERR_PTR(err);
}
/* if found a cached inode, then just return it */
if (!(inode->i_state & I_NEW))
if (!(inode->i_state & I_NEW)) {
/* There can only be one alias, as we don't permit hard links
* This ensures we do not keep stale dentries that would later
* cause confusion. */
d_prune_aliases(inode);
return inode;
}

/* initialize new inode */
info = SDCARDFS_I(inode);
Expand Down Expand Up @@ -244,7 +249,7 @@ static struct dentry *__sdcardfs_lookup(struct dentry *dentry,
struct dentry *child;
struct dentry *match = NULL;
spin_lock(&lower_dir_dentry->d_lock);
list_for_each_entry(child, &lower_dir_dentry->d_subdirs, d_u.d_child) {
list_for_each_entry(child, &lower_dir_dentry->d_subdirs, d_child) {
if (child && child->d_inode) {
if (strcasecmp(child->d_name.name, name)==0) {
match = dget(child);
Expand Down
2 changes: 1 addition & 1 deletion fs/sdcardfs/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ static int sdcardfs_read_super(struct super_block *sb, const char *dev_name,
sb_info->options.fs_low_uid,
sb_info->options.fs_low_gid, 00755);*/
} else {
setup_derived_state(sb->s_root->d_inode, PERM_ROOT, sb_info->options.fs_low_uid, AID_ROOT, false, sb->s_root->d_inode);
setup_derived_state(sb->s_root->d_inode, PERM_ROOT, sb_info->options.fs_user_id, AID_ROOT, false, sb->s_root->d_inode);
snprintf(sb_info->obbpath_s, PATH_MAX, "%s/Android/obb", dev_name);
}
fix_derived_permission(sb->s_root->d_inode);
Expand Down
4 changes: 4 additions & 0 deletions include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ struct inodes_stat_t {
/* File is opened with O_PATH; almost nothing can be done with it */
#define FMODE_PATH ((__force fmode_t)0x4000)

/* File hasn't page cache and can't be mmaped, for stackable filesystem */
#define FMODE_NONMAPPABLE ((__force fmode_t)0x400000)

/* File was opened by fanotify and shouldn't generate fanotify events */
#define FMODE_NONOTIFY ((__force fmode_t)0x1000000)

Expand Down Expand Up @@ -1645,6 +1648,7 @@ struct file_operations {
int (*setlease)(struct file *, long, struct file_lock **);
long (*fallocate)(struct file *file, int mode, loff_t offset,
loff_t len);
struct file* (*get_lower_file)(struct file *f);
};

struct inode_operations {
Expand Down
1 change: 0 additions & 1 deletion include/linux/proc_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ struct proc_ns_operations {
extern const struct proc_ns_operations netns_operations;
extern const struct proc_ns_operations utsns_operations;
extern const struct proc_ns_operations ipcns_operations;
extern const struct proc_ns_operations pidns_operations;
extern const struct proc_ns_operations mntns_operations;

union proc_op {
Expand Down
Loading

0 comments on commit 2288023

Please sign in to comment.