Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6591459yba; Wed, 1 May 2019 15:46:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqyMKGXgkvTA7Ii7iN5G6UJxWl7nj+4da++LHZP5xshIyb8s6mr1VMh/DTRF/6ZNZpv+z/4d X-Received: by 2002:a63:fd49:: with SMTP id m9mr548584pgj.16.1556750805132; Wed, 01 May 2019 15:46:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556750805; cv=none; d=google.com; s=arc-20160816; b=YlZITSVw0t9bgWAzCxxQACgwSbzvTZTucRkTKLc9N3dC7k5QFQS4A073BYhhs5++ko 1jnMjxWjuBkqVws1PB7ZVDC6uC6M1Rc10qm3qNYxsKPPpcpHecweHNdTtYVDd8j2jDRs RbiK6yARlDemIg/91inIGsMZYbLppkd535KpN67UL0VfsYEBOD89BLaBC0S+HZzUqCN8 mLEANal4x5tM3SlFRjYPlDJqw4mSu8gyLrX2ZKdP1s382f385xz8WkwXfFy6whw03kQ6 fHVX+mYWPKc3Hp9MwAGc4vJuCwdo+15SzRQ8iQZ5q+5k54j5Xd+xvZI241Gb4HFKk57t DJSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KTblUkm/mNrdpDwsuqFCeKMxlNyLZ9dgBQCVvCxS8jE=; b=X7WsFrwV3qFi6dWdobGxvWNTG3AZNAjMnWp56gmS+uaDIpcgD5hPMIovt0OEzmtgzW ICyZ41JvdFvXxZTvdPgRO1KypQE5Ek718jcU4ZfbqQfQAvytBEJGG/wquawg9Yc7Kt6v 8sNYD4/r8XX5MvJMymgIEqjj67GQHBd40J5bEBzZZeLSjt33rkdXBbp6loMlXb5Ol4D5 MpGebz3ncmJHIKAj0EjoFBbSM4HbGIcZXHS2viWYDqK6iBkNgpsTNRgLay1XLLYwVly6 Qy8MU3kspCRU5PsErXCalWAs/GIFnmhU1V9YkpLDwEW3tnx2TMRre800lA6kFi7wmvH8 vWRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hDbvwal9; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u21si14168175pgh.13.2019.05.01.15.46.30; Wed, 01 May 2019 15:46:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hDbvwal9; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726167AbfEAWqU (ORCPT + 99 others); Wed, 1 May 2019 18:46:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:47220 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726327AbfEAWqI (ORCPT ); Wed, 1 May 2019 18:46:08 -0400 Received: from ebiggers-linuxstation.mtv.corp.google.com (unknown [104.132.1.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DA7DF21783; Wed, 1 May 2019 22:46:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556750768; bh=GhZSvQyKOd1yPn+J9hQUgu8RrjDo5ilzVAueJc2+4tw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hDbvwal9PolgHXpCoAoua0qXNJaAJ6DPhdeN1dZ73Ppw2vNEodhMnoiJZdUPJVKkY hwbRysc9P7QBAYm9nmpgkgIiz5O914cPMaPaE7j7zOzNhwjhi1b2t7SmKTIhJFRLk0 ziH7IFz0puhY3fyDHjhOmVvLq8PhrBafibd2Yzrg= From: Eric Biggers To: linux-fscrypt@vger.kernel.org Cc: linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-mtd@lists.infradead.org, linux-fsdevel@vger.kernel.org, Chandan Rajendra Subject: [PATCH 10/13] ext4: clear BH_Uptodate flag on decryption error Date: Wed, 1 May 2019 15:45:12 -0700 Message-Id: <20190501224515.43059-11-ebiggers@kernel.org> X-Mailer: git-send-email 2.21.0.593.g511ec345e18-goog In-Reply-To: <20190501224515.43059-1-ebiggers@kernel.org> References: <20190501224515.43059-1-ebiggers@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Chandan Rajendra If decryption fails, ext4_block_write_begin() can return with the page's buffer_head marked with the BH_Uptodate flag. This commit clears the BH_Uptodate flag in such cases. Signed-off-by: Chandan Rajendra Signed-off-by: Eric Biggers --- fs/ext4/inode.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 1ef5d791834fc..9382e1bcefe49 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -1225,10 +1225,14 @@ static int ext4_block_write_begin(struct page *page, loff_t pos, unsigned len, if (!buffer_uptodate(*wait_bh)) err = -EIO; } - if (unlikely(err)) + if (unlikely(err)) { page_zero_new_buffers(page, from, to); - else if (decrypt) + } else if (decrypt) { err = fscrypt_decrypt_pagecache_blocks(page, PAGE_SIZE, 0); + if (err) + clear_buffer_uptodate(*wait_bh); + } + return err; } #endif -- 2.21.0.593.g511ec345e18-goog