Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux ZFS port doesn't respect RLIMIT_FSIZE #5587

Closed
ColinIanKing opened this issue Jan 13, 2017 · 3 comments
Closed

Linux ZFS port doesn't respect RLIMIT_FSIZE #5587

ColinIanKing opened this issue Jan 13, 2017 · 3 comments

Comments

@ColinIanKing
Copy link
Contributor

ColinIanKing commented Jan 13, 2017

BugLink: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1656259

System information

Type Version/Name
Distribution Name Ubuntu
Distribution Version 16.10, 17.04
Linux Kernel 4.8.0-22-generic
Architecture x86_64
ZFS Version 0.6.5.8-0ubuntu1
SPL Version 0.6.5.8-0ubuntu1

Describe the problem you're observing

bash -c 'ulimit -f 1024; yes | head -n2097152' > /path/on/filesystem/under/test

On ext4, this test case prints something along the lines of:

bash: line 1: 11274 Broken pipe yes
11275 File size limit exceeded(core dumped) | head -n2097152

On ZFS, this test case incorrectly exits zero with no output, demonstrating that ZFS does not respect RLIMIT_FSIZE.

I asked a friend to run this on Solaris 5.10 and FreeBSD 10.0-CURRENT, and on those systems this test case correctly generates SIGXFSZ; so it seems that this is a bug in the Linux port of ZFS.

(This was discovered while tracking down Launchpad test suite failures under LXD on ZFS. Launchpad uses RLIMIT_FSIZE in one place to guard against bugs that cause debdiff to generate arbitrarily large amounts of output and fill the disk.)

Describe how to reproduce the problem

bash -c 'ulimit -f 1024; yes | head -n2097152' > /path/on/filesystem/under/test

Include any warning/errors/backtraces from the system logs

None.

@DeHackEd
Copy link
Contributor

Looks like we need to call inode_newsize_ok(const struct inode *inode, loff_t offset) to determine if we have hit the limit. Function was added in 2.6.32 (torvalds/linux@25d9e2d15286281ec8) which makes it safe to use for us.

@tuxoko
Copy link
Contributor

tuxoko commented Jan 13, 2017

We need to add generic_write_checks as well.

behlendorf added a commit to behlendorf/zfs that referenced this issue Jan 13, 2017
The .write/.read file operations callbacks can be retired since
support for .read_iter/.write_iter and .aio_read/.aio_write has
been added.  The vfs_write()/vfs_read() entry functions will
select the correct interface for the kernel.  This is desirable
because all VFS write/read operations now rely on common code.

This change also add the generic write checks to make sure that
ulimits are enforced correctly on write.  A similar check was
added to zpl_fallocate() so the truncate case is also handled
properly.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#5587
@behlendorf
Copy link
Contributor

@tuxoko can you please review #5588 as a potential fix for this issue. It's been lightly tested with CentOS 7 and works as expected, I've open the PRs for the bots to test and to get feedback on the approach.

behlendorf added a commit to behlendorf/zfs that referenced this issue Jan 13, 2017
The .write/.read file operations callbacks can be retired since
support for .read_iter/.write_iter and .aio_read/.aio_write has
been added.  The vfs_write()/vfs_read() entry functions will
select the correct interface for the kernel.  This is desirable
because all VFS write/read operations now rely on common code.

This change also add the generic write checks to make sure that
ulimits are enforced correctly on write.  A similar check was
added to zpl_fallocate() so the truncate case is also handled
properly.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#5587
behlendorf added a commit to behlendorf/zfs that referenced this issue Jan 13, 2017
The .write/.read file operations callbacks can be retired since
support for .read_iter/.write_iter and .aio_read/.aio_write has
been added.  The vfs_write()/vfs_read() entry functions will
select the correct interface for the kernel.  This is desirable
because all VFS write/read operations now rely on common code.

This change also add the generic write checks to make sure that
ulimits are enforced correctly on write.  A similar check was
added to zpl_fallocate() so the truncate case is also handled
properly.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#5587
tuxoko pushed a commit to tuxoko/zfs that referenced this issue Jan 26, 2017
The .write/.read file operations callbacks can be retired since
support for .read_iter/.write_iter and .aio_read/.aio_write has
been added.  The vfs_write()/vfs_read() entry functions will
select the correct interface for the kernel.  This is desirable
because all VFS write/read operations now rely on common code.

This change also add the generic write checks to make sure that
ulimits are enforced correctly on write.  A similar check was
added to zpl_fallocate() so the truncate case is also handled
properly.

Signed-off-by: Brian Behlendorf <[email protected]>
Signed-off-by: Chunwei Chen <[email protected]>
Issue openzfs#5587
tuxoko pushed a commit to tuxoko/zfs that referenced this issue Jan 27, 2017
The .write/.read file operations callbacks can be retired since
support for .read_iter/.write_iter and .aio_read/.aio_write has
been added.  The vfs_write()/vfs_read() entry functions will
select the correct interface for the kernel.  This is desirable
because all VFS write/read operations now rely on common code.

This change also add the generic write checks to make sure that
ulimits are enforced correctly on write.  A similar check was
added to zpl_fallocate() so the truncate case is also handled
properly.

