Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1896159ybp; Fri, 11 Oct 2019 23:52:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqz38PGUGEkqK8/QJUJZtczKLcH0k6qvb/KVYV77StRXCY8crdpRc0g9k5yb+3D2/8UN3YD2 X-Received: by 2002:a17:906:6d82:: with SMTP id h2mr17721695ejt.127.1570863178639; Fri, 11 Oct 2019 23:52:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570863178; cv=none; d=google.com; s=arc-20160816; b=QlBM/NfvjbKH8C6We8MFtNZ9LQ4NNMlrcVX+QGz/EBBFH/idzkJz3Z72182V91sLRb Ry1HYYlgTzOJWBx6kmVwL1Oq2VzThUoHl5pE0sErpl6W9xMMcNPNUfal0KP4hxKxmaaC rocTkp7yi9gf8jl5kj+Vtc3zkK/dRHuPHL2VRsop1xdEgKCqwrwL9JO2xUsougiMrNlW reZYS/ULB+tOG7f6AMcpqTa2kSSRh619sAdIhGbsKJ3wg5IRPE0orKljNnNMAlJe9r2r Tq8qPA/5FGrxxmL9kGU3LQmhH1eudIyZNcmjBISgzHfQkwrYQJRxtKwNfmsRaytLRaBc ilgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:subject:message-id:date:from :mime-version:dkim-signature; bh=yX5F7UQ9XF6+RagIHPxa9+er8AVmn045CyrMl3Uj8II=; b=D63JCAE6EFBIFU49jtl5klCyf0we3z2CkFaLAG75UlpKV2o0s6xctMJ5KFz8ZqcICH ypRBYEQcHe00AeKDq1162qxPSTbbh97FDg00oJ1nKqP694w3NRxojz7pDMSPURaOmbE6 +oMyWiWezgSJzk0C8A9Av5XfP5GKvxVD71vbdba1RvbOhTinrQgkMU84NnmECxVz80Iv WFtBwJkYpg8LIpys9BXNRbx70hFbbpcwWNRmyPEaeBMZzl8pH3LuV3IDd4+3oVrAoDlo a7LNIqSFl/oA9DfeQDQ1UhIvJYBP5NqV5x4/YfnYiW0Zukri82rb1oewlLcJXWp007yx Mkgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vZ8xgYMu; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 29si7306872eje.235.2019.10.11.23.52.23; Fri, 11 Oct 2019 23:52:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vZ8xgYMu; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727014AbfJLGeG (ORCPT + 99 others); Sat, 12 Oct 2019 02:34:06 -0400 Received: from mail-wr1-f52.google.com ([209.85.221.52]:35380 "EHLO mail-wr1-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726728AbfJLGeG (ORCPT ); Sat, 12 Oct 2019 02:34:06 -0400 Received: by mail-wr1-f52.google.com with SMTP id v8so14069188wrt.2; Fri, 11 Oct 2019 23:34:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=yX5F7UQ9XF6+RagIHPxa9+er8AVmn045CyrMl3Uj8II=; b=vZ8xgYMuZtf2K6miCpSfiKIWBcIiN4f7xMdAW1E/JFPPSxKimGzy/nt9SZ4EclWSCr SiN7qQp2vPL+aLEYATYMY0pdwhIFnMLdxAzKrJAh9V/Xyx6aoo0B9WtfdS8vOJIZWK2z e8UnoGVRDABmn4L6EWMrzibBdrpT81TWNJNWCx1s0pIwLSQHfpBQA5WZRzYtfduvVJlz guQU4qV7oBxclyYwDyMh/4yO/EXH45+18IHMAOS021i57nr14Um7CUXucOmjIvxPGT5R G1Qkvss+BjCKBorwBFcTIinWuFamTzdlFmBuy6PPAc6Q+qWiBcafrMdFifi6wo6yriU9 0ssg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=yX5F7UQ9XF6+RagIHPxa9+er8AVmn045CyrMl3Uj8II=; b=BeIVaaggx2YCZUHmWlBHTeRbke2hph4aLy92qk3NNYO+09ITp8HGdD+s/ULzXLglch ugQJnPRGLYCt2iPhzgOGn9lTCQ9xM4xKtUoww6HM6EYReoWq5yytVxW6yNKIej42uXkE N16GRzbJFpaff9A8vLIUdQApREngG4wdcDqvJguwAgUvIKG3dRNFrSqQunhvwL4h2sj1 uYp5IClHLD8e2ZjeHrrc2h8dgzQtduna63LQeZ5QLUomqCOxNoZwesKH8N810r7KtNQZ R0EjEqeCTLJoJSZVROs2GC8S+C13Dva94Q1qRPm6dgYqaLJgukGfXQRnZ6VMzqIKrEAA lYgg== X-Gm-Message-State: APjAAAXHsgNrMcWYsL5hLHIwMu5a22We5MGg7iwy8eurvGFlaOWd/YSY 85slG7bQI0WTVEUmg1dveDgcxwqFg8Wrzkcl87bKL6Pkid0= X-Received: by 2002:a5d:638b:: with SMTP id p11mr10510005wru.372.1570862043467; Fri, 11 Oct 2019 23:34:03 -0700 (PDT) MIME-Version: 1.0 From: Wang Shilong Date: Sat, 12 Oct 2019 14:33:36 +0800 Message-ID: Subject: [Project Quota]file owner could change its project ID? To: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, Ext4 Developers List , Andreas Dilger , Li Xi , Wang Shilong Content-Type: text/plain; charset="UTF-8" Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Steps to reproduce: [wangsl@localhost tmp]$ mkdir project [wangsl@localhost tmp]$ lsattr -p project -d 0 ------------------ project [wangsl@localhost tmp]$ chattr -p 1 project [wangsl@localhost tmp]$ lsattr -p -d project 1 ------------------ project [wangsl@localhost tmp]$ chattr -p 2 project [wangsl@localhost tmp]$ lsattr -p -d project 2 ------------------ project [wangsl@localhost tmp]$ df -Th . Filesystem Type Size Used Avail Use% Mounted on /dev/sda3 xfs 36G 4.1G 32G 12% / [wangsl@localhost tmp]$ uname -r 5.4.0-rc2+ As above you could see file owner could change project ID of file its self. As my understanding, we could set project ID and inherit attribute to account Directory usage, and implement a similar 'Directory Quota' based on this. But Directories could easily break this limit by change its file to other project ID. And we used vfs_ioc_fssetxattr_check() to only allow init userspace to change project quota: /* * Project Quota ID state is only allowed to change from within the init * namespace. Enforce that restriction only if we are trying to change * the quota ID state. Everything else is allowed in user namespaces. */ if (current_user_ns() != &init_user_ns) { if (old_fa->fsx_projid != fa->fsx_projid) return -EINVAL; if ((old_fa->fsx_xflags ^ fa->fsx_xflags) & FS_XFLAG_PROJINHERIT) return -EINVAL; } Shall we have something like following to limit admin change for Project state too? diff --git a/fs/inode.c b/fs/inode.c index fef457a42882..3e324931ee84 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -2273,7 +2273,7 @@ int vfs_ioc_fssetxattr_check(struct inode *inode, const struct fsxattr *old_fa, * namespace. Enforce that restriction only if we are trying to change * the quota ID state. Everything else is allowed in user namespaces. */ - if (current_user_ns() != &init_user_ns) { + if (current_user_ns() != &init_user_ns || !capable(CAP_SYS_ADMIN)){ if (old_fa->fsx_projid != fa->fsx_projid) return -EINVAL; if ((old_fa->fsx_xflags ^ fa->fsx_xflags) &