Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp452974pxb; Thu, 21 Jan 2021 10:59:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJx4U9KmSnD0OrK5Q9Qd3JbYJ/9B+3VNIpxoG4HD//4tD785CYGTehSMqE92VekPOhzrhcAN X-Received: by 2002:a17:906:2743:: with SMTP id a3mr624949ejd.378.1611255558065; Thu, 21 Jan 2021 10:59:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611255558; cv=none; d=google.com; s=arc-20160816; b=edIqDX4xKFnQW1gOrtriLvqvpDX0uy+08wcOg+WGHFJ2xOuxs3CYyYCyJZR8mkgzhe /ON8/Eu4HROTQJjMWObQ4RnP+TiTQu5BH7OZdeYZS6/7CzEwpe/U785Um69v14xCaki3 0RKbmYbAscuH6xTqeAT9WwAnRnLjB883Cc8wEebrKe2nLtCM8i2O57q8JkhHt6VhgCbi 3lb227R0lL4DjXvODOJyMrAhgczYZzFyPQjfkm1zDbBZkPlbblZtwuO6crMUXVIX5mIe F7ptfH+9vJEUCWJ3Y4ln2C4CB1hTxSH75kV9y01KiPS2r+RfA09BEI6kntFa+oMX4pEQ S9Kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=kh5H4UFhDxCiOGRdI09Atf4Ml4LlpZUwwfn84ZLlMQM=; b=ajEnMoIMbi0mUFoNA2JcQXVC4rO8blI0fyShFmv+280rTRgrtYKP29j+ydF0CBiIum CB5MlNmvZk3kS8gpJlmKLfCdpmh00ohSqE5Oz+s77cUjlK9Rn00EqdGaNarq3UWGFllb RKXnbPPlS1iyBX2vVor2xKb8Z7hoy9kGG65w2RKxZxB/MIvp4B0TDx26WTkoJn6ekjYh AUto35b70t0WsN9/Y13GNPFPwUyfBtz8BL0HJFrUpQyfLmcMVOos79xVL+xykGUzWinx sONCH6IzOjAvGMWSV6SkV4L2Nq0d46ndIurdyI19F6iTBMrcckzwhDe9k0SZJqypwDKv 3iww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VgUUy1wm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v24si2820396eda.271.2021.01.21.10.58.53; Thu, 21 Jan 2021 10:59:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=@kernel.org header.s=k20201202 header.b=VgUUy1wm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727177AbhAUS4h (ORCPT + 99 others); Thu, 21 Jan 2021 13:56:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:34470 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727525AbhAUSmY (ORCPT ); Thu, 21 Jan 2021 13:42:24 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2835820663; Thu, 21 Jan 2021 18:41:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611254498; bh=zUyVSomcOLJhZqUOWCun3ToANA99xAvMOlulwnj2ps8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=VgUUy1wmJh3wnXnN8uP6I0WZG851YhCN2YKVHZYYztg/fUeyZBBI4DJzF6tlLoHc4 EaoOfF1WXY8tRLMwp/kP/1j8csWEOUHds4ZtanprT30tj1dmTZEfFZoeQFuuK5tSsB zhV6O8Fl55tedNR36ZnMdGf9Y8ORFqw31XauriEhKInw+gZjv3n8Ju7lUnmARGnMYL Ghd9ZSRAFng90siSedQNlJl4x3Pki9PT2egyM9mneV5ZGXlkfXfhO6Y+nOHqbFsYOx uJ7Vn/12AVlNfhoH/2ngUADIireGx8vagPz94W6NtBFnwXqvho5tHIrIC6V4Xm1Gm9 0S1D5J89ZEogw== Date: Thu, 21 Jan 2021 10:41:37 -0800 From: "Darrick J. Wong" To: Jeffrey Mitchell Cc: linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] xfs: set inode size after creating symlink Message-ID: <20210121184137.GB1282159@magnolia> References: <20210121151912.4429-1-jeffrey.mitchell@starlab.io> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210121151912.4429-1-jeffrey.mitchell@starlab.io> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 21, 2021 at 09:19:12AM -0600, Jeffrey Mitchell wrote: > When XFS creates a new symlink, it writes its size to disk but not to the > VFS inode. This causes i_size_read() to return 0 for that symlink until > it is re-read from disk, for example when the system is rebooted. > > I found this inconsistency while protecting directories with eCryptFS. Heh. No doubt caused by the fact that we only call i_size_write for regular files, ecryptfs copies i_size_read() of the lower dentry into the ecryptfs inode, and ecryptfs_getattr_link and doesn't call ->getattr on the lower inode. Do directories have the same problem? I'm guessing no because every other file type calls vfs_getattr on the lower dentry, which should link us to xfs_vn_getattr. Reviewed-by: Darrick J. Wong --D > The command "stat path/to/symlink/in/ecryptfs" will report "Size: 0" if > the symlink was created after the last reboot on an XFS root. > > Call i_size_write() in xfs_symlink() > > Signed-off-by: Jeffrey Mitchell > --- > fs/xfs/xfs_symlink.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c > index 1f43fd7f3209..c835827ae389 100644 > --- a/fs/xfs/xfs_symlink.c > +++ b/fs/xfs/xfs_symlink.c > @@ -300,6 +300,7 @@ xfs_symlink( > } > ASSERT(pathlen == 0); > } > + i_size_write(VFS_I(ip), ip->i_d.di_size); > > /* > * Create the directory entry for the symlink. > -- > 2.25.1 >