// https://syzkaller.appspot.com/bug?id=b798d2a1e35362e903d6c263ddc1743bf200b8f3 #include #include #include #include #include #include #include #include #define MAX_ACPI_DEVS 256 char acpi_files[MAX_ACPI_DEVS][256]; int num_acpi_files = 0; void *acpi_worker(void *arg) { char buf[256]; for (int i = 0; i < 1000; i++) { for (int j = 0; j < num_acpi_files; j++) { int fd = open(acpi_files[j], O_RDONLY); if (fd < 0) { printf("[-] Failed to open %s: %s\n", acpi_files[j], strerror(errno)); exit(1); } ssize_t n = read(fd, buf, sizeof(buf)); if (n < 0) { printf("[-] Failed to read %s: %s\n", acpi_files[j], strerror(errno)); exit(1); } if (close(fd) < 0) { printf("[-] Failed to close %s: %s\n", acpi_files[j], strerror(errno)); exit(1); } } } return NULL; } int main() { setvbuf(stdout, NULL, _IONBF, 0); DIR *dir = opendir("/sys/bus/acpi/devices"); if (!dir) { printf("[-] Failed to opendir /sys/bus/acpi/devices: %s\n", strerror(errno)); exit(1); } printf("[+] opendir /sys/bus/acpi/devices successful.\n"); struct dirent *ent; while ((ent = readdir(dir)) != NULL) { if (ent->d_name[0] == '.') continue; char path[256]; snprintf(path, sizeof(path), "/sys/bus/acpi/devices/%s/status", ent->d_name); if (access(path, R_OK) == 0) { int fd = open(path, O_RDONLY); if (fd < 0) { printf("[-] Failed to open %s during probe: %s\n", path, strerror(errno)); } else { char buf[256]; if (read(fd, buf, sizeof(buf)) < 0) { printf("[-] Failed to read %s during probe: %s\n", path, strerror(errno)); } else { strncpy(acpi_files[num_acpi_files++], path, 256); } if (close(fd) < 0) { printf("[-] Failed to close %s during probe: %s\n", path, strerror(errno)); } } } if (num_acpi_files >= MAX_ACPI_DEVS) break; snprintf(path, sizeof(path), "/sys/bus/acpi/devices/%s/path", ent->d_name); if (access(path, R_OK) == 0) { int fd = open(path, O_RDONLY); if (fd < 0) { printf("[-] Failed to open %s during probe: %s\n", path, strerror(errno)); } else { char buf[256]; if (read(fd, buf, sizeof(buf)) < 0) { printf("[-] Failed to read %s during probe: %s\n", path, strerror(errno)); } else { strncpy(acpi_files[num_acpi_files++], path, 256); } if (close(fd) < 0) { printf("[-] Failed to close %s during probe: %s\n", path, strerror(errno)); } } } if (num_acpi_files >= MAX_ACPI_DEVS) break; } if (closedir(dir) < 0) { printf("[-] Failed to closedir: %s\n", strerror(errno)); exit(1); } printf("[+] closedir successful.\n"); if (num_acpi_files == 0) { printf("[-] No readable ACPI status/path files found.\n"); exit(1); } printf("[+] Found %d ACPI files to read.\n", num_acpi_files); pthread_t threads[8]; for (int i = 0; i < 8; i++) { int res = pthread_create(&threads[i], NULL, acpi_worker, NULL); if (res != 0) { printf("[-] Failed to pthread_create: %s\n", strerror(res)); exit(1); } } printf("[+] Threads created successfully.\n"); for (int i = 0; i < 8; i++) { int res = pthread_join(threads[i], NULL); if (res != 0) { printf("[-] Failed to pthread_join: %s\n", strerror(res)); exit(1); } } printf("[+] Threads joined successfully.\n"); sleep(1); return 0; }