From patchwork Sun Jun 7 00:42:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Antonov X-Patchwork-Id: 6560401 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 63A339F4DD for ; Sat, 6 Jun 2015 22:42:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6DDDF20624 for ; Sat, 6 Jun 2015 22:42:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 085F92062D for ; Sat, 6 Jun 2015 22:42:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753048AbbFFWm2 (ORCPT ); Sat, 6 Jun 2015 18:42:28 -0400 Received: from mail-qc0-f196.google.com ([209.85.216.196]:32892 "EHLO mail-qc0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752160AbbFFWm0 (ORCPT ); Sat, 6 Jun 2015 18:42:26 -0400 Received: by qcrw7 with SMTP id w7so5171112qcr.0 for ; Sat, 06 Jun 2015 15:42:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=VMMLtGSW6g6jlFK6GmacDYAGwJOIBTeRJCr0fWUED0Q=; b=Q9raNBw0HfqEHK0ypzgaHZBMwH1aMlv1E6Fag0gPZx7tHAmeYHUMqiGOqje/G35wpG qkTLfR0KOExaOl3Dgd9IrOWm3q2hVRAyIyofD1gRPYNCWNHMjRZCqcZLxpZtsrjTL6qv tuLVBinqZFqnwA+hiACcT+cquBQQ6v5UJSbP9YdqPIp2C2FxWznnzzM2qtlU8BcxMxlM PM2Yj1DLp6JCyjjaAgXwBj3UwtQoeYXnxLbEDsuGX5NGyNQcw2E6r9JtOEHQHy/dpVVt 4z04xqTjDDUO18qRZMqpMY1HKxln93duT2R62U12hNvO3Gp5zdy3R+Hgl39Jhy9ikVO6 Y3+A== X-Received: by 10.140.106.101 with SMTP id d92mr11430050qgf.70.1433630545186; Sat, 06 Jun 2015 15:42:25 -0700 (PDT) Received: from localhost.localdomain (HSI-KBW-078-042-106-148.hsi3.kabel-badenwuerttemberg.de. [78.42.106.148]) by mx.google.com with ESMTPSA id i7sm5913653qge.32.2015.06.06.15.42.23 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 06 Jun 2015 15:42:24 -0700 (PDT) From: Sergei Antonov To: linux-fsdevel@vger.kernel.org, Sasha Levin Cc: Anton Altaparmakov , Al Viro , Christoph Hellwig , Andrew Morton , Vyacheslav Dubeyko , Hin-Tak Leung , Sougata Santra , Sergei Antonov Subject: [PATCH] hfsplus: release bnode pages after use, not before Date: Sun, 7 Jun 2015 02:42:56 +0200 Message-Id: <1433637776-3559-1-git-send-email-saproj@gmail.com> X-Mailer: git-send-email 2.3.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fix this bugreport by Sasha Levin: http://lkml.org/lkml/2015/2/20/85 ("use after free") Make sure mapped pages are available for the entire lifetime of hfs_bnode. Cc: Anton Altaparmakov Cc: Al Viro Cc: Christoph Hellwig Cc: Andrew Morton Cc: Vyacheslav Dubeyko Cc: Hin-Tak Leung Cc: Sougata Santra Reported-by: Sasha Levin Signed-off-by: Sergei Antonov Reviewed-by: Anton Altaparmakov --- fs/hfsplus/bnode.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/hfsplus/bnode.c b/fs/hfsplus/bnode.c index 759708f..5af50fb 100644 --- a/fs/hfsplus/bnode.c +++ b/fs/hfsplus/bnode.c @@ -454,7 +454,6 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid) page_cache_release(page); goto fail; } - page_cache_release(page); node->page[i] = page; } @@ -566,13 +565,12 @@ node_error: void hfs_bnode_free(struct hfs_bnode *node) { -#if 0 int i; - for (i = 0; i < node->tree->pages_per_bnode; i++) + for (i = 0; i < node->tree->pages_per_bnode; i++) { if (node->page[i]) page_cache_release(node->page[i]); -#endif + } kfree(node); }