From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750862AbcEHNOu (ORCPT ); Sun, 8 May 2016 09:14:50 -0400 Received: from mail-pf0-f178.google.com ([209.85.192.178]:35644 "EHLO mail-pf0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750713AbcEHNOt (ORCPT ); Sun, 8 May 2016 09:14:49 -0400 From: Anthony Romano To: hughd@google.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Anthony Romano Subject: [PATCH] tmpfs: don't undo fallocate past its last page Date: Sun, 8 May 2016 06:16:27 -0700 Message-Id: <1462713387-16724-1-git-send-email-anthony.romano@coreos.com> X-Mailer: git-send-email 2.8.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When fallocate is interrupted it will undo a range that extends one byte past its range of allocated pages. This can corrupt an in-use page by zeroing out its first byte. Instead, undo using the inclusive byte range. Signed-off-by: Anthony Romano --- mm/shmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/shmem.c b/mm/shmem.c index 719bd6b..f0f9405 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2238,7 +2238,7 @@ static long shmem_fallocate(struct file *file, int mode, loff_t offset, /* Remove the !PageUptodate pages we added */ shmem_undo_range(inode, (loff_t)start << PAGE_SHIFT, - (loff_t)index << PAGE_SHIFT, true); + ((loff_t)index << PAGE_SHIFT) - 1, true); goto undone; } -- 2.8.1