From patchwork Wed Jul 18 12:11:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Dickson X-Patchwork-Id: 10532313 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 570C76053F for ; Wed, 18 Jul 2018 12:11:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 461CD28FA4 for ; Wed, 18 Jul 2018 12:11:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A72228FB2; Wed, 18 Jul 2018 12:11:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CEB3428FBC for ; Wed, 18 Jul 2018 12:11:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731144AbeGRMsq (ORCPT ); Wed, 18 Jul 2018 08:48:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59984 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730213AbeGRMsq (ORCPT ); Wed, 18 Jul 2018 08:48:46 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 23DFB308330B for ; Wed, 18 Jul 2018 12:11:09 +0000 (UTC) Received: from steved.boston.devel.redhat.com (ovpn-117-174.phx2.redhat.com [10.3.117.174]) by smtp.corp.redhat.com (Postfix) with ESMTP id D087C5D9C6 for ; Wed, 18 Jul 2018 12:11:08 +0000 (UTC) From: Steve Dickson To: Linux NFS Mailing list Subject: [PATCH] rpc.gssd: truncates 32-bit UIDs/GIDs to 16 bits architectures. Date: Wed, 18 Jul 2018 08:11:07 -0400 Message-Id: <20180718121107.16838-1-steved@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 18 Jul 2018 12:11:09 +0000 (UTC) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP utils/gssd_proc.c uses SYS_setresuid and SYS_setresgid in change_identity when it should use SYS_setresuid32 and SYS_setresgid32 instead. This causes it to truncate UIDs/GIDs > 65536. Fixes: https://bugs.launchpad.net/ubuntu/+source/nfs-utils/+bug/1779962 Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1595927 Tested-by: James Ettle Tested-by: Sree Signed-off-by: Steve Dickson --- utils/gssd/gssd_proc.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/utils/gssd/gssd_proc.c b/utils/gssd/gssd_proc.c index 8767e26..7a57c4e 100644 --- a/utils/gssd/gssd_proc.c +++ b/utils/gssd/gssd_proc.c @@ -434,6 +434,7 @@ static int change_identity(uid_t uid) { struct passwd *pw; + int res; /* drop list of supplimentary groups first */ if (syscall(SYS_setgroups, 0, 0) != 0) { @@ -459,14 +460,23 @@ change_identity(uid_t uid) * send a signal to all other threads to synchronize the uid in all * other threads. To bypass this, we have to call syscall() directly. */ - if (syscall(SYS_setresgid, pw->pw_gid, pw->pw_gid, pw->pw_gid) != 0) { +#ifdef __NR_setresuid32 + res = syscall(SYS_setresgid32, pw->pw_gid, pw->pw_gid, pw->pw_gid); +#else + res = syscall(SYS_setresgid, pw->pw_gid, pw->pw_gid, pw->pw_gid); +#endif + if (res != 0) { printerr(0, "WARNING: failed to set gid to %u!\n", pw->pw_gid); return errno; } - if (syscall(SYS_setresuid, uid, uid, uid) != 0) { - printerr(0, "WARNING: Failed to setuid for user with uid %u\n", - uid); +#ifdef __NR_setresuid32 + res = syscall(SYS_setresuid32, uid, uid, uid); +#else + res = syscall(SYS_setresuid, uid, uid, uid); +#endif + if (res != 0) { + printerr(0, "WARNING: Failed to setuid for user with uid %u\n", uid); return errno; }