From patchwork Thu Mar 21 12:30:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 10863429 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 CC68113B5 for ; Thu, 21 Mar 2019 12:30:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB4A92A050 for ; Thu, 21 Mar 2019 12:30:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AFD2D2A13B; Thu, 21 Mar 2019 12:30:54 +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=unavailable 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 70DFC2A13F for ; Thu, 21 Mar 2019 12:30:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728129AbfCUMax (ORCPT ); Thu, 21 Mar 2019 08:30:53 -0400 Received: from mx2.suse.de ([195.135.220.15]:50230 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727949AbfCUMax (ORCPT ); Thu, 21 Mar 2019 08:30:53 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 9BE66AEC8; Thu, 21 Mar 2019 12:30:51 +0000 (UTC) From: Johannes Thumshirn To: Jens Axboe Cc: Hannes Reinecke , Bart Van Assche , Christoph Hellwig , Jan Kara , Linux Block Layer Mailinglist , Linux FSDEVEL Mailinglist , Johannes Thumshirn Subject: [PATCH 0/2] add flag for tracking bio allocation Date: Thu, 21 Mar 2019 13:30:43 +0100 Message-Id: <20190321123045.32396-1-jthumshirn@suse.de> X-Mailer: git-send-email 2.16.4 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hannes recently sent a patch in [1] to fix an Oops caused by __blkdev_direct_IO_simple() doing bio submissions from the stack and which ended up being freed bio bio_free(). As bio_free() expected a bio which was allocated by bio_alloc_bioset() it crashed. I've sent out a different aproach to tackling this problem and both Jens and Jan leaned to my solution, namely adding another bio flag tracking the allocation. As flag is the last available bit, add a compile time check as a safety net, so we're not accidentially overriding the high 3 bits of bi_flags, which are used for the BVEC_POOL_IDX(). Note, Jens also staged a patch in his io_uring-next branch taking the last flag. For this reason patch 2/2 might not be applied in this form, but 1/2 is still applicable then. [1] https://lore.kernel.org/linux-block/20190320081253.129688-1-hare@suse.de/ Johannes Thumshirn (2): block: bio: ensure newly added bio flags don't override BVEC_POOL_IDX bio: introduce BIO_ALLOCED flag and check it in bio_free block/bio.c | 12 ++++++++++++ include/linux/blk_types.h | 32 ++++++++++++++++++-------------- 2 files changed, 30 insertions(+), 14 deletions(-)