From patchwork Wed Aug 2 12:27:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Broz X-Patchwork-Id: 9876701 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4A395602BC for ; Wed, 2 Aug 2017 12:29:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3CC99286D1 for ; Wed, 2 Aug 2017 12:29:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3176E28734; Wed, 2 Aug 2017 12:29:18 +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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 BE597286D1 for ; Wed, 2 Aug 2017 12:29:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753259AbdHBM3R (ORCPT ); Wed, 2 Aug 2017 08:29:17 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:38749 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753248AbdHBM3Q (ORCPT ); Wed, 2 Aug 2017 08:29:16 -0400 Received: by mail-wm0-f66.google.com with SMTP id y206so6962989wmd.5 for ; Wed, 02 Aug 2017 05:29:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=CdPv34/EbvMzWTAgZKO9W4amoj92OWWr5uaxYjRMD2U=; b=VftPKGsBzAX/uuq64CgO5i7iaPKMgA0rIfD3+TKpuTaNic8mh0F0mpYnanjRyf4c9U zPKKGuSXjKBfWSkqWvJP+hx43tAqzW6rRb040x7IdjQBB/g6AiFeT7j27YWT6xMi0wBg 8LGbFdPnv7WVQjXaLerrSq7MrrroatFhdDecBATdkFV13mrwrIx82b3EYZOhtCApXq7v w8i6vIw5HxMS5uWWX4H/ov3CuLHji28jIBDQKT4gCdIbAIKpCqPoCzKHTI1iiOpPRLpj cRxP9SSccmQB/LAdpN2v1MkZzm7rfz3ewur6q37hD6a9QW0XrnhAXNV0lCfuXmsSdAlJ jxWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=CdPv34/EbvMzWTAgZKO9W4amoj92OWWr5uaxYjRMD2U=; b=ZMPsIEVaZNN/RKzahMlpREZ0e+/+pc6pKS30HkRwgn9n6j5pDzni1AOv0im/WQcJy0 ReOMNuaEoqvDdiZhV5nqrfOWinmznAeJVKCpHlo2lCPEf1N1FJJ22+vlcRbTVThLuL/+ CyjWSz8XftlQ249d24SfHT6fHTD/YAFrBZHoE//GAvODaSVjMTSuSZ0GVXABRvG3suw8 HllKYtCg39yfsI2qybxk2blp5ibJkHy2DejsJI507iPM6EIvWmJyaRimi2y7LpJMPY0A CpMaK7qvxV22s42KkGua2pndubvA7YLFZeinYT1mm0q/Jxk2SAcLeSiPuxZ7aIuywpW7 OdwQ== X-Gm-Message-State: AIVw11042Mn4hrH/kvqqBEzLeaDNvQNrXMLVLebwY+3tl1sf944eBDTf NwcQgdKRtk+55QqA X-Received: by 10.28.71.203 with SMTP id m72mr3942456wmi.97.1501676954579; Wed, 02 Aug 2017 05:29:14 -0700 (PDT) Received: from merlot.mazyland.net (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.googlemail.com with ESMTPSA id p20sm3740473wmg.10.2017.08.02.05.29.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Aug 2017 05:29:12 -0700 (PDT) From: Milan Broz To: linux-block@vger.kernel.org Cc: hch@lst.de, axboe@kernel.dk, mpatocka@redhat.com, dm-devel@redhat.com, Milan Broz Subject: [RFC PATCH] bio-integrity: Fix regression if profile verify_fn is NULL Date: Wed, 2 Aug 2017 14:27:50 +0200 Message-Id: <20170802122750.12216-1-gmazyland@gmail.com> X-Mailer: git-send-email 2.13.3 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In dm-integrity target we register integrity profile that have both generate_fn and verify_fn callbacks set to NULL. This is used if dm-integrity is stacked under a dm-crypt device for authenticated encryption (integrity payload contains authentication tag and IV seed). In this case the verification is done through own crypto API processing inside dm-crypt; integrity profile is only holder of these data. (And memory is owned by dm-crypt as well.) After the commit (and previous changes) Commit 7c20f11680a441df09de7235206f70115fbf6290 Author: Christoph Hellwig Date: Mon Jul 3 16:58:43 2017 -0600 bio-integrity: stop abusing bi_end_io we get this crash: : BUG: unable to handle kernel NULL pointer dereference at (null) : IP: (null) : *pde = 00000000 ... : : Workqueue: kintegrityd bio_integrity_verify_fn : task: f48ae180 task.stack: f4b5c000 : EIP: (null) : EFLAGS: 00210286 CPU: 0 : EAX: f4b5debc EBX: 00001000 ECX: 00000001 EDX: 00000000 : ESI: 00001000 EDI: ed25f000 EBP: f4b5dee8 ESP: f4b5dea4 : DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068 : CR0: 80050033 CR2: 00000000 CR3: 32823000 CR4: 001406d0 : Call Trace: : ? bio_integrity_process+0xe3/0x1e0 : bio_integrity_verify_fn+0xea/0x150 : process_one_work+0x1c7/0x5c0 : worker_thread+0x39/0x380 : kthread+0xd6/0x110 : ? process_one_work+0x5c0/0x5c0 : ? kthread_worker_fn+0x100/0x100 : ? kthread_worker_fn+0x100/0x100 : ret_from_fork+0x19/0x24 : Code: Bad EIP value. : EIP: (null) SS:ESP: 0068:f4b5dea4 : CR2: 0000000000000000 Patch just skip the whole verify workqueue if verify_fn is set to NULL. Signed-off-by: Milan Broz --- block/bio-integrity.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 83e92beb3c9f..b9d1580bfc13 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -387,7 +387,9 @@ static void bio_integrity_verify_fn(struct work_struct *work) */ bool __bio_integrity_endio(struct bio *bio) { - if (bio_op(bio) == REQ_OP_READ && !bio->bi_status) { + struct blk_integrity *bi = bdev_get_integrity(bio->bi_bdev); + + if (bi->profile->verify_fn && bio_op(bio) == REQ_OP_READ && !bio->bi_status) { struct bio_integrity_payload *bip = bio_integrity(bio); INIT_WORK(&bip->bip_work, bio_integrity_verify_fn);