From patchwork Thu Sep 9 20:22:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauricio Faria de Oliveira X-Patchwork-Id: 1526293 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=Y6uaWc8t; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4H59Rr0Gghz9sX3; Fri, 10 Sep 2021 06:23:04 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1mOQZX-00025v-Sp; Thu, 09 Sep 2021 20:22:59 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1mOQZN-0001wP-5f for kernel-team@lists.ubuntu.com; Thu, 09 Sep 2021 20:22:49 +0000 Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 6B36240264 for ; Thu, 9 Sep 2021 20:22:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1631218967; bh=mxACkB4qWVdDJuIaT5zYyJkYOTvGtFTMEyqEU+JVHUs=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Y6uaWc8tlruphgoGxm3AB4KkBr5d94hOxzGeLWP/lPM04JaGwVWx8lAWvdx7jJYNd vd6tiQT1NsDD6Gzw+v4uhSL4oIz5mLZPO9Llt1/pNXPo/1whXyKfPZw2x99Iu+4mWs aWwXw1BG9qqV6tNSmMaisgeDe5LGHAjZOTzfrte79w3em+226MJJnAXMeBOgBmu2RT gnG2U+Yq9llgQ4IzENQdsptbX7aKIP45KwqN0vYpDmUvfFM0IpIZuqWps/Dovq+pOK sMut9IlxSQMBIP7BeEsAWBiXc6laH3G7IMX9xTxeLW1V5tT4f1tnGkwbu3xbK1DxGn zmVfCxdqfl31A== Received: by mail-qt1-f199.google.com with SMTP id c22-20020ac80096000000b0029f6809300eso9644783qtg.6 for ; Thu, 09 Sep 2021 13:22:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mxACkB4qWVdDJuIaT5zYyJkYOTvGtFTMEyqEU+JVHUs=; b=4Axcwr1TVgxKGx/c/tYcqjp/SWsbDolWER8IcLkqix6JVRAhmWPOjKVRbz8eYSgFGh E8DgsNU6pBvRgXpYx1pGEAZ+bfj/WNyIDt8swFkuKKsXMefRJAIlu8p5JaUB/2W/LcuJ O8EmpjZX411WCBLtjAgSWfXHHrBAsHGrhPrTT3exCl6q4WvDg84qEKo6afJ1+c+QQosh XcDaaoW5sbD5VkoHOWfSBCEgP/pRdTlJRMIS1/5SLskAS6bDwxst1sjoYz4mgn5PhPWo +3pLLRFlXQCU/GjcSzuzdCW7rB2/N8BfQuvN2IAlWaH89w9ZeukdbzXaiIifQ9KbBPG/ 3wug== X-Gm-Message-State: AOAM533Nz9pH3DaniMKwhHUSqpoCjwj050wsyvFNJ/tVimy2r7ttjwei GprYm40yFZ9mH59qOjy1tW804h2A7/DW/l5cPyFJigx+DauCnz0hUULn4wWxZMKCeZCFmjuf7LO bmol3kcBlLdKbpvPE89mKlRPUCtB9sKaul1PUKNI6DA== X-Received: by 2002:ac8:450e:: with SMTP id q14mr4702535qtn.323.1631218966218; Thu, 09 Sep 2021 13:22:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQh54wxyqRr8WayDNTZaxVSvS7SXtLJgPic17uQEl1XSaQkwk+3jTQ7J6WtOFl81iCMh4YLg== X-Received: by 2002:ac8:450e:: with SMTP id q14mr4702515qtn.323.1631218966013; Thu, 09 Sep 2021 13:22:46 -0700 (PDT) Received: from mfo-t470.. ([2804:14c:4e1:8732:e256:1fca:b0d8:d6a8]) by smtp.gmail.com with ESMTPSA id t64sm2172210qkd.71.2021.09.09.13.22.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Sep 2021 13:22:45 -0700 (PDT) From: Mauricio Faria de Oliveira To: kernel-team@lists.ubuntu.com Subject: [B][PATCH 5/5] ext4: fix mmap write protection for data=journal mode Date: Thu, 9 Sep 2021 17:22:30 -0300 Message-Id: <20210909202230.886329-10-mfo@canonical.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909202230.886329-1-mfo@canonical.com> References: <20210909202230.886329-1-mfo@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Jan Kara BugLink: https://bugs.launchpad.net/bugs/1847340 Commit afb585a97f81 "ext4: data=journal: write-protect pages on j_submit_inode_data_buffers()") added calls ext4_jbd2_inode_add_write() to track inode ranges whose mappings need to get write-protected during transaction commits. However the added calls use wrong start of a range (0 instead of page offset) and so write protection is not necessarily effective. Use correct range start to fix the problem. Fixes: afb585a97f81 ("ext4: data=journal: write-protect pages on j_submit_inode_data_buffers()") Signed-off-by: Jan Kara Link: https://lore.kernel.org/r/20201027132751.29858-1-jack@suse.cz Signed-off-by: Theodore Ts'o (cherry picked from commit b5b18160a3e7a9f55e3528d77051670cca6d9314) Signed-off-by: Mauricio Faria de Oliveira --- fs/ext4/inode.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index fa0d77dade2c..348f941c8531 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -2066,7 +2066,7 @@ static int __ext4_journalled_writepage(struct page *page, } if (ret == 0) ret = err; - err = ext4_jbd2_inode_add_write(handle, inode, 0, len); + err = ext4_jbd2_inode_add_write(handle, inode, page_offset(page), len); if (ret == 0) ret = err; EXT4_I(inode)->i_datasync_tid = handle->h_transaction->t_tid; @@ -6324,7 +6324,8 @@ int ext4_page_mkwrite(struct vm_fault *vmf) if (ext4_walk_page_buffers(handle, page_buffers(page), 0, len, NULL, write_end_fn)) goto out_error; - if (ext4_jbd2_inode_add_write(handle, inode, 0, len)) + if (ext4_jbd2_inode_add_write(handle, inode, + page_offset(page), len)) goto out_error; ext4_set_inode_state(inode, EXT4_STATE_JDATA); ret = 0; // ensure return is VM_FAULT_LOCKED.