Skip to content

Commit

Permalink
Revert "BACKPORT: binder: remove unneeded size check code"
Browse files Browse the repository at this point in the history
This reverts commit 28879c9a288dec7d596ab125cc6e15010731d620.

Signed-off-by: iusmac <[email protected]>
  • Loading branch information
iusmac authored and zeelog committed Sep 10, 2024
1 parent a5c0cd8 commit f79d800
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions drivers/android/binder.c
Original file line number Diff line number Diff line change
Expand Up @@ -4847,14 +4847,20 @@ static unsigned int binder_poll(struct file *filp,
return 0;
}

static int binder_ioctl_write_read(struct file *filp, unsigned long arg,
static int binder_ioctl_write_read(struct file *filp,
unsigned int cmd, unsigned long arg,
struct binder_thread *thread)
{
int ret = 0;
struct binder_proc *proc = filp->private_data;
unsigned int size = _IOC_SIZE(cmd);
void __user *ubuf = (void __user *)arg;
struct binder_write_read bwr;

if (size != sizeof(struct binder_write_read)) {
ret = -EINVAL;
goto out;
}
if (copy_from_user(&bwr, ubuf, sizeof(bwr))) {
ret = -EFAULT;
goto out;
Expand Down Expand Up @@ -5020,6 +5026,7 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
int ret;
struct binder_proc *proc = filp->private_data;
struct binder_thread *thread;
unsigned int size = _IOC_SIZE(cmd);
void __user *ubuf = (void __user *)arg;

/*pr_info("binder_ioctl: %d:%d %x %lx\n",
Expand All @@ -5041,7 +5048,7 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)

switch (cmd) {
case BINDER_WRITE_READ:
ret = binder_ioctl_write_read(filp, arg, thread);
ret = binder_ioctl_write_read(filp, cmd, arg, thread);
if (ret)
goto err;
break;
Expand Down Expand Up @@ -5084,6 +5091,10 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
case BINDER_VERSION: {
struct binder_version __user *ver = ubuf;

if (size != sizeof(struct binder_version)) {
ret = -EINVAL;
goto err;
}
if (put_user(BINDER_CURRENT_PROTOCOL_VERSION,
&ver->protocol_version)) {
ret = -EINVAL;
Expand Down

0 comments on commit f79d800

Please sign in to comment.