From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org, jejb@kernel.org
Cc: Justin Forbes <jmforbes@linuxtx.org>,
Zwane Mwaikambo <zwane@arm.linux.org.uk>,
"Theodore Ts'o" <tytso@mit.edu>,
Randy Dunlap <rdunlap@xenotime.net>,
Dave Jones <davej@redhat.com>,
Chuck Wolber <chuckw@quantumlinux.com>,
Chris Wedgwood <reviews@ml.cw.f00f.org>,
Michael Krufky <mkrufky@linuxtv.org>,
Chuck Ebbert <cebbert@redhat.com>,
Domenico Andreoli <cavokz@gmail.com>, Willy Tarreau <w@1wt.eu>,
Rodrigo Rubira Branco <rbranco@la.checkpoint.com>,
Jake Edge <jake@lwn.net>, Eugene Teo <eteo@redhat.com>,
torvalds@linux-foundation.org, akpm@linux-foundation.org,
alan@lxorguk.ukuu.org.uk, Eric Sandeen <sandeen@redhat.com>,
Michael Halcrow <mhalcrow@us.ibm.com>,
Rik van Riel <riel@redhat.com>
Subject: [patch 23/29] eCryptfs: use page_alloc not kmalloc to get a page of memory
Date: Wed, 30 Jul 2008 16:27:32 -0700 [thread overview]
Message-ID: <20080730232732.GX30670@suse.de> (raw)
In-Reply-To: <20080730232451.GA30670@suse.de>
[-- Attachment #1: ecryptfs-use-page_alloc-not-kmalloc-to-get-a-page-of-memory.patch --]
[-- Type: text/plain, Size: 3623 bytes --]
2.6.25-stable review patch. If anyone has any objections, please let us
know.
------------------
From: Eric Sandeen <sandeen@redhat.com>
commit 7fcba054373d5dfc43d26e243a5c9b92069972ee upstream
Date: Mon, 28 Jul 2008 15:46:39 -0700
Subject: [patch 23/29] eCryptfs: use page_alloc not kmalloc to get a page of memory
With SLUB debugging turned on in 2.6.26, I was getting memory corruption
when testing eCryptfs. The root cause turned out to be that eCryptfs was
doing kmalloc(PAGE_CACHE_SIZE); virt_to_page() and treating that as a nice
page-aligned chunk of memory. But at least with SLUB debugging on, this
is not always true, and the page we get from virt_to_page does not
necessarily match the PAGE_CACHE_SIZE worth of memory we got from kmalloc.
My simple testcase was 2 loops doing "rm -f fileX; cp /tmp/fileX ." for 2
different multi-megabyte files. With this change I no longer see the
corruption.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Acked-by: Michael Halcrow <mhalcrow@us.ibm.com>
Acked-by: Rik van Riel <riel@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
fs/ecryptfs/crypto.c | 30 ++++++++++++++++++------------
1 file changed, 18 insertions(+), 12 deletions(-)
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -474,8 +474,8 @@ int ecryptfs_encrypt_page(struct page *p
{
struct inode *ecryptfs_inode;
struct ecryptfs_crypt_stat *crypt_stat;
- char *enc_extent_virt = NULL;
- struct page *enc_extent_page;
+ char *enc_extent_virt;
+ struct page *enc_extent_page = NULL;
loff_t extent_offset;
int rc = 0;
@@ -491,14 +491,14 @@ int ecryptfs_encrypt_page(struct page *p
page->index);
goto out;
}
- enc_extent_virt = kmalloc(PAGE_CACHE_SIZE, GFP_USER);
- if (!enc_extent_virt) {
+ enc_extent_page = alloc_page(GFP_USER);
+ if (!enc_extent_page) {
rc = -ENOMEM;
ecryptfs_printk(KERN_ERR, "Error allocating memory for "
"encrypted extent\n");
goto out;
}
- enc_extent_page = virt_to_page(enc_extent_virt);
+ enc_extent_virt = kmap(enc_extent_page);
for (extent_offset = 0;
extent_offset < (PAGE_CACHE_SIZE / crypt_stat->extent_size);
extent_offset++) {
@@ -526,7 +526,10 @@ int ecryptfs_encrypt_page(struct page *p
}
}
out:
- kfree(enc_extent_virt);
+ if (enc_extent_page) {
+ kunmap(enc_extent_page);
+ __free_page(enc_extent_page);
+ }
return rc;
}
@@ -608,8 +611,8 @@ int ecryptfs_decrypt_page(struct page *p
{
struct inode *ecryptfs_inode;
struct ecryptfs_crypt_stat *crypt_stat;
- char *enc_extent_virt = NULL;
- struct page *enc_extent_page;
+ char *enc_extent_virt;
+ struct page *enc_extent_page = NULL;
unsigned long extent_offset;
int rc = 0;
@@ -626,14 +629,14 @@ int ecryptfs_decrypt_page(struct page *p
page->index);
goto out;
}
- enc_extent_virt = kmalloc(PAGE_CACHE_SIZE, GFP_USER);
- if (!enc_extent_virt) {
+ enc_extent_page = alloc_page(GFP_USER);
+ if (!enc_extent_page) {
rc = -ENOMEM;
ecryptfs_printk(KERN_ERR, "Error allocating memory for "
"encrypted extent\n");
goto out;
}
- enc_extent_page = virt_to_page(enc_extent_virt);
+ enc_extent_virt = kmap(enc_extent_page);
for (extent_offset = 0;
extent_offset < (PAGE_CACHE_SIZE / crypt_stat->extent_size);
extent_offset++) {
@@ -661,7 +664,10 @@ int ecryptfs_decrypt_page(struct page *p
}
}
out:
- kfree(enc_extent_virt);
+ if (enc_extent_page) {
+ kunmap(enc_extent_page);
+ __free_page(enc_extent_page);
+ }
return rc;
}
--
next prev parent reply other threads:[~2008-07-30 23:41 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20080730231003.655833364@mini.kroah.org>
2008-07-30 23:24 ` [patch 00/29] 2.6.25-stable review Greg KH
2008-07-30 23:26 ` [patch 01/29] quota: fix possible infinite loop in quota code Greg KH
2008-07-30 23:26 ` [patch 02/29] isofs: fix minor filesystem corruption Greg KH
2008-07-30 23:26 ` [patch 03/29] x86: fix crash due to missing debugctlmsr on AMD K6-3 Greg KH
2008-07-30 23:26 ` [patch 04/29] vmlinux.lds: move __attribute__((__cold__)) functions back into final .text section Greg KH
2008-07-30 23:26 ` [patch 05/29] tcp: Clear probes_out more aggressively in tcp_ack() Greg KH
2008-07-30 23:26 ` [patch 06/29] sparc64: Fix lockdep issues in LDC protocol layer Greg KH
2008-07-30 23:26 ` [patch 07/29] sparc64: Fix cpufreq notifier registry Greg KH
2008-07-30 23:26 ` [patch 08/29] sparc64: Do not define BIO_VMERGE_BOUNDARY Greg KH
2008-07-30 23:27 ` [patch 09/29] pata_atiixp: Dont disable Greg KH
2008-07-30 23:27 ` [patch 10/29] markers: fix duplicate modpost entry Greg KH
2008-07-30 23:27 ` [patch 11/29] ide-cd: fix oops when using growisofs Greg KH
2008-07-30 23:27 ` [patch 12/29] Fix build on COMPAT platforms when CONFIG_EPOLL is disabled Greg KH
2008-07-30 23:27 ` [patch 13/29] ARM: fix fls() for 64-bit arguments Greg KH
2008-07-30 23:27 ` [patch 14/29] ALSA: hda - Fix "alc262_sony_unsol" hda_verb array Greg KH
2008-07-30 23:27 ` [patch 15/29] ALSA: trident - pause s/pdif output Greg KH
2008-07-30 23:27 ` [patch 16/29] ahci: retry enabling AHCI a few times before spitting out WARN_ON() Greg KH
2008-07-30 23:27 ` [patch 17/29] x86: fix kernel_physical_mapping_init() for large x86 systems Greg KH
2008-07-30 23:27 ` Greg KH
2008-07-30 23:27 ` [patch 18/29] VFS: increase pseudo-filesystem block size to PAGE_SIZE Greg KH
2008-07-30 23:27 ` [patch 19/29] tmpfs: fix kernel BUG in shmem_delete_inode Greg KH
2008-07-30 23:27 ` [patch 20/29] mpc52xx_psc_spi: fix block transfer Greg KH
2008-07-30 23:27 ` [patch 21/29] markers: fix markers read barrier for multiple probes Greg KH
2008-07-30 23:27 ` [patch 22/29] ixgbe: remove device ID for unsupported device Greg KH
2008-07-30 23:27 ` Greg KH [this message]
2008-07-30 23:27 ` [patch 24/29] cpufreq acpi: only call _PPC after cpufreq ACPI init funcs got called already Greg KH
2008-07-30 23:27 ` [patch 25/29] b43legacy: Release mutex in error handling code Greg KH
2008-07-30 23:27 ` [patch 26/29] ath5k: dont enable MSI, we cannot handle it yet Greg KH
2008-07-30 23:27 ` [patch 27/29] Correct hash flushing from huge_ptep_set_wrprotect() Greg KH
2008-07-30 23:27 ` [patch 28/29] netfilter -stable: nf_conntrack_tcp: fix endless loop Greg KH
2008-07-30 23:27 ` [patch 29/29] Fix off-by-one error in iov_iter_advance() 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=20080730232732.GX30670@suse.de \
--to=gregkh@suse.de \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=cavokz@gmail.com \
--cc=cebbert@redhat.com \
--cc=chuckw@quantumlinux.com \
--cc=davej@redhat.com \
--cc=eteo@redhat.com \
--cc=jake@lwn.net \
--cc=jejb@kernel.org \
--cc=jmforbes@linuxtx.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhalcrow@us.ibm.com \
--cc=mkrufky@linuxtv.org \
--cc=rbranco@la.checkpoint.com \
--cc=rdunlap@xenotime.net \
--cc=reviews@ml.cw.f00f.org \
--cc=riel@redhat.com \
--cc=sandeen@redhat.com \
--cc=stable@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=tytso@mit.edu \
--cc=w@1wt.eu \
--cc=zwane@arm.linux.org.uk \
/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 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.