summary refs log tree commit diff stats
path: root/gitlab/issues/target_missing/host_missing/accel_missing/2197.toml
diff options
context:
space:
mode:
Diffstat (limited to 'gitlab/issues/target_missing/host_missing/accel_missing/2197.toml')
-rw-r--r--gitlab/issues/target_missing/host_missing/accel_missing/2197.toml66
1 files changed, 66 insertions, 0 deletions
diff --git a/gitlab/issues/target_missing/host_missing/accel_missing/2197.toml b/gitlab/issues/target_missing/host_missing/accel_missing/2197.toml
new file mode 100644
index 00000000..7ad0c4d9
--- /dev/null
+++ b/gitlab/issues/target_missing/host_missing/accel_missing/2197.toml
@@ -0,0 +1,66 @@
+id = 2197
+title = "qemu user space emulator handles syscall `setsockopt()` with `optlen=0` incorrectly"
+state = "closed"
+created_at = "2024-02-27T15:35:13.642Z"
+closed_at = "2024-04-25T02:48:53.185Z"
+labels = ["kind::Bug", "linux-user", "workflow::Patch available"]
+url = "https://gitlab.com/qemu-project/qemu/-/issues/2197"
+host-os = "Arch Linux"
+host-arch = "x86_64"
+qemu-version = "8.2.1"
+guest-os = "Arch Linux rootfs"
+guest-arch = "RISC-V 64"
+description = """Note that despite I have only tested with the parameters/environments above, this problem probably **affects ALL architectures on Linux**.
+
+When user program calls `setsockopt(fd, SOL_ALG, ALG_SET_KEY, NULL, 0)`, qemu intercepts the syscall and returns `-1` with `errno = ENOMEM`, which should have completed successfully returning zero."""
+reproduce = """1. compile this code to binary executable:
+```c
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <linux/if_alg.h>
+
+int create_alg(const char *alg)
+{
+        struct sockaddr_alg salg;
+        int sk;
+
+        sk = socket(PF_ALG, SOCK_SEQPACKET | SOCK_CLOEXEC, 0);
+        if (sk < 0)
+                return -1;
+
+        memset(&salg, 0, sizeof(salg));
+        salg.salg_family = AF_ALG;
+        strcpy((char *) salg.salg_type, "hash");
+        strcpy((char *) salg.salg_name, alg);
+
+        if (bind(sk, (struct sockaddr *) &salg, sizeof(salg)) < 0) {
+                close(sk);
+                return -1;
+        }
+
+        return sk;
+}
+
+int main() {
+        int fd = create_alg("hmac(sha1)");
+        char buf[10];
+        int ret = setsockopt(fd, SOL_ALG, ALG_SET_KEY, NULL, 0);
+        if(ret < 0){
+                perror("err");
+        }
+        else{
+                puts("SUCCESS!");
+        }
+        return 0;
+}
+```
+2. run it in any qemu user space emulator
+
+On real Linux kernel, this program outputs a `SUCCESS!` while in qemu it prints `err: Cannot allocate memory`.
+
+The error is neither informative nor intuitive and could be misleading for user programs."""
+additional = """I already have a patch which fixes the issue and I'm willing to send it to mailing list as soon as I have done the testing."""