From patchwork Wed Jun 19 20:59:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 805644 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp14720wrt; Wed, 19 Jun 2024 14:03:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWg4dV85s/2rQ6yKpOxQQw61Uy4VUCeNuns20A41YLdmOBoSHfvbMLX1bj7yNcYHiQLyM7DRu5Rj6bXmCm5h4g0 X-Google-Smtp-Source: AGHT+IHPxa3xYgvaOre5fPiASwO2D0W+GtFiLjUIdQF4LP77JTJCpoB0KFMmueIl0coPfKHMtwBw X-Received: by 2002:ad4:4bb0:0:b0:6b4:ee84:905e with SMTP id 6a1803df08f44-6b501ea4245mr33764216d6.43.1718831001495; Wed, 19 Jun 2024 14:03:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718831001; cv=none; d=google.com; s=arc-20160816; b=yc3ahFCou3/8Wiy/2V4LBLmGElhdmNuSrbqJxdCa9tCdxn4KqeJA/H4YGXq8+WC9Vi a7aVaGnNVSR1BxroEbDgDsxpx56gYF9EcIxgSsZUMjrOt7fkL4ZWqB6rDylvVUO+hwc8 To24E1caqMdwZ0He/dCpEo36RTqMS/q2N6uL+aAsyE8C0yT0vblmi0j2Z8+I18DStQ9t wrmYeE0SidUoivX5x8kGEW2bxfEB0zJaglYfpC83AgsKpYQlVjufTaK9R3/4Xikq5vQs 2oYtzexZICPXmWo7gFZNA2rVhAMGZ4szgYJuFlID4SRVPst+EsblQh2ZqekOOi3nbD7h kBPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=3SDNjdEkTqvqZmekms95ys+/GW3YEsb5HtHOIrwzGFc=; fh=tXc8/PegD6StpQY3Zjfq1FUKW8t8Wvrgbx4ymQHH960=; b=DNYI0uTfwy3FLgV8daFpdPtg1EPhnO6x8bRHb23BeKHEb3fG1feKNs/cDSaXfdrXuj rzIDkwsxd3MplX1lQcvvqQLngAnH2Enjlgmgh2QDsJx81fZHrtCvVPpiLrfwWn4Yk0jO 7ZESp90aQQ2M6MhMQtbHR0F8CXkRzW0G6+r/L9qchMWDREMTOQFmOqeQl6/LB8Mrfvvk rPf8BTXdH4t+p5Y7Dei4KMIqdVdpKDKoof+SNK78y+tmGBcHo0qDqSSJJ6QmN9bgI6K0 g5BTeofGrxWLgKZ62P4pMQuVh+UlEUW90ZFF9WPaUOXmwF36yrGTFMv4OdhFZZ9Zzaqo ZJqw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ikZHgM/r"; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b2a5b7013fsi154896576d6.500.2024.06.19.14.03.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 19 Jun 2024 14:03:21 -0700 (PDT) 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="ikZHgM/r"; 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 Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sK2Pk-0002Nr-PM; Wed, 19 Jun 2024 17:00:20 -0400 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 1sK2Pi-0002Lu-Df for qemu-devel@nongnu.org; Wed, 19 Jun 2024 17:00:18 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sK2Pg-0000jK-Lc for qemu-devel@nongnu.org; Wed, 19 Jun 2024 17:00:18 -0400 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1f44b594deeso1815165ad.2 for ; Wed, 19 Jun 2024 14:00:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718830815; x=1719435615; 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=3SDNjdEkTqvqZmekms95ys+/GW3YEsb5HtHOIrwzGFc=; b=ikZHgM/rWxdhby3f+G9r9wK03T2EXP902AVvaZAzoTFTTbAPhk7bSnLDz8lGVw4Zk0 HooAv3VvguuYyLuVuqM0QQfdhXIiWCknH8qktNl5hUAag9dbg8QS2bkzaRx8mFd0axFv O9tC0yWyDOZb/5zgMWA16X1jjrHqJOi5d9EByxRB047hIhB+xTVOfkxmgAIl8TDB9ZSt PvOSllYJZtEhLlCfL+OlgCt16PW6jikv5mOdCasVkc4yxG86iFN+V5Rc8y0lLSwvtG08 +9qmzAy0rPMHcV0Pm5NzVPyEs7YDQNSZEISF1QA1enHAED6E6v02DvsEU3T4mxwOL5oV jg4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718830815; x=1719435615; 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=3SDNjdEkTqvqZmekms95ys+/GW3YEsb5HtHOIrwzGFc=; b=eA98S0ZX3FeUOl9+C007iEq0g4O7Wxe3H1FLgwCdgiNk+RtfNR087vhx+pCoQt4w0y 5Q1Awc1w7zOC/inUjASIYI470dRQBNPKSfK3cIpsZ1Rv6vABTsGMD26xVaXnMG1U14Ys tZ3QBdx0qh3JGv2UEfXySRBJ9A+/v3LsPTbPRjYe8ANze/YZefwkzyPZXQAn6OdvKQ6f HmuBj2CKEHuGGkH38ahJLCEsjI3OXfOBnrWwtWYJibrU+n8DFDlbze93Qg98IHajUymn qwHs/J9y8nGzGnZNeSaj6qGw1mvkMFvdvn2IHV4b0COFempTn638lI8Xvd2TyR5o+Qhd X5Iw== X-Gm-Message-State: AOJu0YwDDXEcoAtVThTvGJ/mbgFcgbI0uBwQ4KtF1n27956QiUK1ij/j Hb0tsRCVZr0F2U34PvkuS8/klzPjmxch2s8I3K3l/vQ+tV0xdUeHQ+vuu9K9a6IH3+aSakznp5B p X-Received: by 2002:a17:902:d581:b0:1f9:93fe:a1ea with SMTP id d9443c01a7336-1f9aa4335cbmr40059525ad.35.1718830814139; Wed, 19 Jun 2024 14:00:14 -0700 (PDT) Received: from stoup.. ([71.212.132.216]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f98f8f8c42sm39183765ad.162.2024.06.19.14.00.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jun 2024 14:00:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , qemu-stable@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 22/24] linux-user: Make TARGET_NR_setgroups affect only the current thread Date: Wed, 19 Jun 2024 13:59:50 -0700 Message-Id: <20240619205952.235946-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240619205952.235946-1-richard.henderson@linaro.org> References: <20240619205952.235946-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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, T_SCC_BODY_TEXT_LINE=-0.01 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: Ilya Leoshkevich Like TARGET_NR_setuid, TARGET_NR_setgroups should affect only the calling thread, and not the entire process. Therefore, implement it using a syscall, and not a libc call. Cc: qemu-stable@nongnu.org Fixes: 19b84f3c35d7 ("added setgroups and getgroups syscalls") Signed-off-by: Ilya Leoshkevich Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20240614154710.1078766-1-iii@linux.ibm.com> Reviewed-by: Richard Henderson Signed-off-by: Richard Henderson --- linux-user/syscall.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b9b5a387b3..e2804312fc 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7209,11 +7209,17 @@ static inline int tswapid(int id) #else #define __NR_sys_setresgid __NR_setresgid #endif +#ifdef __NR_setgroups32 +#define __NR_sys_setgroups __NR_setgroups32 +#else +#define __NR_sys_setgroups __NR_setgroups +#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) void syscall_init(void) { @@ -11891,7 +11897,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, unlock_user(target_grouplist, arg2, gidsetsize * sizeof(target_id)); } - return get_errno(setgroups(gidsetsize, grouplist)); + return get_errno(sys_setgroups(gidsetsize, grouplist)); } case TARGET_NR_fchown: return get_errno(fchown(arg1, low2highuid(arg2), low2highgid(arg3))); @@ -12227,7 +12233,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, } unlock_user(target_grouplist, arg2, 0); } - return get_errno(setgroups(gidsetsize, grouplist)); + return get_errno(sys_setgroups(gidsetsize, grouplist)); } #endif #ifdef TARGET_NR_fchown32