This is a note to let you know that I've just added the patch titled

    ceph: avoid 32-bit page index overflow

to the 3.4-stable tree which can be found at:
    
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     ceph-avoid-32-bit-page-index-overflow.patch
and it can be found in the queue-3.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <[email protected]> know about it.


>From 6285bc231277419255f3498d3eb5ddc9f8e7fe79 Mon Sep 17 00:00:00 2001
From: Alex Elder <[email protected]>
Date: Tue, 2 Oct 2012 10:25:51 -0500
Subject: ceph: avoid 32-bit page index overflow

From: Alex Elder <[email protected]>

commit 6285bc231277419255f3498d3eb5ddc9f8e7fe79 upstream.

A pgoff_t is defined (by default) to have type (unsigned long).  On
architectures such as i686 that's a 32-bit type.  The ceph address
space code was attempting to produce 64 bit offsets by shifting a
page's index by PAGE_CACHE_SHIFT, but the result was not what was
desired because the shift occurred before the result got promoted
to 64 bits.

Fix this by converting all uses of page->index used in this way to
use the page_offset() macro, which ensures the 64-bit result has the
intended value.

This fixes http://tracker.newdream.net/issues/3112

Reported-by:  Mohamed Pakkeer <[email protected]>
Signed-off-by: Alex Elder <[email protected]>
Reviewed-by: Sage Weil <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

---
 fs/ceph/addr.c |   11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -202,7 +202,7 @@ static int readpage_nounlock(struct file
        dout("readpage inode %p file %p page %p index %lu\n",
             inode, filp, page, page->index);
        err = ceph_osdc_readpages(osdc, ceph_vino(inode), &ci->i_layout,
-                                 page->index << PAGE_CACHE_SHIFT, &len,
+                                 (u64) page_offset(page), &len,
                                  ci->i_truncate_seq, ci->i_truncate_size,
                                  &page, 1, 0);
        if (err == -ENOENT)
@@ -283,7 +283,7 @@ static int start_read(struct inode *inod
        int nr_pages = 0;
        int ret;
 
-       off = page->index << PAGE_CACHE_SHIFT;
+       off = (u64) page_offset(page);
 
        /* count pages */
        next_index = page->index;
@@ -423,7 +423,7 @@ static int writepage_nounlock(struct pag
        struct ceph_inode_info *ci;
        struct ceph_fs_client *fsc;
        struct ceph_osd_client *osdc;
-       loff_t page_off = page->index << PAGE_CACHE_SHIFT;
+       loff_t page_off = page_offset(page);
        int len = PAGE_CACHE_SIZE;
        loff_t i_size;
        int err = 0;
@@ -814,8 +814,7 @@ get_more_pages:
                        /* ok */
                        if (locked_pages == 0) {
                                /* prepare async write request */
-                               offset = (unsigned long long)page->index
-                                       << PAGE_CACHE_SHIFT;
+                               offset = (u64) page_offset(page);
                                len = wsize;
                                req = ceph_osdc_new_request(&fsc->client->osdc,
                                            &ci->i_layout,
@@ -1177,7 +1176,7 @@ static int ceph_page_mkwrite(struct vm_a
        struct inode *inode = vma->vm_file->f_dentry->d_inode;
        struct page *page = vmf->page;
        struct ceph_mds_client *mdsc = ceph_inode_to_client(inode)->mdsc;
-       loff_t off = page->index << PAGE_CACHE_SHIFT;
+       loff_t off = page_offset(page);
        loff_t size, len;
        int ret;
 


Patches currently in stable-queue which might be from [email protected] are

queue-3.4/libceph-check-for-invalid-mapping.patch
queue-3.4/ceph-avoid-32-bit-page-index-overflow.patch
--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to