[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 2/9] linux-user: do_setsockopt: fix SOL_ALG.ALG_SET_KEY
From: |
Richard Henderson |
Subject: |
[PULL 2/9] linux-user: do_setsockopt: fix SOL_ALG.ALG_SET_KEY |
Date: |
Wed, 24 Apr 2024 15:51:16 -0700 |
From: Michael Tokarev <mjt@tls.msk.ru>
This setsockopt accepts zero-lengh optlen (current qemu implementation
does not allow this). Also, there's no need to make a copy of the key,
it is enough to use lock_user() (which accepts zero length already).
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2197
Fixes: f31dddd2fc "linux-user: Add support for setsockopt() option SOL_ALG"
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Message-Id: <20240331100737.2724186-2-mjt@tls.msk.ru>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
linux-user/syscall.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 3df2b94d9a..59fb3e911f 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -2277,18 +2277,13 @@ static abi_long do_setsockopt(int sockfd, int level,
int optname,
switch (optname) {
case ALG_SET_KEY:
{
- char *alg_key = g_malloc(optlen);
-
+ char *alg_key = lock_user(VERIFY_READ, optval_addr, optlen, 1);
if (!alg_key) {
- return -TARGET_ENOMEM;
- }
- if (copy_from_user(alg_key, optval_addr, optlen)) {
- g_free(alg_key);
return -TARGET_EFAULT;
}
ret = get_errno(setsockopt(sockfd, level, optname,
alg_key, optlen));
- g_free(alg_key);
+ unlock_user(alg_key, optval_addr, optlen);
break;
}
case ALG_SET_AEAD_AUTHSIZE:
--
2.34.1
- [PULL 0/9] tcg + linux-user patch queue, Richard Henderson, 2024/04/24
- [PULL 1/9] meson: Make DEBUG_REMAP a meson option, Richard Henderson, 2024/04/24
- [PULL 2/9] linux-user: do_setsockopt: fix SOL_ALG.ALG_SET_KEY,
Richard Henderson <=
- [PULL 3/9] linux-user: do_setsockopt: make ip_mreq local to the place it is used and inline target_to_host_ip_mreq(), Richard Henderson, 2024/04/24
- [PULL 4/9] linux-user: do_setsockopt: make ip_mreq_source local to the place where it is used, Richard Henderson, 2024/04/24
- [PULL 5/9] linux-user: do_setsockopt: eliminate goto in switch for SO_SNDTIMEO, Richard Henderson, 2024/04/24
- [PULL 6/9] linux-user: Add FITRIM ioctl, Richard Henderson, 2024/04/24
- [PULL 7/9] target/m68k: Pass semihosting arg to exit, Richard Henderson, 2024/04/24
- [PULL 9/9] target/m68k: Support semihosting on non-ColdFire targets, Richard Henderson, 2024/04/24
- [PULL 8/9] target/m68k: Perform the semihosting test during translate, Richard Henderson, 2024/04/24
- Re: [PULL 0/9] tcg + linux-user patch queue, Richard Henderson, 2024/04/24