[pnfs] [PATCH 2/4] [SQUASHME] pnfs: prevent offset overflow in filelayout_commit

Benny Halevy bhalevy.lists at gmail.com
Wed May 14 13:38:32 EDT 2008


wb_index needs to be typecasted to u64 or loff_t before shifting left
with PAGE_CACHE_SHIFT to prevent overflow on 32-bit architectures
since pgoff_t is unsigned long.

Signed-off-by: Benny Halevy <bhalevy at panasas.com>
---
 fs/nfs/nfs4filelayout.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/nfs/nfs4filelayout.c b/fs/nfs/nfs4filelayout.c
index 7ed0843..c7d043b 100644
--- a/fs/nfs/nfs4filelayout.c
+++ b/fs/nfs/nfs4filelayout.c
@@ -599,7 +599,7 @@ filelayout_commit(struct pnfs_layout_type *layoutid, int sync,
 	while (!list_empty(head)) {
 		req = nfs_list_entry(head->next);
 
-		file_offset = req->wb_index << PAGE_CACHE_SHIFT;
+		file_offset = (loff_t)req->wb_index << PAGE_CACHE_SHIFT;
 
 		/* Get dserver for the current page */
 		status = nfs4_pnfs_dserver_get(data->lseg,
@@ -635,7 +635,7 @@ filelayout_commit(struct pnfs_layout_type *layoutid, int sync,
 		 *      and then compare if they are the same. */
 		list_for_each_safe(pos, tmp, head) {
 			reqt = nfs_list_entry(pos);
-			comp_offset = reqt->wb_index << PAGE_CACHE_SHIFT;
+			comp_offset = (loff_t)reqt->wb_index << PAGE_CACHE_SHIFT;
 			idx2 = filelayout_dserver_get_index(comp_offset, di, nfslay);
 			if (idx1 == idx2) {
 				nfs_list_remove_request(reqt);
-- 
1.5.3.3



More information about the pNFS mailing list