Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp1380724imd; Thu, 1 Nov 2018 14:50:17 -0700 (PDT) X-Google-Smtp-Source: AJdET5dfU0M5bHpACYoB6KX4xS/6OzF1wiw6ax6lMF6DlbR9mXPCGPiUw3ROBzFYBd2vc/d++bOE X-Received: by 2002:a62:2bd4:: with SMTP id r203-v6mr7695323pfr.105.1541109017919; Thu, 01 Nov 2018 14:50:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541109017; cv=none; d=google.com; s=arc-20160816; b=t8b0UEJMZ3CGpSwDOS6FDxzMBRhyiqdhxU368BJmccem0pww0ZxAwRC8Kf5SFY/gjb QVaqCMMuBkKPO4gzqCHpqNYzKvOeYnUzW2NUqP8tuOrQaVNO3Xb4SrZdJfki9t4jfBsR Cogpk1J6OQS7dDIdXo7vK2idcLfEN8vpmPpCmm/fXnMt8TzNw/2Ms992qErtK6/qOA25 d+7nQbqXAPhXpBaJocrpnSFV0UPAb9iIQNQmSPT1utHvmUTY436LOvFdiH6l2d5q3YTy jvMCce80zrqOaj/7oFe7n9LmG+oHYDeJIP0kcjCGJ1lvOvA7QiWPnBY2i3MkixET4mez jT6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from; bh=tfcS/D8E2NVDSMMG2zN/Checw4lvvL0gTuc15nYTfSo=; b=Yg4YtRrzeRY9mM7/JOo0rWCk83ARmUf376Pb+rSd2FUPM6JENDTsI1pgAjgjlj0urq +K5pBlF+JtzgCuLyO2a95nLAUSUKFUgwcn4MFT4J5FM5jBDaiDL9wZCetEZECXUjJkK4 7S9PN256+wHFvgyvBtuLcr+jbH/nFokYcLWg1cCil3IG8mRxRm9QakfCIKndNDVcdESF uyG4Pb2eflyBiRtZodOQ68yRIw9v8NAcxo3oXxSgLw/DIUz56FUuDGXyEs0WodkAlkPX BVdv9W4m7zId5IuvXnkSn+B3V7hScs1VryAPLRaDh40b3fDOQuhpAURMRQnLEicFgK90 EePA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s17-v6si30930698pge.209.2018.11.01.14.50.03; Thu, 01 Nov 2018 14:50:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727854AbeKBGx6 (ORCPT + 99 others); Fri, 2 Nov 2018 02:53:58 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:58266 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727828AbeKBGx6 (ORCPT ); Fri, 2 Nov 2018 02:53:58 -0400 Received: from mail-io1-f72.google.com ([209.85.166.72]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1gIKpy-0008K0-DB for linux-kernel@vger.kernel.org; Thu, 01 Nov 2018 21:49:10 +0000 Received: by mail-io1-f72.google.com with SMTP id k9-v6so18707186ioj.18 for ; Thu, 01 Nov 2018 14:49:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tfcS/D8E2NVDSMMG2zN/Checw4lvvL0gTuc15nYTfSo=; b=sN+RZibsbwq4CfrZ0zqgInfKhRrvj/ivVX8DrqHEVBmFFigDBAgGXNFgEz5ygd7EKu R8XW7a53AlyXX98haY57kUHdF7vV2ZWsU6Wvq94g7CWggJIm5z8WEcnGfDYNK5LrTi9r ycNgNVtSd6RHEChEy2MVr43mrAWW4cG2ijI6wDrA1Y8C04ScW2ZeaEa5hxH7/KdbXBBe ULNsz3hl3LpcpSgly0A6KRFbSWdpOmBkf8skQ7Q4EcpmTzK4t3K/w3kBtIBvZBExcIRB Vt8IL2U8iEBg8iPSmHXHLJtDQRwKT1TuHvT4AqCxDezEq7Nrs+DMJ364Cqt4q+pyRHHi VF8A== X-Gm-Message-State: AGRZ1gJfWKVhn0CU+22Had5ujLYNfOjjS7x5+Kx0LPEN6XlAPjBLENQ5 Te7MmCLtBUjGWvC8JtYZ4wRsS3zIKISI57Sy9EagDVl5XZjBxt4mOUTKiC4MwiIuyfQE9uaZ7/A k7RaJuM07TcGCzETPpN8F9rUsy2QqClLPrJ4Reog77Q== X-Received: by 2002:a02:a1cb:: with SMTP id o11-v6mr5094053jah.82.1541108948879; Thu, 01 Nov 2018 14:49:08 -0700 (PDT) X-Received: by 2002:a02:a1cb:: with SMTP id o11-v6mr5094031jah.82.1541108948452; Thu, 01 Nov 2018 14:49:08 -0700 (PDT) Received: from localhost ([2605:a601:ac7:2a20:7c8b:4047:a2ef:69cd]) by smtp.gmail.com with ESMTPSA id k21-v6sm5266844iom.50.2018.11.01.14.49.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 01 Nov 2018 14:49:07 -0700 (PDT) From: Seth Forshee To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, containers@lists.linux-foundation.org, James Bottomley Subject: [RFC PATCH 4/6] shiftfs: translate uids using s_user_ns from lower fs Date: Thu, 1 Nov 2018 16:48:54 -0500 Message-Id: <20181101214856.4563-5-seth.forshee@canonical.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181101214856.4563-1-seth.forshee@canonical.com> References: <20181101214856.4563-1-seth.forshee@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Do not assume that ids from the lower filesystem are from init_user_ns. Instead, translate them from that filesystem's s_user_ns and then to the shiftfs user ns. Signed-off-by: Seth Forshee --- fs/shiftfs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/shiftfs.c b/fs/shiftfs.c index 556594988dd2..226c03d8588b 100644 --- a/fs/shiftfs.c +++ b/fs/shiftfs.c @@ -613,6 +613,8 @@ static int shiftfs_getattr(const struct path *path, struct kstat *stat, struct inode *reali = real->d_inode; const struct inode_operations *iop = reali->i_op; struct path newpath = { .mnt = path->dentry->d_sb->s_fs_info, .dentry = real }; + struct user_namespace *from_ns = reali->i_sb->s_user_ns; + struct user_namespace *to_ns = inode->i_sb->s_user_ns; int err = 0; if (iop->getattr) @@ -624,8 +626,8 @@ static int shiftfs_getattr(const struct path *path, struct kstat *stat, return err; /* transform the underlying id */ - stat->uid = make_kuid(inode->i_sb->s_user_ns, __kuid_val(stat->uid)); - stat->gid = make_kgid(inode->i_sb->s_user_ns, __kgid_val(stat->gid)); + stat->uid = shift_kuid(from_ns, to_ns, stat->uid); + stat->gid = shift_kgid(from_ns, to_ns, stat->gid); return 0; } -- 2.19.1