Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp722095rdf; Tue, 21 Nov 2023 14:59:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IEJl1S017NYLEkptCsXy4JxJL7Bp00wTqCag25svwgM0isRMBW3ySMbx8O4iu/FQuBUnm6o X-Received: by 2002:a17:90a:195e:b0:283:2932:e912 with SMTP id 30-20020a17090a195e00b002832932e912mr729810pjh.28.1700607562009; Tue, 21 Nov 2023 14:59:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700607561; cv=none; d=google.com; s=arc-20160816; b=mlodxbLt41Z7wfVsrCn7GsLGqrswAJRzis2AU/+T6gDphlPxvabgj9ZtyqT76JLKYf 5W1ltaevqzGnq+GOjM7QyQcx5oqWEh92SV+0DsFSBKq/sGzT/xdjFr/qkjy8jzRWVTtt LcGpvRbqazdOnbt7m2Pjsw3Y/UoqGwFDJEHDgemEcYOVJeylX5DKYyxZ/Q1452IOu0nt OFIUpW379Gi9Q7omhOe4fSo6mPXdbx2szIxYveQ6V+NiktnsXYddJXEDl6Y+utiCvbD/ Akw5aHyVnvW/NWIb1aLJBMA/toRxaEhgdUPMmQsYFO7SNJp9ezxgtQ0YpGy8995gYMDK wcLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ir9ASqEEYL8F0Fsq6I2/SQQO4LVsCbwUFW+Ie4VA4Uk=; fh=O3efhQ8YRWF9SbJmSfBxu1sIGqKgzh1BE87bI7BiATg=; b=fumU5aJ3gplvYOzvM/Z0PuHYkmOHlVoNNWoPEXJk7fb5wry30XjYJIUmr/tgcNpoAi fxhvpyTN+UA+HA5D/vSFHz9YpD6JFdr8TqJha7w8YWRaGDtM3y43So/qonkHgD37e1TW uiLtjKRTlIXZ3Bl54NOrtej0HXmf+MyBT99QFCXR/AExDlYHCBJlkjzopdMWeEx3IGr8 zm4zcW+8r0PW6d4IAg5E9ft0SdWd2EOiPKbRZjiBwhj5OsmqNUiSmAPyq24lQPhat7P8 +5OpYHRdv6mzSRpeU9c9aizsZ9GueR0uvXOM6YQikOMddpa2yDBDTBVMAKS9W1en5M08 Cn/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=d0N0ke0u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id h6-20020a170902704600b001ce5b6e97b6si10761299plt.162.2023.11.21.14.59.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 14:59:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=d0N0ke0u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 4385A804E732; Tue, 21 Nov 2023 14:57:52 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234908AbjKUW5Z (ORCPT + 99 others); Tue, 21 Nov 2023 17:57:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234861AbjKUW5P (ORCPT ); Tue, 21 Nov 2023 17:57:15 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B68F8D5D for ; Tue, 21 Nov 2023 14:57:04 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD78FC433CA; Tue, 21 Nov 2023 22:57:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700607424; bh=xo0rZfEH6XOgDU8QdntjZwVzF3RfcOmi68IeS+5BMbI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=d0N0ke0u8nUKNqiGzOQVsNoUAQgSoLko6yZo8nn7CfW9Ie6BVukB6bX1ompRMlmE0 1TkBNpBJeiJ9MIW+71vtUoP9c62rm9Ecr0o4Sq1umvYuiPaR6YE7fKsE7QGWsLfuGB t8M7ObSFtgwGknfFtn97LRq1uN1MV7ZKLB3sX5Ks6ilZEcTnWOeBbpOSnXQrzOEEA8 gDs36YtK8AN/sF8VMTKBenqQlyrLvLmiT2D9Bik4vg25eUUivRUBUOcL5Fzt5Tuhes i/MtnhgzGE/bgcb9yOvEcrX0l0PUIX9azTL+9nw9ZeaVxcsrRbER9HQmBIBd8Er2aL jO2/rDb8+AHrQ== Date: Tue, 21 Nov 2023 14:57:02 -0800 From: Eric Biggers To: Wu Bo Cc: Alasdair Kergon , Mike Snitzer , Mikulas Patocka , dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org, Wu Bo Subject: Re: [PATCH 1/2] dm verity: init fec io before cleaning it Message-ID: <20231121225702.GA2172@sol.localdomain> References: <419e7aa58f67d90020512892f7652623e8c9f059.1700555778.git.bo.wu@vivo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <419e7aa58f67d90020512892f7652623e8c9f059.1700555778.git.bo.wu@vivo.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Tue, 21 Nov 2023 14:57:52 -0800 (PST) On Tue, Nov 21, 2023 at 01:55:28AM -0700, 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 > > Signed-off-by: Wu Bo What commit introduced this bug? It looks like it was commit 5721d4e5a9cd ("dm verity: Add optional "try_verify_in_tasklet" feature"), which moved the call to verity_fec_init_io() from verity_map() to verity_work(). Do you agree? Should the call to verity_fec_init_io() perhaps be moved back to verity_map(), instead of putting it in verity_end_io()? Or maybe another call to verity_fec_init_io() should be added only just before the call to verity_finish_io() in verity_end_io(), given that it's not needed in the tasklet case? In any case, please also add a Fixes tag with the appropriate commit, as well as a "Cc stable" tag. - Eric