From patchwork Wed Dec 18 19:17:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13914066 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A89C9157E88; Wed, 18 Dec 2024 19:17:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734549459; cv=fail; b=uNdMmUCn4QxUrFu0OaYFX1D1YuHZpSq/xaiVDMc/GoA72KOgRXSFmt8Xwab33KHrhqeWZQWC5+TkCz1RIzy97y3IIKsiqcZgSdLJ/m/VEA1LViUvIhkDMHlJCJyQur4T29jZTW4kLiJCgWp1VyLZJozyxsyqZKnStX8Q7VCdFg0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734549459; c=relaxed/simple; bh=HlEcayD1xyf8iW8DFGFSi5Y5yNWDyRiBdxfgp7jJ81g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=KKJclpXrNexAbPYqTpNLeJoSamehgOBZyGlIN4UQ0+MyWR0B7TjG+BUGrsTnZmG5rtV9kll23sBSpqCnS/fQUCNurEbMjop1OF6JE293dP1m7OBddrImo03A/EbtMr7DxBcTy2qgbx9Xdn97pL3WP0KvXGx4dqmkbB3ltJltFIg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=GdmasDBD; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=dVXwzQye; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="GdmasDBD"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="dVXwzQye" Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4BIHQeYN005633; Wed, 18 Dec 2024 19:17:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=ScPg7Mg/0yZeA+OkXXYut4hUI6ZV5gQk944GDbsngNI=; b= GdmasDBDoa+0tnY0qAu1RPHkdRtzKMYvh4ai+OLGiCbO/1HXzKiWf5YzZvFYREKe OCAPwTlBmHmf+PtS2EsF8f4i6v0007Z+osnszGO26gvbkz2hGggyGgIct3oTb8Y+ VgbH46hVAYRG53C5tqM851+zhIuhi/szwaJHrD7Tg+/j0ZBtiampuhOofKXyFIiI WhUo4DrPjDkDxTsW8M8kwjcoG0sCSDkw3vhZmuHb84lBzteHplg9cyUHg71PMCUz LQMffjJLQji6fG/ggf1iwNsxJrSq9SkBn18pvrMmdroMBYCcFzPXu6klALgQdWv5 LYEEjppLK6Sv8X0IrcostQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43h0ec9bu4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Dec 2024 19:17:36 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4BIHTSZ2035463; Wed, 18 Dec 2024 19:17:35 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2174.outbound.protection.outlook.com [104.47.59.174]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 43h0fa8g5r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Dec 2024 19:17:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TPeZQMxvpVld7rDcl9HZUqImkxA2m9vd8bXvXY4eFvl2Gr7Piig2hVS8MEZDpw4Os/K3P3g09c9fMN5WWJhoWz1mS3hQnT//vASnnYGxfGYSs9WP3+t1V7wCpFxuCvAocZladEmrKfVzckPU5bG5mZA7asF96hlfqy0Hm/t50RIy2clzKDT0eok2ZtZsWKCXDKHVjSt0q7ZzEiAapo7+FFTjEb0Z/vwMaOSbJNf6KsIFP0UyzzYde4GIGq7SZEq8PVWJYteZExNvfYYV4TFZ0Qqr47VJJmHuaVfIx+iG95um9ktYsX9AJs5Q+0G4pSsg0ObNQyopQqLYOwOckSEc2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ScPg7Mg/0yZeA+OkXXYut4hUI6ZV5gQk944GDbsngNI=; b=qMQWT3VqSPhcTxMwJ3W2K3AhoaJ8NlrvlANHbtXZyDDlUuOjfBABNvLs/96ElUQt3AWsZ/3ux1ALEuwdwONvh+/kakaOUBlsWwLx9sCZzhZhQCMbhqLkCppt7+lQpZVlWWiVRxMCcmO4UaQ9rnngZ4ZI2Dw7ZuZn9LVAZlsopIqtTLRHemUW6FKGbN/N9t1OfY86eAsl4TnhjXeeF/cVGYv+XAFY4idl2rcGcHcJfKe2vAFQ+tUPr46yZsg16Zlp59HEYJxz67xZUufo/m4kRobZSlN4itfIEt+PjGZtxdv3yvev+8A7Y0EZPDt0W66yy3HPApzPIfMw4Qp3TF88cg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ScPg7Mg/0yZeA+OkXXYut4hUI6ZV5gQk944GDbsngNI=; b=dVXwzQyeAycm8hlp7LGsOW8DUDJKyAF/b7BMtXfzmE6s9gtw+R8zSpqQaX3kLBxFMNgQEWMRkxLyOxs7NlKkJB7dHEvr4T5LQ3snRciPu5wa/7YWs6mgKkhtGJ1scvRJGUBXIpUHYjdXykYTZwCype6am/xGNNFw+Mm4ZgmkbLU= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by CYYPR10MB7673.namprd10.prod.outlook.com (2603:10b6:930:cb::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.12; Wed, 18 Dec 2024 19:17:32 +0000 Received: from BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142]) by BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142%6]) with mapi id 15.20.8272.013; Wed, 18 Dec 2024 19:17:32 +0000 From: Catherine Hoang To: stable@vger.kernel.org Cc: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 03/17] xfs: use consistent uid/gid when grabbing dquots for inodes Date: Wed, 18 Dec 2024 11:17:11 -0800 Message-Id: <20241218191725.63098-4-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241218191725.63098-1-catherine.hoang@oracle.com> References: <20241218191725.63098-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BY1P220CA0021.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:5c3::16) To BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BLAPR10MB5316:EE_|CYYPR10MB7673:EE_ X-MS-Office365-Filtering-Correlation-Id: 57f61b1e-6561-4729-85bf-08dd1f989f5a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016|10070799003; X-Microsoft-Antispam-Message-Info: 4p6K9b5J9VTmozSZ+mFwk7xz+zKj0Q93XNpC9kZcvZ36Ehp3z6YIcy3PuDdW6b6fekjG4X2mTQkGT2WaQXpgRuJ1Kzr+ZbBZ/1GKX6xkXUuLpA6YlnczexfkF4SdRGn2UbSiEWXMGB1aT2YoARqIDT3tPAWF/oCtASrRLXIjzfh+cSjUWvbWZpsXqsnYQYEr+l6hNtDjC76etoRMRIIr1rbXYruas1ALndJQi02oQMhc6cffcl0eAZ1L/4GmXEfLu4kn9lLjTvuVvGakFwL+h2yf2kQkOJMQWAacIcMLS64veynXWTC87/Q88NSbF350sgUP7xoP4kSGbFvUB1DkIiNmq9jaJsckZmkrT+f3DTxkpT0es/lH0Toz+9cD7Pc58wBqfxfgpRLSOVUIcLlWewHEEZqN4R479yZ3V5e/IxCAb3Wee9vy/nosCy7+XZBrcWjMYmoQa9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800799024)(366016)(10070799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BsewNKRvh/5QY3j0UY/1/CP5IXmsxv2kIqNX9uckWBd513jMIzeMBht6/28VMt+nFKmKqbSsErS8tN0NQZ7BRPWM6vCpzpVf+NBVLPJAZrYQ2tv0aSut1qtItoumZqHYDYQF0xO12Vmzgoqh1UNn67kE1xTgVUFuSkqsLf87o+h89JBjhtmK7vInI+Vlgo9qLxfqq7bn64nak2j3mRaiZHYq+CZ3SXtcWHr0ljoWRvgfnSbCyWDnHO14wmYFyNVlA7GPhoA8skFqmj74RhS7WncHUp4mCyCcxDboVtqRatN0+vhf/V+6uidyO+aLlN+0z9U7J5Rzll/Wnai/aHBExMfp8OGJ4ElapDbv9Dl1/lbv2somDJKbfTygdk/1G6Y5tAq714c54i4jJFhZ/3DEIOhyRQJUoyKQuLz329PRCMukOjXv+sFNDsX9E8U/KCfgXlKTROa4N/r00mBR3voTMomPw3+O39SBACqKvOltfZUqlK2FFq8yMZLN2mggP5n88Fonz/95jp8Q51i20D/Ffj09cX43XxrFlfKKPkZjkmBAk1+AFS8Eol4AviF5U9pl9AdjtVUejpXsy7iPriVgRS4OOTTwbCii4yF5yc1JdhtWztEXTXEVn1aqWwb5O5tZZxm5iw3MFQf3ymn2WGL9dMRNPxONnyR0BRhWBP43V0KpmlbHw0pdL2acR7pw/Z3MrNdW6GpfGlh1Y51xX6Wv/qg5EBn4Q0zbWdNN68/vqBCkl0EDZcL/n0sUIwqBSZzVHp9ywhfLx1otg34QKlutRBWh3vU/ZGJH5Xiv0nGYw33k1wnCSox4xo6nGJfejtfQmg3j8Wtk2KCH87MCnOf/K06DKic2F80X8HKIGHuBE1JHqEgT9/WyAkB7gzro6PqxDJGOjYO7gcjv8QFWDTOwvsH83DXcmsA5Fu1Oh/JqCy4EASgVvooywSQM5yuuv8GVIPA1cYV5Q7STInQVr9mgbhhROdNmsqYG7blo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ImdcUKAtYuDeRDPRnP9X0ksPYbS082S0M/FuMuilNexFuRgQDGKIvk03SSa6uM8EfOqHXcImagT+gViqhfUXJP9yK6FBObXIemLOM2KEOVdoaFc4vZ2+1+W3Gl6XdGstZ2AlbH6N33VycbVYLBONt1OWWac7dnfgCNvWGwaV6hJxlPfrXP7CKDHDyllAw/phEpRTaHEYwFzbIgTyYi7630VKEebhhnUg/GHJvTklsplz2q8OH+sITh73zGBwsewAdfd5DIAohpGEdORkZ851zugSjxInxRG2h69nSyMaad+0o= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 57f61b1e-6561-4729-85bf-08dd1f989f5a X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2024 19:17:32.7369 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: p6UBtoOtaNLxsjKL4txmrUs8rO6IEyynyXomDHwJaXaiC6McZ24PyYKU3QV+e8gmuJPxRyhHcjeZ2jlSyTiuhDaaikXHLFWBak1htOfCXOk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR10MB7673 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2024-12-18_06,2024-12-18_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 spamscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2412180149 X-Proofpoint-GUID: Qf4DQxX1nAjxbilEV-c_1eBYHkmD_-V4 X-Proofpoint-ORIG-GUID: Qf4DQxX1nAjxbilEV-c_1eBYHkmD_-V4 From: "Darrick J. Wong" commit 24a4e1cb322e2bf0f3a1afd1978b610a23aa8f36 upstream. I noticed that callers of xfs_qm_vop_dqalloc use the following code to compute the anticipated uid of the new file: mapped_fsuid(idmap, &init_user_ns); whereas the VFS uses a slightly different computation for actually assigning i_uid: mapped_fsuid(idmap, i_user_ns(inode)); Technically, these are not the same things. According to Christian Brauner, the only time that inode->i_sb->s_user_ns != &init_user_ns is when the filesystem was mounted in a new mount namespace by an unpriviledged user. XFS does not allow this, which is why we've never seen bug reports about quotas being incorrect or the uid checks in xfs_qm_vop_create_dqattach tripping debug assertions. However, this /is/ a logic bomb, so let's make the code consistent. Link: https://lore.kernel.org/linux-fsdevel/20240617-weitblick-gefertigt-4a41f37119fa@brauner/ Fixes: c14329d39f2d ("fs: port fs{g,u}id helpers to mnt_idmap") Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Catherine Hoang Acked-by: Darrick J. Wong --- fs/xfs/xfs_inode.c | 16 ++++++++++------ fs/xfs/xfs_symlink.c | 8 +++++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 7aa73855fab6..1e50cc9a29db 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -982,10 +982,12 @@ xfs_create( prid = xfs_get_initial_prid(dp); /* - * Make sure that we have allocated dquot(s) on disk. + * Make sure that we have allocated dquot(s) on disk. The uid/gid + * computation code must match what the VFS uses to assign i_[ug]id. + * INHERIT adjusts the gid computation for setgid/grpid systems. */ - error = xfs_qm_vop_dqalloc(dp, mapped_fsuid(idmap, &init_user_ns), - mapped_fsgid(idmap, &init_user_ns), prid, + error = xfs_qm_vop_dqalloc(dp, mapped_fsuid(idmap, i_user_ns(VFS_I(dp))), + mapped_fsgid(idmap, i_user_ns(VFS_I(dp))), prid, XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp, &pdqp); if (error) @@ -1131,10 +1133,12 @@ xfs_create_tmpfile( prid = xfs_get_initial_prid(dp); /* - * Make sure that we have allocated dquot(s) on disk. + * Make sure that we have allocated dquot(s) on disk. The uid/gid + * computation code must match what the VFS uses to assign i_[ug]id. + * INHERIT adjusts the gid computation for setgid/grpid systems. */ - error = xfs_qm_vop_dqalloc(dp, mapped_fsuid(idmap, &init_user_ns), - mapped_fsgid(idmap, &init_user_ns), prid, + error = xfs_qm_vop_dqalloc(dp, mapped_fsuid(idmap, i_user_ns(VFS_I(dp))), + mapped_fsgid(idmap, i_user_ns(VFS_I(dp))), prid, XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp, &pdqp); if (error) diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c index 85e433df6a3f..b08be64dd10b 100644 --- a/fs/xfs/xfs_symlink.c +++ b/fs/xfs/xfs_symlink.c @@ -191,10 +191,12 @@ xfs_symlink( prid = xfs_get_initial_prid(dp); /* - * Make sure that we have allocated dquot(s) on disk. + * Make sure that we have allocated dquot(s) on disk. The uid/gid + * computation code must match what the VFS uses to assign i_[ug]id. + * INHERIT adjusts the gid computation for setgid/grpid systems. */ - error = xfs_qm_vop_dqalloc(dp, mapped_fsuid(idmap, &init_user_ns), - mapped_fsgid(idmap, &init_user_ns), prid, + error = xfs_qm_vop_dqalloc(dp, mapped_fsuid(idmap, i_user_ns(VFS_I(dp))), + mapped_fsgid(idmap, i_user_ns(VFS_I(dp))), prid, XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp, &pdqp); if (error)