From: Greg KH <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: torvalds@linux-foundation.org, akpm@linux-foundation.org,
alan@lxorguk.ukuu.org.uk, Tyler Hicks <tyhicks@canonical.com>
Subject: [03/20] eCryptfs: Make truncate path killable
Date: Wed, 01 Feb 2012 12:14:05 -0800 [thread overview]
Message-ID: <20120201201531.344259682@clark.kroah.org> (raw)
In-Reply-To: <20120201210055.GA25374@kroah.com>
2.6.32-longterm review patch. If anyone has any objections, please let me know.
------------------
From: Tyler Hicks <tyhicks@canonical.com>
commit 5e6f0d769017cc49207ef56996e42363ec26c1f0 upstream.
ecryptfs_write() handles the truncation of eCryptfs inodes. It grabs a
page, zeroes out the appropriate portions, and then encrypts the page
before writing it to the lower filesystem. It was unkillable and due to
the lack of sparse file support could result in tying up a large portion
of system resources, while encrypting pages of zeros, with no way for
the truncate operation to be stopped from userspace.
This patch adds the ability for ecryptfs_write() to detect a pending
fatal signal and return as gracefully as possible. The intent is to
leave the lower file in a useable state, while still allowing a user to
break out of the encryption loop. If a pending fatal signal is detected,
the eCryptfs inode size is updated to reflect the modified inode size
and then -EINTR is returned.
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/ecryptfs/read_write.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
--- a/fs/ecryptfs/read_write.c
+++ b/fs/ecryptfs/read_write.c
@@ -136,6 +136,11 @@ int ecryptfs_write(struct file *ecryptfs
size_t num_bytes = (PAGE_CACHE_SIZE - start_offset_in_page);
size_t total_remaining_bytes = ((offset + size) - pos);
+ if (fatal_signal_pending(current)) {
+ rc = -EINTR;
+ break;
+ }
+
if (num_bytes > total_remaining_bytes)
num_bytes = total_remaining_bytes;
if (pos < offset) {
@@ -197,15 +202,19 @@ int ecryptfs_write(struct file *ecryptfs
}
pos += num_bytes;
}
- if ((offset + size) > ecryptfs_file_size) {
- i_size_write(ecryptfs_inode, (offset + size));
+ if (pos > ecryptfs_file_size) {
+ i_size_write(ecryptfs_inode, pos);
if (crypt_stat->flags & ECRYPTFS_ENCRYPTED) {
- rc = ecryptfs_write_inode_size_to_metadata(
+ int rc2;
+
+ rc2 = ecryptfs_write_inode_size_to_metadata(
ecryptfs_inode);
- if (rc) {
+ if (rc2) {
printk(KERN_ERR "Problem with "
"ecryptfs_write_inode_size_to_metadata; "
- "rc = [%d]\n", rc);
+ "rc = [%d]\n", rc2);
+ if (!rc)
+ rc = rc2;
goto out;
}
}
next prev parent reply other threads:[~2012-02-01 21:59 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-01 21:00 [00/20] 2.6.32.56-longterm review Greg KH
2012-02-01 20:14 ` [01/20] eCryptfs: Sanitize write counts of /dev/ecryptfs Greg KH
2012-02-01 20:14 ` [02/20] ecryptfs: Improve metadata read failure logging Greg KH
2012-02-01 20:14 ` Greg KH [this message]
2012-02-01 20:14 ` [04/20] drm: Fix authentication kernel crash Greg KH
2012-02-01 20:14 ` [05/20] crypto: sha512 - make it work, undo percpu message schedule Greg KH
2012-02-01 20:14 ` [06/20] crypto: sha512 - reduce stack usage to safe number Greg KH
2012-02-01 23:42 ` Alexey Dobriyan
2012-02-01 23:52 ` Greg KH
2012-02-02 0:04 ` Herbert Xu
2012-02-02 0:09 ` Greg KH
2012-02-01 20:14 ` [07/20] Revert "ARM: 7220/1: mmc: mmci: Fixup error handling for dma" Greg KH
2012-02-01 20:14 ` [08/20] block: fail SCSI passthrough ioctls on partition devices Greg KH
2012-02-01 20:14 ` [09/20] dm: do not forward ioctls from logical volumes to the underlying device Greg KH
2012-02-01 20:14 ` [10/20] USB: ftdi_sio: fix TIOCSSERIAL baud_base handling Greg KH
2012-02-01 20:14 ` [11/20] USB: ftdi_sio: add PID for TI XDS100v2 / BeagleBone A3 Greg KH
2012-02-01 20:14 ` [12/20] USB: serial: ftdi additional IDs Greg KH
2012-02-01 20:14 ` [13/20] USB: ftdi_sio: Add more identifiers Greg KH
2012-02-01 20:14 ` [14/20] USB: cdc-wdm: updating desc->length must be protected by spin_lock Greg KH
2012-02-01 20:14 ` [15/20] usb: io_ti: Make edge_remove_sysfs_attrs the port_remove method Greg KH
2012-02-01 20:14 ` [16/20] USB: usbsevseg: fix max length Greg KH
2012-02-01 20:14 ` [17/20] hwmon: (f71805f) Fix clamping of temperature limits Greg KH
2012-02-01 20:14 ` [18/20] hwmon: (sht15) fix bad error code Greg KH
2012-02-01 20:14 ` [19/20] USB: serial: CP210x: Added USB-ID for the Link Instruments MSO-19 Greg KH
2012-02-01 20:14 ` [20/20] USB: cp210x: do not map baud rates to B0 Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120201201531.344259682@clark.kroah.org \
--to=gregkh@linuxfoundation.org \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=tyhicks@canonical.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).