* [PATCH] fix error: a bin file can truncate itself while running at overlayfs.
@ 2016-06-20 2:51 zhangaihua1
2016-06-20 7:05 ` Miklos Szeredi
0 siblings, 1 reply; 2+ messages in thread
From: zhangaihua1 @ 2016-06-20 2:51 UTC (permalink / raw)
To: linux-fsdevel, linux-kernel, linux-unionfs; +Cc: Aihua Zhang
From: Aihua Zhang <zhangaihua1@huawei.com>
I wrote a testcase to truncate a bin file while it is running at overlayfs.
the result as below:
Bus error (core dumped)
I think it's not appropriate for filesystem, and fixed it by this patch.
after the patch, result as below:
status:-1
errno:26
ETXTBSY:26
PASS
This is because the inode is not correct ,it should point to overlayfs rather
than the upper filesystem.
Signed-off-by: Aihua Zhang <zhangaihua1@huawei.com>
---
include/linux/fs.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index dd28814..54fdbf9 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2589,7 +2589,7 @@ static inline int get_write_access(struct inode *inode)
}
static inline int deny_write_access(struct file *file)
{
- struct inode *inode = file_inode(file);
+ struct inode *inode = d_inode(file->f_path.dentry);
return atomic_dec_unless_positive(&inode->i_writecount) ? 0 : -ETXTBSY;
}
static inline void put_write_access(struct inode * inode)
--
1.7.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] fix error: a bin file can truncate itself while running at overlayfs.
2016-06-20 2:51 [PATCH] fix error: a bin file can truncate itself while running at overlayfs zhangaihua1
@ 2016-06-20 7:05 ` Miklos Szeredi
0 siblings, 0 replies; 2+ messages in thread
From: Miklos Szeredi @ 2016-06-20 7:05 UTC (permalink / raw)
To: zhangaihua1; +Cc: linux-fsdevel, linux-kernel, linux-unionfs@vger.kernel.org
On Mon, Jun 20, 2016 at 4:51 AM, <zhangaihua1@huawei.com> wrote:
> From: Aihua Zhang <zhangaihua1@huawei.com>
>
> I wrote a testcase to truncate a bin file while it is running at overlayfs.
> the result as below:
>
> Bus error (core dumped)
Thanks for the report.
Please tell us more information about how to trigger the bug:
- how did you set up the overlay filesystem?
- which test case from which test suite was this?
> I think it's not appropriate for filesystem, and fixed it by this patch.
> after the patch, result as below:
>
> status:-1
> errno:26
> ETXTBSY:26
> PASS
>
> This is because the inode is not correct ,it should point to overlayfs rather
> than the upper filesystem.
Changeing denty_write_access() without a similar change in
allow_write_access() is sure to buggy.
But even with that fixed, it's not clear to me why exactly this change
is needed. More thought needs to be going into this.
Thanks,
Miklos
>
> Signed-off-by: Aihua Zhang <zhangaihua1@huawei.com>
> ---
> include/linux/fs.h | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index dd28814..54fdbf9 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -2589,7 +2589,7 @@ static inline int get_write_access(struct inode *inode)
> }
> static inline int deny_write_access(struct file *file)
> {
> - struct inode *inode = file_inode(file);
> + struct inode *inode = d_inode(file->f_path.dentry);
> return atomic_dec_unless_positive(&inode->i_writecount) ? 0 : -ETXTBSY;
> }
> static inline void put_write_access(struct inode * inode)
> --
> 1.7.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-unionfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-06-20 7:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-20 2:51 [PATCH] fix error: a bin file can truncate itself while running at overlayfs zhangaihua1
2016-06-20 7:05 ` Miklos Szeredi
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).