From patchwork Sat Jun 8 16:48:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10983259 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 663141515 for ; Sat, 8 Jun 2019 16:49:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5284C2892A for ; Sat, 8 Jun 2019 16:49:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 466A428B4D; Sat, 8 Jun 2019 16:49:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E321F2892A for ; Sat, 8 Jun 2019 16:49:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727274AbfFHQtP (ORCPT ); Sat, 8 Jun 2019 12:49:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54406 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727217AbfFHQtO (ORCPT ); Sat, 8 Jun 2019 12:49:14 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9869130842B1; Sat, 8 Jun 2019 16:49:06 +0000 (UTC) Received: from localhost (ovpn-8-17.pek2.redhat.com [10.72.8.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A0FF2A18D; Sat, 8 Jun 2019 16:49:01 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, Ming Lei , David Gibson , "Darrick J. Wong" , linux-xfs@vger.kernel.org, Alexander Viro , Christoph Hellwig Subject: [PATCH 0/2] block: fix page leak by merging to same page Date: Sun, 9 Jun 2019 00:48:51 +0800 Message-Id: <20190608164853.10938-1-ming.lei@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Sat, 08 Jun 2019 16:49:14 +0000 (UTC) Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi, 'pages' retrived by __bio_iov_iter_get_pages() may point to same page, and finally they can be merged to same page too in bio_add_page(), then page leak can be caused. Fixes this issue by dropping the extra page ref. Ming Lei (2): block: introduce 'enum bvec_merge_flags' for __bio_try_merge_page block: fix page leak in case of merging to same page block/bio.c | 34 ++++++++++++++++++++++++---------- fs/iomap.c | 3 ++- fs/xfs/xfs_aops.c | 3 ++- include/linux/bio.h | 9 ++++++++- 4 files changed, 36 insertions(+), 13 deletions(-) Cc: David Gibson Cc: "Darrick J. Wong" Cc: linux-xfs@vger.kernel.org Cc: Alexander Viro Cc: Christoph Hellwig