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: 9876707 X-Patchwork-Delegate: snitzer@redhat.com 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 1827E602BC for ; Wed, 2 Aug 2017 12:30:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0CF5828779 for ; Wed, 2 Aug 2017 12:30:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 01D372877D; Wed, 2 Aug 2017 12:30:25 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AB5E72877C for ; Wed, 2 Aug 2017 12:30:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4D43E883C6; Wed, 2 Aug 2017 12:30:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4D43E883C6 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4D43E883C6 Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VftPKGsB" Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 65E5969AD3; Wed, 2 Aug 2017 12:30:21 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 640EA1803B22; Wed, 2 Aug 2017 12:30:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v72CTJwt030405 for ; Wed, 2 Aug 2017 08:29:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id B126B729D1; Wed, 2 Aug 2017 12:29:19 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A41BD74446; Wed, 2 Aug 2017 12:29:17 +0000 (UTC) Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E85B33DE40; Wed, 2 Aug 2017 12:29:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E85B33DE40 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=gmazyland@gmail.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E85B33DE40 Received: by mail-wm0-f67.google.com with SMTP id q189so7014160wmd.0; 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=mJAhb6aSG4dP3P3WiAHyIeKIJLip9Ur8oHfEztYr6aNbGvpGVRf5LZaALg1VTdz0b8 vYBv2G0sM8oO2RowdYPV0UTMMK91FiIOvXV6sg6Jj1Zg+baPn40YtQzisNG58EdLTrjE HKDh98ThzkKtOa8eAVdb9wzI7OVl2UUYfCQQYWUJ2rRNgTIeVIJ/TIFwzpcZIoPNqHWR GUmEryx/max7eXuUBSlJhvWu+nJ2jywgN6Aop7J6s4fK+PAm0uJ5mDeZAY1feSbM0qC9 E2i8xW4qpMmllE+zT1G9ClSjIQDPztS3BFGBSc1JWJzVyGU7+4sybVUxVxDfysgr0JRH og8g== X-Gm-Message-State: AIVw112wH89mUrDyDvBx/Sqi6cNEMpePasWMh3odqxl7Q3q9DLqvlwe1 8OTNcje2QWhIT6YJ 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 Date: Wed, 2 Aug 2017 14:27:50 +0200 Message-Id: <20170802122750.12216-1-gmazyland@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 02 Aug 2017 12:29:16 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 02 Aug 2017 12:29:16 +0000 (UTC) for IP:'74.125.82.67' DOMAIN:'mail-wm0-f67.google.com' HELO:'mail-wm0-f67.google.com' FROM:'gmazyland@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.27 (DCC_REPUT_13_19, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_SPAM, SPF_PASS) 74.125.82.67 mail-wm0-f67.google.com 74.125.82.67 mail-wm0-f67.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: dm-devel@redhat.com Cc: axboe@kernel.dk, dm-devel@redhat.com, mpatocka@redhat.com, hch@lst.de, Milan Broz Subject: [dm-devel] [RFC PATCH] bio-integrity: Fix regression if profile verify_fn is NULL X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 02 Aug 2017 12:30:24 +0000 (UTC) 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);