Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp1361626lqs; Sat, 15 Jun 2024 05:53:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV6QrecT9S408VduypBgO4iq1LA0Fx33SPrc8Ye7xdXvck/8QfjQ0KcShUCMcNpq+q2fm0ZYVH6dEJgVgYVQfFNpXStcv8Rj4NT2GPBiw== X-Google-Smtp-Source: AGHT+IHAFa+iBqFOpdLAROb3arCxpHj013sEGNbv1voFlafMF8HjUZkl3NORLK9K+JOBNiUEUrFy X-Received: by 2002:a0c:c48b:0:b0:6b2:b05d:aa78 with SMTP id 6a1803df08f44-6b2b05dacddmr51398896d6.9.1718456017743; Sat, 15 Jun 2024 05:53:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718456017; cv=pass; d=google.com; s=arc-20160816; b=ttF8A3RxUFhBj4za5ctJXW4/ObkB8cJZKuRed2DxHnTAVDEjXNzTkXZuQOUZIEDct5 4kfxFZBr+tjMMZ86rYJDY4JhAZFyEG456uwFbTiW2qH0kE9jDcaE1HRyFY5fH5uofsPW tNwiQFRO9G4HZqPvU7y3BQPpbvw02hlwfPluOakGKEzj8WpNKdA9t3x6mjzZAXNR0NLr UraohJ8euiRsf5tJik2LzXnnXS7hyOA+QiOx4aXtHa2vMiyz2v/z8Emx/7e3ABEAI1Q8 jkonx8HxeGkLqJxM0PckRPALwjn9drVN2Int0ztcmfUIgyIxfH1LlH6SpmEM1tBTb/aj u1uQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=92LCsaXkJeoRVpJsDtxyMK6znw0YY1VAEpYw5A4ddpc=; fh=kFr1Dl15GHZ/xQ20c3UObsNOasu4DCX41emrSb+RVrg=; b=jYkLALtyh5Bwb8E15P/q790f1mfeKcCScNLn/NI+v+JQxu2wCPoPtfciL18n0lItWd uVCTNmNB5IIgrt9rVE6o44EYZxNcgXdBq1AjadQrcBvr41l6LLbeR4yGDv2iEA43Xytw 303yNDK1JzWpy977Q5bGtk6J1z9To8iP+txhs45I071L7XZtDZBbdHSh3AdrHkSOy3Vl +Knss4INg86MPvZbdSDPk3AALNf/ol1hUebEawZdFQ5b8Yax2pO2xsALM6fEpo3OXW5n HOw0OCGxRyq4s5MUqmbCOlgshHov+b0ouiFw6ibYnq+AIBFzfsIXqB18LFckgOr7gmkN GzEQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=rDSyu5OC; arc=pass (i=1 dkim=pass dkdomain=linux.org.uk dmarc=pass fromdomain=zeniv.linux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-215734-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215734-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 6a1803df08f44-6b2a5a17133si58402756d6.51.2024.06.15.05.53.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Jun 2024 05:53:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-215734-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=rDSyu5OC; arc=pass (i=1 dkim=pass dkdomain=linux.org.uk dmarc=pass fromdomain=zeniv.linux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-215734-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215734-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id B46171C21616 for ; Sat, 15 Jun 2024 06:55:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DC43B17580; Sat, 15 Jun 2024 06:55:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="rDSyu5OC" Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (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 299ED79F5; Sat, 15 Jun 2024 06:55:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718434545; cv=none; b=i1n+0g3rlfUIBOOD0QiSL1R32ZyhdZ0kslkWW5m4E5a22A/Xu30SbXHmAVnJgrtecQ70T/Z22v6hDKnmVK0NmbPUuOwczH9GZcwDMs8dTGplANPwu0Tkie6+G5c3mZakEUnR74qB5vytO3pkjOSlryircPQ6vN6fHHbaFwh6fMY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718434545; c=relaxed/simple; bh=v0MCPzGmDHWaCmXNTaeRXiP4uAHdb48+oNgoKNrIOUk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=euGq6GfpOgU5SwFx2KNd0qx7nGu0HybiXPMKhomezAJz6+uQyaP443GhvRKCYtKhn/T1jTGnQTSA870nm3QOo3jyPQe+mebrvz+Q4NNxaRLLL7/sAmpZUGMJN09WIO1qmzcdgqgnVSUowgExYQ0+mENZrVUuQd8C+ELq5+LU1b8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=rDSyu5OC; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=92LCsaXkJeoRVpJsDtxyMK6znw0YY1VAEpYw5A4ddpc=; b=rDSyu5OCFt2rJ1qjMvxp0ICybI 0pTc7tvz9ZDGbi8VtwA3pG1ZrjPUtwN30w2vc0oDyAZjRLi49wyONs4KPqVtJfp1EKHfRdKfMRL8p SertZn86m2xBe2vVqWGZQCy/hfEJKHymekRsQlrrvhUm/bubHlm9IOAg7OT7CSeCl8LWpSEsEEmM+ 2YH7cErZdtF1pGJNdIewTFetlcweD5A3qp0vHlVJh8rB85vEXPfU46zZbDv25Q6ebnPtGZkYAw5un 8K63EQPNyJD8vK5jSAeHMBSSYtvSIU/RTFZKHwbTqYHpVFhVZG/Kw2tAPzN9+1tOxvZF6fB0N/cXM xLnTX97g==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1sINJw-009tiR-1d; Sat, 15 Jun 2024 06:55:28 +0000 Date: Sat, 15 Jun 2024 07:55:28 +0100 From: Al Viro To: Christoph Hellwig Cc: Congjie Zhou , brauner@kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] fs: modify the annotation of vfs_mkdir() in fs/namei.c Message-ID: <20240615065528.GP1629371@ZenIV> References: <20240615030056.GO1629371@ZenIV> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Al Viro On Fri, Jun 14, 2024 at 11:29:38PM -0700, Christoph Hellwig wrote: > On Sat, Jun 15, 2024 at 12:38:32PM +0800, Congjie Zhou wrote: > > modify the annotation of @dir and @dentry > > Well, it is clearly obvious that you modify them from the patch. But > why? Look at the current comment: * @dir: inode of @dentry It is an inode of _some_ dentry; it's most definitely not that of the argument named 'dentry'. * @dentry: pointer to dentry of the base directory No. The first thing vfs_mkdir() does is int error = may_create(idmap, dir, dentry); if (error) return error; Look at may_create(). Starts with static inline int may_create(struct mnt_idmap *idmap, struct inode *dir, struct dentry *child) { audit_inode_child(dir, child, AUDIT_TYPE_CHILD_CREATE); if (child->d_inode) return -EEXIST; If the last argument (aka. 'dentry' argument of vfs_mkdir()) is currently referring to *ANY* directory, you get -EEXIST. For a good and simple reason: it is the dentry of subdirectory to be created. Now, the second argument of vfs_mkdir() ('dir') is the inode of the parent to be (or base directory, if you will). While we are at it, the rest of comments coming from the same commit suffer similar problems. vfs_create(), vfs_symlink(), et.al. vfs_unlink() is fine, vfs_rmdir() should match vfs_unlink() (inode of parent + dentry of victim).