All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] minix: fix bug when opening a file with O_DIRECT will
@ 2022-01-06  3:30 Qinghua Jin
  2022-01-06 11:00 ` Jan Kara
  0 siblings, 1 reply; 4+ messages in thread
From: Qinghua Jin @ 2022-01-06  3:30 UTC (permalink / raw)
  To: christian.brauner
  Cc: qhjin_dev, Qinghua Jin, Greg Kroah-Hartman, Jan Kara,
	Andrew Morton, linux-kernel

Testcase:
1. create a minix file system and mount it
2. open a file on the file system with O_RDWR|O_CREAT|O_TRUNC|O_DIRECT
3. open fails with -EINVAL but leaves an empty file behind. All other
open() failures don't leave the failed open files behind.

It is hard to check the direct_IO op before creating the inode. Just as
ext4 and btrfs do, this patch will resolve the issue by allowing to 
create the file with O_DIRECT but returning error when writing the file.

Signed-off-by: Qinghua Jin <qhjin.dev@gmail.com>
---
 fs/minix/inode.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/minix/inode.c b/fs/minix/inode.c
index a71f1cf894b9..d4bd94234ef7 100644
--- a/fs/minix/inode.c
+++ b/fs/minix/inode.c
@@ -447,7 +447,8 @@ static const struct address_space_operations minix_aops = {
 	.writepage = minix_writepage,
 	.write_begin = minix_write_begin,
 	.write_end = generic_write_end,
-	.bmap = minix_bmap
+	.bmap = minix_bmap,
+	.direct_IO = noop_direct_IO
 };
 
 static const struct inode_operations minix_symlink_inode_operations = {
-- 
2.30.2


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

* Re: [PATCH] minix: fix bug when opening a file with O_DIRECT will
  2022-01-06  3:30 [PATCH] minix: fix bug when opening a file with O_DIRECT will Qinghua Jin
@ 2022-01-06 11:00 ` Jan Kara
       [not found]   ` <CACL7WEN+eBW2MFGCti-NAzxAZAKXkjJ2F+6=eGqX0UdcAzw8Eg@mail.gmail.com>
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Kara @ 2022-01-06 11:00 UTC (permalink / raw)
  To: Qinghua Jin
  Cc: christian.brauner, qhjin_dev, Greg Kroah-Hartman, Jan Kara,
	Andrew Morton, linux-kernel

On Thu 06-01-22 11:30:41, Qinghua Jin wrote:
> Testcase:
> 1. create a minix file system and mount it
> 2. open a file on the file system with O_RDWR|O_CREAT|O_TRUNC|O_DIRECT
> 3. open fails with -EINVAL but leaves an empty file behind. All other
> open() failures don't leave the failed open files behind.
> 
> It is hard to check the direct_IO op before creating the inode. Just as
> ext4 and btrfs do, this patch will resolve the issue by allowing to 
> create the file with O_DIRECT but returning error when writing the file.
> 
> Signed-off-by: Qinghua Jin <qhjin.dev@gmail.com>

The patch looks good. Thanks. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

Just out of curiosity: Do you happen to really use minix filesystem or was
this just a fallout from some fuzz testing or something like that?

								Honza
> ---
>  fs/minix/inode.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/minix/inode.c b/fs/minix/inode.c
> index a71f1cf894b9..d4bd94234ef7 100644
> --- a/fs/minix/inode.c
> +++ b/fs/minix/inode.c
> @@ -447,7 +447,8 @@ static const struct address_space_operations minix_aops = {
>  	.writepage = minix_writepage,
>  	.write_begin = minix_write_begin,
>  	.write_end = generic_write_end,
> -	.bmap = minix_bmap
> +	.bmap = minix_bmap,
> +	.direct_IO = noop_direct_IO
>  };
>  
>  static const struct inode_operations minix_symlink_inode_operations = {
> -- 
> 2.30.2
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH] minix: fix bug when opening a file with O_DIRECT will
       [not found]   ` <CACL7WEN+eBW2MFGCti-NAzxAZAKXkjJ2F+6=eGqX0UdcAzw8Eg@mail.gmail.com>
@ 2022-01-07 11:32     ` Christian Brauner
  2022-01-07 13:36       ` [PATCH v2] minix: fix bug when opening a file with O_DIRECT Qinghua Jin
  0 siblings, 1 reply; 4+ messages in thread
From: Christian Brauner @ 2022-01-07 11:32 UTC (permalink / raw)
  To: Qinghua Jin
  Cc: Jan Kara, qhjin_dev, Greg Kroah-Hartman, Andrew Morton,
	linux-kernel, Colin Ian King

On Fri, Jan 07, 2022 at 07:12:39AM +0800, Qinghua Jin wrote:
> On Thu, Jan 6, 2022 at 11:43 PM Jan Kara <jack@suse.cz> wrote:
> 
> > On Thu 06-01-22 11:30:41, Qinghua Jin wrote:
> > > Testcase:
> > > 1. create a minix file system and mount it
> > > 2. open a file on the file system with O_RDWR|O_CREAT|O_TRUNC|O_DIRECT
> > > 3. open fails with -EINVAL but leaves an empty file behind. All other
> > > open() failures don't leave the failed open files behind.
> > >
> > > It is hard to check the direct_IO op before creating the inode. Just as
> > > ext4 and btrfs do, this patch will resolve the issue by allowing to
> > > create the file with O_DIRECT but returning error when writing the file.
> > >
> > > Signed-off-by: Qinghua Jin <qhjin.dev@gmail.com>
> >
> > The patch looks good. Thanks. Feel free to add:
> >
> > Reviewed-by: Jan Kara <jack@suse.cz>
> >
> > Just out of curiosity: Do you happen to really use minix filesystem or was
> > this just a fallout from some fuzz testing or something like that?
> >
> > Thanks, It's a bug reported by colin.king@canonical.com
> https://bugzilla.kernel.org/show_bug.cgi?id=213041
> I don't include the email because it's not reachable.

Fwiw, Colin's now at Intel:
Colin Ian King <colin.king@intel.com>

(While I'm here:
 Acked-by: Christian Brauner <christian.brauner@ubuntu.com>)

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

* [PATCH v2] minix: fix bug when opening a file with O_DIRECT
  2022-01-07 11:32     ` Christian Brauner
@ 2022-01-07 13:36       ` Qinghua Jin
  0 siblings, 0 replies; 4+ messages in thread
From: Qinghua Jin @ 2022-01-07 13:36 UTC (permalink / raw)
  Cc: Qinghua Jin, Colin Ian King, Jan Kara, Christian Brauner,
	Andrew Morton, Greg Kroah-Hartman, James Morris, linux-kernel

Testcase:
1. create a minix file system and mount it
2. open a file on the file system with O_RDWR|O_CREAT|O_TRUNC|O_DIRECT
3. open fails with -EINVAL but leaves an empty file behind. All other
open() failures don't leave the failed open files behind.

It is hard to check the direct_IO op before creating the inode. Just as
ext4 and btrfs do, this patch will resolve the issue by allowing to
create the file with O_DIRECT but returning error when writing the file.

Reported-by: Colin Ian King <colin.king@intel.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Qinghua Jin <qhjin.dev@gmail.com>
---
 fs/minix/inode.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/minix/inode.c b/fs/minix/inode.c
index a71f1cf894b9..d4bd94234ef7 100644
--- a/fs/minix/inode.c
+++ b/fs/minix/inode.c
@@ -447,7 +447,8 @@ static const struct address_space_operations minix_aops = {
 	.writepage = minix_writepage,
 	.write_begin = minix_write_begin,
 	.write_end = generic_write_end,
-	.bmap = minix_bmap
+	.bmap = minix_bmap,
+	.direct_IO = noop_direct_IO
 };
 
 static const struct inode_operations minix_symlink_inode_operations = {
-- 
2.30.2


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

end of thread, other threads:[~2022-01-07 13:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-06  3:30 [PATCH] minix: fix bug when opening a file with O_DIRECT will Qinghua Jin
2022-01-06 11:00 ` Jan Kara
     [not found]   ` <CACL7WEN+eBW2MFGCti-NAzxAZAKXkjJ2F+6=eGqX0UdcAzw8Eg@mail.gmail.com>
2022-01-07 11:32     ` Christian Brauner
2022-01-07 13:36       ` [PATCH v2] minix: fix bug when opening a file with O_DIRECT Qinghua Jin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.