* [PATCH] ramfs: skip mknod if inode already exists.
@ 2021-06-16 2:53 Chen Li
2021-06-16 5:10 ` Christoph Hellwig
2021-06-16 12:16 ` [PATCH] ramfs: skip mknod if inode already exists Al Viro
0 siblings, 2 replies; 5+ messages in thread
From: Chen Li @ 2021-06-16 2:53 UTC (permalink / raw)
To: Alexander Viro, linux-fsdevel, linux-kernel, Christian Brauner,
Andrew Morton, linux-kernel
It's possible we try to mknod a dentry, which have
already bound to an inode, just skip it.
Signed-off-by: Chen Li <chenli@uniontech.com>
---
fs/ramfs/inode.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
index 9ebd17d7befb..6cb1de521142 100644
--- a/fs/ramfs/inode.c
+++ b/fs/ramfs/inode.c
@@ -106,6 +106,8 @@ ramfs_mknod(struct user_namespace *mnt_userns, struct inode *dir,
{
struct inode * inode = ramfs_get_inode(dir->i_sb, dir, mode, dev);
int error = -ENOSPC;
+ if (dentry->d_inode)
+ return -EEXIST;
if (inode) {
d_instantiate(dentry, inode);
--
2.32.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] ramfs: skip mknod if inode already exists.
2021-06-16 2:53 [PATCH] ramfs: skip mknod if inode already exists Chen Li
@ 2021-06-16 5:10 ` Christoph Hellwig
2021-06-16 8:11 ` [PATCH] ramfs: skip mknod if inode already exists.【请注意,邮件由batv+ae8989e1668f84a74d37+6506+infradead.org+hch@casper.srs.infradead.org代发】 Chen Li
2021-06-16 12:16 ` [PATCH] ramfs: skip mknod if inode already exists Al Viro
1 sibling, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2021-06-16 5:10 UTC (permalink / raw)
To: Chen Li
Cc: Alexander Viro, linux-fsdevel, linux-kernel, Christian Brauner,
Andrew Morton
On Wed, Jun 16, 2021 at 10:53:12AM +0800, Chen Li wrote:
>
> It's possible we try to mknod a dentry, which have
> already bound to an inode, just skip it.
How do you think this could happen?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ramfs: skip mknod if inode already exists.【请注意,邮件由batv+ae8989e1668f84a74d37+6506+infradead.org+hch@casper.srs.infradead.org代发】
2021-06-16 5:10 ` Christoph Hellwig
@ 2021-06-16 8:11 ` Chen Li
0 siblings, 0 replies; 5+ messages in thread
From: Chen Li @ 2021-06-16 8:11 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Alexander Viro, linux-fsdevel, linux-kernel, Christian Brauner,
Andrew Morton
On Wed, 16 Jun 2021 13:10:25 +0800,
Christoph Hellwig wrote:
>
> On Wed, Jun 16, 2021 at 10:53:12AM +0800, Chen Li wrote:
> >
> > It's possible we try to mknod a dentry, which have
> > already bound to an inode, just skip it.
>
> How do you think this could happen?
>
>
Sorry, that's my bad. I noticed unionfs used to do this check in 9c5b4452998c6e670cfde0928b277e9c50d9a676, but not sure is it a must.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ramfs: skip mknod if inode already exists.
2021-06-16 2:53 [PATCH] ramfs: skip mknod if inode already exists Chen Li
2021-06-16 5:10 ` Christoph Hellwig
@ 2021-06-16 12:16 ` Al Viro
2021-06-17 1:13 ` [PATCH] ramfs: skip mknod if inode already exists.【请注意,邮件由viro@ftp.linux.org.uk代发】 Chen Li
1 sibling, 1 reply; 5+ messages in thread
From: Al Viro @ 2021-06-16 12:16 UTC (permalink / raw)
To: Chen Li; +Cc: linux-fsdevel, linux-kernel, Christian Brauner, Andrew Morton
On Wed, Jun 16, 2021 at 10:53:12AM +0800, Chen Li wrote:
>
> It's possible we try to mknod a dentry, which have
> already bound to an inode, just skip it.
Caller should have checked may_create(), which includes EEXIST handling.
NAKed-by: Al Viro <viro@zeniv.linux.org.uk>
Incidentally, if it ever had been called that way, your variant would
leak inode. Not the main problem, though...
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ramfs: skip mknod if inode already exists.【请注意,邮件由viro@ftp.linux.org.uk代发】
2021-06-16 12:16 ` [PATCH] ramfs: skip mknod if inode already exists Al Viro
@ 2021-06-17 1:13 ` Chen Li
0 siblings, 0 replies; 5+ messages in thread
From: Chen Li @ 2021-06-17 1:13 UTC (permalink / raw)
To: Al Viro; +Cc: linux-fsdevel, linux-kernel, Christian Brauner, Andrew Morton
On Wed, 16 Jun 2021 20:16:58 +0800,
Al Viro wrote:
>
> On Wed, Jun 16, 2021 at 10:53:12AM +0800, Chen Li wrote:
> >
> > It's possible we try to mknod a dentry, which have
> > already bound to an inode, just skip it.
>
> Caller should have checked may_create(), which includes EEXIST handling.
> NAKed-by: Al Viro <viro@zeniv.linux.org.uk>
Don't know may_create before, thanks!
>
> Incidentally, if it ever had been called that way, your variant would
> leak inode. Not the main problem, though...
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-06-17 1:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-16 2:53 [PATCH] ramfs: skip mknod if inode already exists Chen Li
2021-06-16 5:10 ` Christoph Hellwig
2021-06-16 8:11 ` [PATCH] ramfs: skip mknod if inode already exists.【请注意,邮件由batv+ae8989e1668f84a74d37+6506+infradead.org+hch@casper.srs.infradead.org代发】 Chen Li
2021-06-16 12:16 ` [PATCH] ramfs: skip mknod if inode already exists Al Viro
2021-06-17 1:13 ` [PATCH] ramfs: skip mknod if inode already exists.【请注意,邮件由viro@ftp.linux.org.uk代发】 Chen Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).