The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] fs/namei: Don't update atime when some errors occur in get_link
@ 2023-12-05  7:17 Hao Ge
  2023-12-05 11:06 ` Christian Brauner
  0 siblings, 1 reply; 3+ messages in thread
From: Hao Ge @ 2023-12-05  7:17 UTC (permalink / raw)
  To: viro, brauner; +Cc: linux-fsdevel, linux-kernel, gehao618, Hao Ge

Perhaps we have some errors occur(like security),then we don't update
atime,because we didn't actually access it

Signed-off-by: Hao Ge <gehao@kylinos.cn>
---
 fs/namei.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 71c13b2990b4..033d36d5c1c5 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1779,15 +1779,6 @@ static const char *pick_link(struct nameidata *nd, struct path *link,
 			unlikely(link->mnt->mnt_flags & MNT_NOSYMFOLLOW))
 		return ERR_PTR(-ELOOP);
 
-	if (!(nd->flags & LOOKUP_RCU)) {
-		touch_atime(&last->link);
-		cond_resched();
-	} else if (atime_needs_update(&last->link, inode)) {
-		if (!try_to_unlazy(nd))
-			return ERR_PTR(-ECHILD);
-		touch_atime(&last->link);
-	}
-
 	error = security_inode_follow_link(link->dentry, inode,
 					   nd->flags & LOOKUP_RCU);
 	if (unlikely(error))
@@ -1810,6 +1801,16 @@ static const char *pick_link(struct nameidata *nd, struct path *link,
 		if (IS_ERR(res))
 			return res;
 	}
+
+	if (!(nd->flags & LOOKUP_RCU)) {
+		touch_atime(&last->link);
+		cond_resched();
+	} else if (atime_needs_update(&last->link, inode)) {
+		if (!try_to_unlazy(nd))
+			return ERR_PTR(-ECHILD);
+		touch_atime(&last->link);
+	}
+
 	if (*res == '/') {
 		error = nd_jump_root(nd);
 		if (unlikely(error))
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] fs/namei: Don't update atime when some errors occur in get_link
  2023-12-05  7:17 [PATCH] fs/namei: Don't update atime when some errors occur in get_link Hao Ge
@ 2023-12-05 11:06 ` Christian Brauner
  2023-12-06  9:02   ` Hao Ge
  0 siblings, 1 reply; 3+ messages in thread
From: Christian Brauner @ 2023-12-05 11:06 UTC (permalink / raw)
  To: Hao Ge; +Cc: viro, linux-fsdevel, linux-kernel, gehao618

On Tue, Dec 05, 2023 at 03:17:33PM +0800, Hao Ge wrote:
> Perhaps we have some errors occur(like security),then we don't update
> atime,because we didn't actually access it
> 
> Signed-off-by: Hao Ge <gehao@kylinos.cn>
> ---

We didn't follow the link but we accessed it. I guess it's not completey
clear what's correct here so I'd just leave it as is.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] fs/namei: Don't update atime when some errors occur in get_link
  2023-12-05 11:06 ` Christian Brauner
@ 2023-12-06  9:02   ` Hao Ge
  0 siblings, 0 replies; 3+ messages in thread
From: Hao Ge @ 2023-12-06  9:02 UTC (permalink / raw)
  To: Christian Brauner; +Cc: Hao Ge, viro, linux-fsdevel, linux-kernel



> On Dec 5, 2023, at 19:07, Christian Brauner <brauner@kernel.org> wrote:
> 
> On Tue, Dec 05, 2023 at 03:17:33PM +0800, Hao Ge wrote:
>> Perhaps we have some errors occur(like security),then we don't update
>> atime,because we didn't actually access it
>> 
>> Signed-off-by: Hao Ge <gehao@kylinos.cn>
>> ---
> 
> We didn't follow the link but we accessed it. I guess it's not completey
> clear what's correct here so I'd just leave it as is.
Hi brauner
Thank your for your reply.
I just thought of a situation that user access a link failed due to some error(like permission issue),maybe report some error to user, actually user don’t get anything,but atime still update.
Maybe your are right,after all,we still tried to visit.
Thanks
Best Regards 
Hao

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-12-06  9:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-05  7:17 [PATCH] fs/namei: Don't update atime when some errors occur in get_link Hao Ge
2023-12-05 11:06 ` Christian Brauner
2023-12-06  9:02   ` Hao Ge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox