From patchwork Fri Nov 15 20:58:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 843513 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcc:0:b0:382:184f:390f with SMTP id e12csp1056983wrc; Fri, 15 Nov 2024 12:59:57 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWXiUasvOvbk57SjQLTzN1pLERab+0x7jEJBdefZ5yiQx8+Wa/Uzt/Sw0XXdvzof5OIlHRLlw==@linaro.org X-Google-Smtp-Source: AGHT+IG6c90I3LZVUExLiV69R0V5qkZgo1KD1BqqYxoNvFlH/f7/anur3w7g1O+B3bguSKGofp8F X-Received: by 2002:a05:620a:c4d:b0:7b1:4536:8dc1 with SMTP id af79cd13be357-7b36236406dmr626160585a.62.1731704397451; Fri, 15 Nov 2024 12:59:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1731704397; cv=none; d=google.com; s=arc-20240605; b=X+0l/bOenU19wtzgm/deLRLFdBrq0UqA2X99OdP0IcitUKq3tm+/WkO9Wh7gGpElz6 z/mr8pYu4H5PRzHeaoICSmHKITzJIzIYjkoZ+xIKWfE9T5Nz0j5z5Ez9tQQctFNa+828 lJqvVLcXp43K3ruMrchrx9R0j/+wRr4F/SyPdHylgS3DpEl/NuJraSVausFn2VvhkaeI hvnKSEGSiQrbGWyG9UYNbDnx4b7OiooqlSk5J2VoimF9XdDS+CFyfuLt1VjfsMMhXqLi hw1X/KVBY2Rty8yfE1BLhxO/d6ECAL4NmvckB2Mr0A2Mi14Bs5vMEMCI8+byifVJmSNl JfRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IefchHLUObrdReiKezDwvf7im5w8O51AN5OkZQmzJ08=; fh=qoFg0j8bGPifMOj9VfbL1YMQC3/qe81FjErpwoAQ4Cc=; b=cvw/QQ8DBQpgTEgDIU6VhqhwWgrtPZbUBiD3r8KyoZoYY1mS0lyD1WjnPSRzeVqICZ cDbetbblU6lsamOK1zOfSESOA0ru1zKXmTqAtnkgZKoCuTKWAtiEmfDVoufShPUke4cr fIaSRUS7OtpM+atdu02ZvRYoRXgQJ3PKrgUwMu1CfpxwsrkWqtHQv+cwlerxg/kdaLkw JUJFQPP5ehLmcE1GUh7qfL0GCSKu9p8j1tu/kLP42oozzVGXSfLEBHcQE2ZMjwBKByZx deMhZ6pNOiypdhvprM/8QYKalN3jNPTPHCgsxpQIWg+Bl+TwT9nSHLpeiX9jk0Fii7wl 0gcg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CoNftJ7Q; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b35c96f373si447743085a.142.2024.11.15.12.59.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Nov 2024 12:59:57 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CoNftJ7Q; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tC3P8-0007VX-AB; Fri, 15 Nov 2024 15:58:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tC3P5-0007U2-4Z for qemu-devel@nongnu.org; Fri, 15 Nov 2024 15:58:55 -0500 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tC3P3-0004M4-99 for qemu-devel@nongnu.org; Fri, 15 Nov 2024 15:58:54 -0500 Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-2ea0f91d381so57714a91.1 for ; Fri, 15 Nov 2024 12:58:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1731704332; x=1732309132; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IefchHLUObrdReiKezDwvf7im5w8O51AN5OkZQmzJ08=; b=CoNftJ7QhOgSBwunaGQ4fNfpun+k9w/yh4yNaKe0rOwSZi5wFeUWi0xCYL6aThu+9o pSKBsQHX9IRzfyWy0c84Q4mPte606+8ZlssYM+507H3dG6wYLlENTEORqDhRA5Qwc0VH n5DDGXECJMCU4c83QbOTixckYTLcaPqLe/gs7K8Qov7p4U9I1m1SYszgFlatPE3ETu2L 9jda/cfemuuiX92xe42zHFH5GzsWXOa1LCgtv27Go5eWyuPDDh/iLbFEeW59o4URCOnL UHFccIhqBe8YQxlHqyWCnhqw0KoFoGf8QvT7JdUxyTijSjSd3d9Z0N8TDXHM/IHBGh+Q isCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731704332; x=1732309132; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IefchHLUObrdReiKezDwvf7im5w8O51AN5OkZQmzJ08=; b=wehsNO3P/IUp+jElAzlZFUNmSLiQ5+CmFEb7AEItadkKsIe61tvHYOWdZH2EhUCGu6 tuMy/DKnSb0MVzvIjEtpyByiRRHqGwxmZQct+bI+lRPg0pfm2qIkbNNesDMCaMu56GTJ a6JMII3KDOTxL86PwT3Pc5gNdZ37+x5iZzfBLgV1lzguzfXwk/nYsNtOZ2+x6S0atCCY QLhQS+MnIXrNeVXfWGDAdsQTJN4iZHPLUMgJhsJ6IzUPaHF/ocyPPPYgDWbEfCod5uQE qTw9vk/8FCnO1jWrzae58fpBtGbW2ykNQtjoJLN19ypwqnLLdYBpvFq1c0NqHost4fcb XjdQ== X-Gm-Message-State: AOJu0YwVb7bAKaJ1hMxpbIAuf/u2512we8ypP69n+0quISr9QBf6+2/J ANF1oCd2owJLeZEGsSH0Hm5+rl4HZnLBjE+TH2INlhiAGmWwsnY9pCnOgCOIG/vm3wUsUcAw65+ n X-Received: by 2002:a17:90b:4ecd:b0:2e2:cd5e:7eef with SMTP id 98e67ed59e1d1-2ea15585ba3mr4287368a91.27.1731704331827; Fri, 15 Nov 2024 12:58:51 -0800 (PST) Received: from stoup.. ([71.212.136.242]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2ea024a49a8sm3362274a91.23.2024.11.15.12.58.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2024 12:58:51 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Helge Deller , qemu-stable@nongnu.org, Helge Deller , Ilya Leoshkevich Subject: [PULL 01/14] linux-user: Fix setreuid and setregid to use direct syscalls Date: Fri, 15 Nov 2024 12:58:36 -0800 Message-ID: <20241115205849.266094-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241115205849.266094-1-richard.henderson@linaro.org> References: <20241115205849.266094-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1033; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1033.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Helge Deller The commit fd6f7798ac30 ("linux-user: Use direct syscalls for setuid(), etc") added direct syscall wrappers for setuid(), setgid(), etc since the system calls have different semantics than the libc functions. Add and use the corresponding wrappers for setreuid and setregid which were missed in that commit. This fixes the build of the debian package of the uid_wrapper library (https://cwrap.org/uid_wrapper.html) when running linux-user. Cc: qemu-stable@nongnu.org Signed-off-by: Helge Deller Reviewed-by: Richard Henderson Reviewed-by: Ilya Leoshkevich Message-ID: Signed-off-by: Richard Henderson --- linux-user/syscall.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 59b2080b98..0279f23576 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7233,12 +7233,24 @@ static inline int tswapid(int id) #else #define __NR_sys_setgroups __NR_setgroups #endif +#ifdef __NR_sys_setreuid32 +#define __NR_sys_setreuid __NR_setreuid32 +#else +#define __NR_sys_setreuid __NR_setreuid +#endif +#ifdef __NR_sys_setregid32 +#define __NR_sys_setregid __NR_setregid32 +#else +#define __NR_sys_setregid __NR_setregid +#endif _syscall1(int, sys_setuid, uid_t, uid) _syscall1(int, sys_setgid, gid_t, gid) _syscall3(int, sys_setresuid, uid_t, ruid, uid_t, euid, uid_t, suid) _syscall3(int, sys_setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid) _syscall2(int, sys_setgroups, int, size, gid_t *, grouplist) +_syscall2(int, sys_setreuid, uid_t, ruid, uid_t, euid); +_syscall2(int, sys_setregid, gid_t, rgid, gid_t, egid); void syscall_init(void) { @@ -11932,9 +11944,9 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, return get_errno(high2lowgid(getegid())); #endif case TARGET_NR_setreuid: - return get_errno(setreuid(low2highuid(arg1), low2highuid(arg2))); + return get_errno(sys_setreuid(low2highuid(arg1), low2highuid(arg2))); case TARGET_NR_setregid: - return get_errno(setregid(low2highgid(arg1), low2highgid(arg2))); + return get_errno(sys_setregid(low2highgid(arg1), low2highgid(arg2))); case TARGET_NR_getgroups: { /* the same code as for TARGET_NR_getgroups32 */ int gidsetsize = arg1; @@ -12264,11 +12276,11 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, #endif #ifdef TARGET_NR_setreuid32 case TARGET_NR_setreuid32: - return get_errno(setreuid(arg1, arg2)); + return get_errno(sys_setreuid(arg1, arg2)); #endif #ifdef TARGET_NR_setregid32 case TARGET_NR_setregid32: - return get_errno(setregid(arg1, arg2)); + return get_errno(sys_setregid(arg1, arg2)); #endif #ifdef TARGET_NR_getgroups32 case TARGET_NR_getgroups32: