Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4741830rdh; Wed, 29 Nov 2023 09:21:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IHcD0zGeLpOXjW+riW866UkFq/mKcExy9EaZ+JEbBXsNiQNU+3Km5d2zvxg/Yj7DGHnzUi7 X-Received: by 2002:a05:6808:298f:b0:3ae:1351:d0f with SMTP id ex15-20020a056808298f00b003ae13510d0fmr18596700oib.22.1701278464762; Wed, 29 Nov 2023 09:21:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701278464; cv=none; d=google.com; s=arc-20160816; b=RSb7WweCRQda2mJcjDg3zkW6ZRep3EJJWhg4OLdC54uXYDy3qyLgqc5Qgq+DrG7jOc VUZKjcUqrZO2uUfyZmOWmemkJSzDAolp8Zbrghh7pt3cCQC+QiDoy7WdejL7f5IxgAxq Z7v4X+c9Ed0Zb3JsTYLMbJaMhJtRBLhVGUlDMllGU9X3JamVHUqAHaXUVW8K8LfV3Grj bXfRjwIfGshbiWa+G5VygbMz/Ahm/ktXAGBUDmsh+lvI+uupjkrW+xKwrOpGN0I8vnb6 8ZCqweKAtBIfPuzcxNoWdjU+kHeMohPGLEohwD/VOzfpPYOaYF6rqwHL1m9dgU4jSChx yhSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=fdZcz1CbfySNC/voTyNm3HwHoiZ6xk0K2b5NJeG5dMA=; fh=7t+4mRH+NyF2et0cD026NmsXRHD4D7Uznw5kmchM9kw=; b=s4ygEHixtLu2pZirBlY5P44rWcvcZfJKwaNUrKnWxmyIcbfqD/QUzmK7Vc7GzKrAzS xOLcPf/TMiScxIMziHKKVlMU+gZ+j6h5hChkavqyXIt4juhzBVrOhFvBTCx0mZ8gDMHa 2qvzjgtmbmU+aKTj8UMFs4ARPPC7/+HHpBmMoD6ArnZu1PrU9+3eCiYwAY9nNcFbeIl0 M1cgMP+RhIyyJGW21ycIzDDYEx0s7C5UItFlklq6R2/oKSWWTYHDWpilTq0kWcyP0Ymm pY7yvxVoeK655J2afIdGWBbPOzJEyvBVT3utCZTfcU+ZoeAMdd18W3mWTc6v1axnvDbg m4hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XsLihWRV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id s66-20020a635e45000000b005b930e0b604si15051265pgb.549.2023.11.29.09.21.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 09:21:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XsLihWRV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 96D448034A5E; Wed, 29 Nov 2023 09:21:01 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230103AbjK2RUr (ORCPT + 99 others); Wed, 29 Nov 2023 12:20:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229799AbjK2RUp (ORCPT ); Wed, 29 Nov 2023 12:20:45 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 191C6BE for ; Wed, 29 Nov 2023 09:20:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701278451; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=fdZcz1CbfySNC/voTyNm3HwHoiZ6xk0K2b5NJeG5dMA=; b=XsLihWRVyUjQO24AGeBnp7TF9sn6d2hcBtuXza0ITxmXxFJa8fuKEq+yAznRJ+9vYn6+nF dHAt6h5AyPwzZrrNGtLtkqmWTg26ln7vWBCEnRAsarzk/H2JDZ0xAxEWUhW5LFAwg+voZU 3X3MfhHccCJxmV5l0aF5nMAZNTM/2Tk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-498-D6fCWJHpNYaP3WRafceDHA-1; Wed, 29 Nov 2023 12:20:47 -0500 X-MC-Unique: D6fCWJHpNYaP3WRafceDHA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 36BA08556F5; Wed, 29 Nov 2023 17:20:47 +0000 (UTC) Received: from file1-rdu.file-001.prod.rdu2.dc.redhat.com (unknown [10.11.5.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0EF57492BEF; Wed, 29 Nov 2023 17:20:47 +0000 (UTC) Received: by file1-rdu.file-001.prod.rdu2.dc.redhat.com (Postfix, from userid 12668) id F055830C1A8C; Wed, 29 Nov 2023 17:20:46 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by file1-rdu.file-001.prod.rdu2.dc.redhat.com (Postfix) with ESMTP id EBCA23FB76; Wed, 29 Nov 2023 18:20:46 +0100 (CET) Date: Wed, 29 Nov 2023 18:20:46 +0100 (CET) From: Mikulas Patocka To: Wu Bo cc: Alasdair Kergon , Mike Snitzer , dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org, Wu Bo , Eric Biggers , stable@vger.kernel.org Subject: Re: [PATCH v2 1/2] dm verity: init fec io before cleaning it In-Reply-To: <4257e74602bd0ea192011eaefdbf8a2205382b56.1700623691.git.bo.wu@vivo.com> Message-ID: <64cbcac5-6ad-945d-32e9-87497c3615a6@redhat.com> References: <4257e74602bd0ea192011eaefdbf8a2205382b56.1700623691.git.bo.wu@vivo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 29 Nov 2023 09:21:01 -0800 (PST) On Tue, 21 Nov 2023, Wu Bo wrote: > If BIO error, it may goto verity_finish_io() before > verity_fec_init_io(). Therefor, the fec_io->rs is not initialized and > may crash when doing memory freeing in verity_fec_finish_io(). > > Crash call stack: > die+0x90/0x2b8 > __do_kernel_fault+0x260/0x298 > do_bad_area+0x2c/0xdc > do_translation_fault+0x3c/0x54 > do_mem_abort+0x54/0x118 > el1_abort+0x38/0x5c > el1h_64_sync_handler+0x50/0x90 > el1h_64_sync+0x64/0x6c > free_rs+0x18/0xac > fec_rs_free+0x10/0x24 > mempool_free+0x58/0x148 > verity_fec_finish_io+0x4c/0xb0 > verity_end_io+0xb8/0x150 > > Cc: stable@vger.kernel.org # v6.0+ > Fixes: 5721d4e5a9cd ("dm verity: Add optional "try_verify_in_tasklet" feature") > Signed-off-by: Wu Bo > --- > drivers/md/dm-verity-target.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c > index e115fcfe723c..beec14b6b044 100644 > --- a/drivers/md/dm-verity-target.c > +++ b/drivers/md/dm-verity-target.c > @@ -642,7 +642,6 @@ static void verity_work(struct work_struct *w) > > io->in_tasklet = false; > > - verity_fec_init_io(io); > verity_finish_io(io, errno_to_blk_status(verity_verify_io(io))); > } > > @@ -792,6 +791,8 @@ static int verity_map(struct dm_target *ti, struct bio *bio) > bio->bi_private = io; > io->iter = bio->bi_iter; > > + verity_fec_init_io(io); > + > verity_submit_prefetch(v, io); > > submit_bio_noacct(bio); > -- > 2.25.1 Reviewed-by: Mikulas Patocka