aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2019-04-04 03:01:23 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2019-04-04 03:01:23 +0000
commit3c322a224807a4d4b95b709797f0667c3c0df97e (patch)
treebce42a46d75de5e3ccd1d7470af79810bc2cd19d
parenta1a4a17c8bb54366deca9cdeabb3c43865f5f15a (diff)
parentdb83b156a85bf531c967adb00e649d55d7238dc7 (diff)
downloadbcc-android10-tests-release.tar.gz
Snap for 5434517 from db83b156a85bf531c967adb00e649d55d7238dc7 to qt-releaseandroid-vts-10.0_r9android-vts-10.0_r8android-vts-10.0_r7android-vts-10.0_r6android-vts-10.0_r5android-vts-10.0_r4android-vts-10.0_r3android-vts-10.0_r2android-vts-10.0_r16android-vts-10.0_r15android-vts-10.0_r14android-vts-10.0_r13android-vts-10.0_r12android-vts-10.0_r11android-vts-10.0_r10android-vts-10.0_r1android-security-10.0.0_r75android-security-10.0.0_r74android-security-10.0.0_r73android-security-10.0.0_r72android-security-10.0.0_r71android-security-10.0.0_r70android-security-10.0.0_r69android-security-10.0.0_r68android-security-10.0.0_r67android-security-10.0.0_r66android-security-10.0.0_r65android-security-10.0.0_r64android-security-10.0.0_r63android-security-10.0.0_r62android-security-10.0.0_r61android-security-10.0.0_r60android-security-10.0.0_r59android-security-10.0.0_r58android-security-10.0.0_r57android-security-10.0.0_r56android-security-10.0.0_r55android-security-10.0.0_r54android-security-10.0.0_r53android-security-10.0.0_r52android-security-10.0.0_r51android-security-10.0.0_r50android-security-10.0.0_r49android-security-10.0.0_r48android-mainline-10.0.0_r3android-mainline-10.0.0_r2android-mainline-10.0.0_r1android-cts-10.0_r9android-cts-10.0_r8android-cts-10.0_r7android-cts-10.0_r6android-cts-10.0_r5android-cts-10.0_r4android-cts-10.0_r3android-cts-10.0_r2android-cts-10.0_r16android-cts-10.0_r15android-cts-10.0_r14android-cts-10.0_r13android-cts-10.0_r12android-cts-10.0_r11android-cts-10.0_r10android-cts-10.0_r1android-10.0.0_r6android-10.0.0_r5android-10.0.0_r47android-10.0.0_r46android-10.0.0_r4android-10.0.0_r3android-10.0.0_r2android-10.0.0_r17android-10.0.0_r11android-10.0.0_r10android-10.0.0_r1android10-tests-releaseandroid10-security-releaseandroid10-s3-releaseandroid10-s2-releaseandroid10-s1-releaseandroid10-releaseandroid10-mainline-releaseandroid10-mainline-a-releaseandroid10-gsi
Change-Id: I7fc77778c6ef71cb62a0b29b428264a9d159d616
-rw-r--r--src/cc/libbpf.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/cc/libbpf.c b/src/cc/libbpf.c
index 9852f8ca..1cf315a2 100644
--- a/src/cc/libbpf.c
+++ b/src/cc/libbpf.c
@@ -385,7 +385,7 @@ int bpf_prog_compute_tag(const struct bpf_insn *insns, int prog_len,
.salg_type = "hash",
.salg_name = "sha1",
};
- int shafd = socket(AF_ALG, SOCK_SEQPACKET, 0);
+ int shafd = socket(AF_ALG, SOCK_SEQPACKET | SOCK_CLOEXEC, 0);
if (shafd < 0) {
fprintf(stderr, "sha1 socket not available %s\n", strerror(errno));
return -1;
@@ -396,7 +396,7 @@ int bpf_prog_compute_tag(const struct bpf_insn *insns, int prog_len,
close(shafd);
return ret;
}
- int shafd2 = accept(shafd, NULL, 0);
+ int shafd2 = accept4(shafd, NULL, 0, SOCK_CLOEXEC);
if (shafd2 < 0) {
fprintf(stderr, "sha1 accept fail %s\n", strerror(errno));
close(shafd);
@@ -448,7 +448,7 @@ int bpf_prog_get_tag(int fd, unsigned long long *ptag)
{
char fmt[64];
snprintf(fmt, sizeof(fmt), "/proc/self/fdinfo/%d", fd);
- FILE * f = fopen(fmt, "r");
+ FILE * f = fopen(fmt, "re");
if (!f) {
/* fprintf(stderr, "failed to open fdinfo %s\n", strerror(errno));*/
return -1;
@@ -668,7 +668,7 @@ static int bpf_find_probe_type(const char *event_type)
if (ret < 0 || ret >= (int)sizeof(buf))
return -1;
- fd = open(buf, O_RDONLY);
+ fd = open(buf, O_RDONLY | O_CLOEXEC);
if (fd < 0)
return -1;
ret = read(fd, buf, sizeof(buf));
@@ -691,7 +691,7 @@ static int bpf_get_retprobe_bit(const char *event_type)
if (ret < 0 || ret >= (int)sizeof(buf))
return -1;
- fd = open(buf, O_RDONLY);
+ fd = open(buf, O_RDONLY | O_CLOEXEC);
if (fd < 0)
return -1;
ret = read(fd, buf, sizeof(buf));
@@ -779,7 +779,7 @@ static int bpf_attach_tracing_event(int progfd, const char *event_path, int pid,
// event path provided.
if (*pfd < 0) {
snprintf(buf, sizeof(buf), "%s/id", event_path);
- efd = open(buf, O_RDONLY, 0);
+ efd = open(buf, O_RDONLY | O_CLOEXEC, 0);
if (efd < 0) {
fprintf(stderr, "open(%s): %s\n", buf, strerror(errno));
return -1;
@@ -839,7 +839,7 @@ int bpf_attach_kprobe(int progfd, enum bpf_probe_attach_type attach_type,
// yet. Try create the event using debugfs.
if (pfd < 0) {
snprintf(buf, sizeof(buf), "/sys/kernel/debug/tracing/%s_events", event_type);
- kfd = open(buf, O_WRONLY | O_APPEND, 0);
+ kfd = open(buf, O_WRONLY | O_APPEND | O_CLOEXEC, 0);
if (kfd < 0) {
fprintf(stderr, "open(%s): %s\n", buf, strerror(errno));
goto error;
@@ -889,13 +889,13 @@ static int enter_mount_ns(int pid) {
if ((size_t)snprintf(buf, sizeof(buf), "/proc/%d/ns/mnt", pid) >= sizeof(buf))
return -1;
- self_fd = open("/proc/self/ns/mnt", O_RDONLY);
+ self_fd = open("/proc/self/ns/mnt", O_RDONLY | O_CLOEXEC);
if (self_fd < 0) {
perror("open(/proc/self/ns/mnt)");
return -1;
}
- target_fd = open(buf, O_RDONLY);
+ target_fd = open(buf, O_RDONLY | O_CLOEXEC);
if (target_fd < 0) {
perror("open(/proc/<pid>/ns/mnt)");
goto error;
@@ -955,7 +955,7 @@ int bpf_attach_uprobe(int progfd, enum bpf_probe_attach_type attach_type,
// yet. Try create the event using debugfs.
if (pfd < 0) {
snprintf(buf, sizeof(buf), "/sys/kernel/debug/tracing/%s_events", event_type);
- kfd = open(buf, O_WRONLY | O_APPEND, 0);
+ kfd = open(buf, O_WRONLY | O_APPEND | O_CLOEXEC, 0);
if (kfd < 0) {
fprintf(stderr, "open(%s): %s\n", buf, strerror(errno));
goto error;
@@ -1017,7 +1017,7 @@ static int bpf_detach_probe(const char *ev_name, const char *event_type)
* it is safe to skip the cleaning up process (write -:... to the file).
*/
snprintf(buf, sizeof(buf), "/sys/kernel/debug/tracing/%s_events", event_type);
- fp = fopen(buf, "r");
+ fp = fopen(buf, "re");
if (!fp) {
fprintf(stderr, "open(%s): %s\n", buf, strerror(errno));
goto error;
@@ -1042,7 +1042,7 @@ static int bpf_detach_probe(const char *ev_name, const char *event_type)
return 0;
snprintf(buf, sizeof(buf), "/sys/kernel/debug/tracing/%s_events", event_type);
- kfd = open(buf, O_WRONLY | O_APPEND, 0);
+ kfd = open(buf, O_WRONLY | O_APPEND | O_CLOEXEC, 0);
if (kfd < 0) {
fprintf(stderr, "open(%s): %s\n", buf, strerror(errno));
goto error;
@@ -1242,7 +1242,7 @@ int bpf_attach_xdp(const char *dev_name, int progfd, uint32_t flags) {
memset(&sa, 0, sizeof(sa));
sa.nl_family = AF_NETLINK;
- sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
+ sock = socket(AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_ROUTE);
if (sock < 0) {
fprintf(stderr, "bpf: opening a netlink socket: %s\n", strerror(errno));
return -1;