BUG at fs/afs/file.c:137!
David Howells
dhowells at redhat.com
Wed Aug 26 11:41:31 EDT 2009
Anton Blanchard <anton at samba.org> wrote:
> Hit another one in afs_readpage:
>
> ASSERT(file != NULL);
>
> kernel BUG at fs/afs/file.c:137!
Can you try the attached patch please?
David
---
From: David Howells <dhowells at redhat.com>
Subject: [PATCH] AFS: Stop readlink() on AFS crashing because file not passed to afs_readpage()
kAFS crashes when asked to read a symbolic link because page_getlink() passes a
NULL file pointer to read_mapping_page(), but afs_readpage() expects a file
pointer from which to extract a key.
Modify afs_readpage() to request the appropriate key from the calling
process's keyrings if a file struct is not supplied with one attached.
Signed-off-by: David Howells <dhowells at redhat.com>
---
fs/afs/file.c | 18 +++++++++++++++---
1 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/fs/afs/file.c b/fs/afs/file.c
index 1586496..cbc746d 100644
--- a/fs/afs/file.c
+++ b/fs/afs/file.c
@@ -136,9 +136,16 @@ static int afs_readpage(struct file *file, struct page *page)
inode = page->mapping->host;
- ASSERT(file != NULL);
- key = file->private_data;
- ASSERT(key != NULL);
+ if (file) {
+ key = file->private_data;
+ ASSERT(key != NULL);
+ } else {
+ key = afs_request_key(AFS_FS_S(inode->i_sb)->volume->cell);
+ if (IS_ERR(key)) {
+ ret = PTR_ERR(key);
+ goto error_nokey;
+ }
+ }
_enter("{%x},{%lu},{%lu}", key_serial(key), inode->i_ino, page->index);
@@ -209,12 +216,17 @@ static int afs_readpage(struct file *file, struct page *page)
unlock_page(page);
}
+ if (!file)
+ key_put(key);
_leave(" = 0");
return 0;
error:
SetPageError(page);
unlock_page(page);
+ if (!file)
+ key_put(key);
+error_nokey:
_leave(" = %d", ret);
return ret;
}
More information about the linux-afs
mailing list