Signed-off-by: Brian Behlendorf <[email protected]>
Signed-off-by: Chunwei Chen <[email protected]>
Issue openzfs#5587
tuxoko pushed a commit to tuxoko/zfs that referenced this issue Jan 27, 2017
The .write/.read file operations callbacks can be retired since
support for .read_iter/.write_iter and .aio_read/.aio_write has
been added.  The vfs_write()/vfs_read() entry functions will
select the correct interface for the kernel.  This is desirable
because all VFS write/read operations now rely on common code.

This change also add the generic write checks to make sure that
ulimits are enforced correctly on write.  A similar check was
added to zpl_fallocate() so the truncate case is also handled
properly.

Signed-off-by: Brian Behlendorf <[email protected]>
Signed-off-by: Chunwei Chen <[email protected]>
Issue openzfs#5587
tuxoko pushed a commit to tuxoko/zfs that referenced this issue Jan 27, 2017
The .write/.read file operations callbacks can be retired since
support for .read_iter/.write_iter and .aio_read/.aio_write has
been added.  The vfs_write()/vfs_read() entry functions will
select the correct interface for the kernel.  This is desirable
because all VFS write/read operations now rely on common code.

This change also add the generic write checks to make sure that
ulimits are enforced correctly on write.

Signed-off-by: Brian Behlendorf <[email protected]>
Signed-off-by: Chunwei Chen <[email protected]>
Issue openzfs#5587
tuxoko pushed a commit to tuxoko/zfs that referenced this issue Jan 27, 2017
The .write/.read file operations callbacks can be retired since
support for .read_iter/.write_iter and .aio_read/.aio_write has
been added.  The vfs_write()/vfs_read() entry functions will
select the correct interface for the kernel.  This is desirable
because all VFS write/read operations now rely on common code.

This change also add the generic write checks to make sure that
ulimits are enforced correctly on write.

Signed-off-by: Brian Behlendorf <[email protected]>
Signed-off-by: Chunwei Chen <[email protected]>
Issue openzfs#5587
behlendorf pushed a commit to behlendorf/zfs that referenced this issue Feb 2, 2017
The .write/.read file operations callbacks can be retired since
support for .read_iter/.write_iter and .aio_read/.aio_write has
been added.  The vfs_write()/vfs_read() entry functions will
select the correct interface for the kernel.  This is desirable
because all VFS write/read operations now rely on common code.

This change also add the generic write checks to make sure that
ulimits are enforced correctly on write.

Signed-off-by: Brian Behlendorf <[email protected]>
Signed-off-by: Chunwei Chen <[email protected]>
Closes openzfs#5587
Closes openzfs#5673
behlendorf pushed a commit to behlendorf/zfs that referenced this issue Feb 2, 2017
The .write/.read file operations callbacks can be retired since
support for .read_iter/.write_iter and .aio_read/.aio_write has
been added.  The vfs_write()/vfs_read() entry functions will
select the correct interface for the kernel.  This is desirable
because all VFS write/read operations now rely on common code.

This change also add the generic write checks to make sure that
ulimits are enforced correctly on write.

Signed-off-by: Brian Behlendorf <[email protected]>
Signed-off-by: Chunwei Chen <[email protected]>
Closes openzfs#5587
Closes openzfs#5673
Requires-builders: style
behlendorf pushed a commit that referenced this issue Feb 3, 2017
The .write/.read file operations callbacks can be retired since
support for .read_iter/.write_iter and .aio_read/.aio_write has
been added.  The vfs_write()/vfs_read() entry functions will
select the correct interface for the kernel.  This is desirable
because all VFS write/read operations now rely on common code.

This change also add the generic write checks to make sure that
ulimits are enforced correctly on write.

Signed-off-by: Brian Behlendorf <[email protected]>
Signed-off-by: Chunwei Chen <[email protected]>
Closes #5587
Closes #5673
wli5 pushed a commit to wli5/zfs that referenced this issue Feb 28, 2017
The .write/.read file operations callbacks can be retired since
support for .read_iter/.write_iter and .aio_read/.aio_write has
been added.  The vfs_write()/vfs_read() entry functions will
select the correct interface for the kernel.  This is desirable
because all VFS write/read operations now rely on common code.

This change also add the generic write checks to make sure that
ulimits are enforced correctly on write.

Signed-off-by: Brian Behlendorf <[email protected]>
Signed-off-by: Chunwei Chen <[email protected]>
Closes openzfs#5587 
Closes openzfs#5673
wli5 pushed a commit to wli5/zfs that referenced this issue Feb 28, 2017
The .write/.read file operations callbacks can be retired since
support for .read_iter/.write_iter and .aio_read/.aio_write has
been added.  The vfs_write()/vfs_read() entry functions will
select the correct interface for the kernel.  This is desirable
because all VFS write/read operations now rely on common code.

This change also add the generic write checks to make sure that
ulimits are enforced correctly on write.

Signed-off-by: Brian Behlendorf <[email protected]>
Signed-off-by: Chunwei Chen <[email protected]>
Closes openzfs#5587
Closes openzfs#5673
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants