Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4645890pxu; Tue, 13 Oct 2020 03:50:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySia97IAUxM7i+guk1zdF0+YO3Txm4ts8rdeMsUwV2E1A0ZIHQ4HUiRyEkoP8ER4rgcrJ7 X-Received: by 2002:aa7:c442:: with SMTP id n2mr19146622edr.309.1602586243206; Tue, 13 Oct 2020 03:50:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602586243; cv=none; d=google.com; s=arc-20160816; b=S4fSu32p1o/Yh+2Njg4WBmdQ2o1r1YSVcn99Gs53B+9wIoTKeHkKPzdDEdEeUVB2Eo vf3af8CcbTAIpup+0I+efvyxsP3l0NyiHMsO1SbTrqcrJPPNMFnj3ayZvoyjeY6UgN7W qkXL9P5XyUraWxIsoakBYESfyfwATiV2D3OHB3nfnoYANGbw5SdAUJjwRJ7USP60IkX5 Yt9NPcaJyHraQDTS2ecohvIsaNls3TqYvfdDSY//ADlmICSkhDp9AaIQ5sCgUPHY60uW vA6RdI1sG+XDJN0aV2UvXFx+KkCdKI9j7PZ/Rz5uN36zRe3QjgNXVFYrdcgBp456pQRO xgtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=SblYN1e37CL9JdaGLQ5Y/6gLdI5UbuRc4P5/Ws+FaE0=; b=HIdauCjfFISX77ap4EhM+VgSgrJwRhtXDqYgpi4K+U5pHRhVnG4zJ1SkxC7cNWnUlG nm4icuvHo/uGZYlBfmbgvVkYok+9gknHaGJ1GzMc8f/4AQIzqdq7vDKBN317y8y51eDC qIFdyHZvn2cRpHggIBx4d0vxgQMTd8zY98T6N3d3ghHlLXk6SJdBPAml/eXua1Dnn0LM c+OgJRu54iozl25ZsOGWBuS6m1ssiSQVTA4fhp2gi9bZzgD52H/9vmth/3x4Tf9hGSOX BZu2x47s/NLoBjy/91YN5EJvMnEE+t6J9Gfe5/zq8S0T28nT7XtBYo91THuBjcmDmCIb UnwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sargun.me header.s=google header.b=trBiP6d4; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 65si14083380edc.222.2020.10.13.03.50.08; Tue, 13 Oct 2020 03:50:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@sargun.me header.s=google header.b=trBiP6d4; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730583AbgJLVn5 (ORCPT + 99 others); Mon, 12 Oct 2020 17:43:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730555AbgJLVn5 (ORCPT ); Mon, 12 Oct 2020 17:43:57 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A39A3C0613D1 for ; Mon, 12 Oct 2020 14:43:56 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id o9so9404949plx.10 for ; Mon, 12 Oct 2020 14:43:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sargun.me; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=SblYN1e37CL9JdaGLQ5Y/6gLdI5UbuRc4P5/Ws+FaE0=; b=trBiP6d4fYRQAfCdkqfM2hxAOmzzL+Ns2poC/dNnkAOtywmreZp1ZPUisBbEl43Q0b XCCJX6j3+KcWMzUSVnqkKEL4WKhOxK2eb95cqKCWqOzssj5Gwi9Gt3kwY6jKSYEvNEKZ 1c8JLeN+t3UeVSfmoMB6wpOEHRQoCnoUTvVGM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=SblYN1e37CL9JdaGLQ5Y/6gLdI5UbuRc4P5/Ws+FaE0=; b=B4AFNDRaerhfxt4xnek3zzbHkYY3o+yNTK0zRfym12ERTLHvDmXisqAxmZyUSh8RrH DoBaQ6jBc+xcau5hHqSIumq7QGL5TvIUQwO/SAAvsor1OiSOJiJOYfo+wixohIQlI/hd h7ulKSkRQd85fozlON7XDgLzuV+grN/6fcLQSZ1tklCEJ22YFsiP2ajonqF8MjbLrv7D nVdxYdZme2Lnx32fUrp36rNFJiVxo4tOa+qAvg1RBrE2kbaR3IYJallmSvppY4eK+sn2 D99iXmrCd0aEqF9WisDFDsD0PQbyV0c3TQufB9oUEUJXypArfkQVNwPF+Fmql3Ml/fxh FZOA== X-Gm-Message-State: AOAM530IBqmgfdoT5P1ZrtQkT4TwIaBTQ7sR0STugaqzMrwcuNNHVmdn jQMUo6rgGGwXNiF79ApIe3IoUw== X-Received: by 2002:a17:902:8d86:b029:d1:9237:6dfd with SMTP id v6-20020a1709028d86b02900d192376dfdmr25060401plo.22.1602539035925; Mon, 12 Oct 2020 14:43:55 -0700 (PDT) Received: from ubuntu.netflix.com (203.20.25.136.in-addr.arpa. [136.25.20.203]) by smtp.gmail.com with ESMTPSA id x5sm21284370pfp.113.2020.10.12.14.43.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 14:43:55 -0700 (PDT) From: Sargun Dhillon To: "J . Bruce Fields" , Chuck Lever , Trond Myklebust , Anna Schumaker Cc: Sargun Dhillon , linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] NFS: Only reference user namespace from nfs4idmap struct instead of cred Date: Mon, 12 Oct 2020 14:43:39 -0700 Message-Id: <20201012214339.6070-1-sargun@sargun.me> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org The nfs4idmapper only needs access to the user namespace, and not the entire cred struct. This replaces the struct cred* member with struct user_namespace*. This is mostly hygiene, so we don't have to hold onto the cred object, which has extraneous references to things like user_struct. This also makes switching away from init_user_ns more straightforward in the future. Signed-off-by: Sargun Dhillon --- fs/nfs/nfs4idmap.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/fs/nfs/nfs4idmap.c b/fs/nfs/nfs4idmap.c index 62e6eea5c516..8d8aba305ecc 100644 --- a/fs/nfs/nfs4idmap.c +++ b/fs/nfs/nfs4idmap.c @@ -46,6 +46,7 @@ #include #include #include +#include #include "internal.h" #include "netns.h" @@ -69,13 +70,13 @@ struct idmap { struct rpc_pipe *idmap_pipe; struct idmap_legacy_upcalldata *idmap_upcall_data; struct mutex idmap_mutex; - const struct cred *cred; + struct user_namespace *user_ns; }; static struct user_namespace *idmap_userns(const struct idmap *idmap) { - if (idmap && idmap->cred) - return idmap->cred->user_ns; + if (idmap && idmap->user_ns) + return idmap->user_ns; return &init_user_ns; } @@ -286,7 +287,7 @@ static struct key *nfs_idmap_request_key(const char *name, size_t namelen, if (ret < 0) return ERR_PTR(ret); - if (!idmap->cred || idmap->cred->user_ns == &init_user_ns) + if (!idmap->user_ns || idmap->user_ns == &init_user_ns) rkey = request_key(&key_type_id_resolver, desc, ""); if (IS_ERR(rkey)) { mutex_lock(&idmap->idmap_mutex); @@ -462,7 +463,7 @@ nfs_idmap_new(struct nfs_client *clp) return -ENOMEM; mutex_init(&idmap->idmap_mutex); - idmap->cred = get_cred(clp->cl_rpcclient->cl_cred); + idmap->user_ns = get_user_ns(clp->cl_rpcclient->cl_cred->user_ns); rpc_init_pipe_dir_object(&idmap->idmap_pdo, &nfs_idmap_pipe_dir_object_ops, @@ -486,7 +487,7 @@ nfs_idmap_new(struct nfs_client *clp) err_destroy_pipe: rpc_destroy_pipe_data(idmap->idmap_pipe); err: - put_cred(idmap->cred); + get_user_ns(idmap->user_ns); kfree(idmap); return error; } @@ -503,7 +504,7 @@ nfs_idmap_delete(struct nfs_client *clp) &clp->cl_rpcclient->cl_pipedir_objects, &idmap->idmap_pdo); rpc_destroy_pipe_data(idmap->idmap_pipe); - put_cred(idmap->cred); + put_user_ns(idmap->user_ns); kfree(idmap); } -- 2.25.1