| 1 |
/* { dg-do compile } */ |
| 2 |
// TODO: remove need for --param=analyzer-max-svalue-depth=25 here: |
| 3 |
/* { dg-options "-fanalyzer --param=analyzer-max-svalue-depth=25" } */ |
| 4 |
/* { dg-additional-options "-Wno-pedantic" } */ |
| 5 |
/* { dg-require-effective-target analyzer } */ |
| 6 |
|
| 7 |
/* See notes in this header. */ |
| 8 |
#include "taint-CVE-2011-0521.h" |
| 9 |
|
| 10 |
/* Adapted from dvb_ca_ioctl in drivers/media/dvb/ttpci/av7110_ca.c and |
| 11 |
dvb_usercopy in drivers/media/dvb/dvb-core/dvbdev.c |
| 12 |
|
| 13 |
Further simplified from -3; merge into a single function; drop the mutex, |
| 14 |
remove control flow. */ |
| 15 |
|
| 16 |
int test_1(struct file *file, unsigned int cmd, unsigned long arg) |
| 17 |
{ |
| 18 |
char sbuf[128]; |
| 19 |
void *parg = sbuf; |
| 20 |
|
| 21 |
if (copy_from_user(parg, (void __user *)arg, sizeof(sbuf))) |
| 22 |
return -1; |
| 23 |
|
| 24 |
{ |
| 25 |
struct dvb_device *dvbdev = file->private_data; |
| 26 |
struct av7110 *av7110 = dvbdev->priv; |
| 27 |
unsigned long arg = (unsigned long) parg; |
| 28 |
|
| 29 |
/* case CA_GET_SLOT_INFO: */ |
| 30 |
ca_slot_info_t *info=(ca_slot_info_t *)parg; |
| 31 |
|
| 32 |
if (info->num > 1) |
| 33 |
return -EINVAL; |
| 34 |
av7110->ci_slot[info->num].num = info->num; /* { dg-warning "attacker-controlled value" } */ |
| 35 |
av7110->ci_slot[info->num].type = FW_CI_LL_SUPPORT(av7110->arm_app) ? |
| 36 |
CA_CI_LINK : CA_CI; |
| 37 |
memcpy(info, &av7110->ci_slot[info->num], sizeof(ca_slot_info_t)); |
| 38 |
} |
| 39 |
|
| 40 |
copy_to_user((void __user *)arg, parg, sizeof(sbuf)); |
| 41 |
|
| 42 |
return 0; |
| 43 |
} |