From patchwork Wed Nov 22 03:51:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wu Bo X-Patchwork-Id: 168091 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp1078209vqb; Tue, 21 Nov 2023 19:43:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IEtBraCDrBwbEDZJgvlRYFMGPFxGO0jl9Lt+1KmvjiTIfEk8mO4gF2iask9Zpj+y7/ziCfN X-Received: by 2002:a0d:d705:0:b0:5a9:27c8:edbc with SMTP id z5-20020a0dd705000000b005a927c8edbcmr1071750ywd.28.1700624622138; Tue, 21 Nov 2023 19:43:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700624622; cv=pass; d=google.com; s=arc-20160816; b=XhtaO5IFpsjFUXJIoYUKlGXWELA7VWOBcLYSZ3uO794k/GfTtLIzHgIExrRWEAwt4Z b1N4EuNLNGLycPLYNZqml5spu7tcanfADwm589Fj5MYS/YunesBQcw09srA5P+DH5v/q 9pPhNPOTJ/dEK3Qz93o4c6HF8+DMNcgGkFwwQV/kQcFxG/sleRFQAR+RiZC7Yo5mZqnO od3l22eAPZzLSVPl6tlApoLYSui7Y0bDvn+A/dSoYXEnM0LJHnRZtoEmCzEraMjTqzVd aA3uOWQH6+blOTMPbkv8wuzCsWbcP9vYtijbjUfGf2A70hz+8v2vZXzI8fFPZHmJRqa2 PSNQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=G/qf2T/5cEDHh8tPY410B8H5G0BBARESDNRqdWsycAY=; fh=nBUTbZf3DSpGeIlTiqg7JFsZjlnLkdwh0+5N33OIULc=; b=FfjS8Rcu8lB1iCyBnBWibqduYnnyEcDeakniORZLv+93AHrmACBNVj5fk9qLCjxPhy aqwMyUkx69+In3fHhcBjVKk00ilo/8NLyQHQd8VvOU6PI3vJErYP9AO26HnXneIUje3Q 154/NIPmc8qhoB8TKT86sEp9KaLdvkw9cfdRju3bT3LsEFbu8Gd5uKKWQ3l223sHCTJf irPx3FqPLtLrL+G9zGIuMCJZ7UkXHt5V5hWd4WayDCnqpPMsH0vRI4mFvIb3BVSanh0D Qg0U9ShFSC+MSo0YrfotD01hVgsbVbKVoPsDHGk1O/76IME48Caq9w+G/6+p380HVcNn LhGg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b="WGKr/J4M"; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id p10-20020a63fe0a000000b005b8f61fcba6si11238443pgh.452.2023.11.21.19.43.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 19:43:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b="WGKr/J4M"; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 62DAF802531F; Tue, 21 Nov 2023 19:43:33 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343617AbjKVDne (ORCPT + 99 others); Tue, 21 Nov 2023 22:43:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235035AbjKVDnd (ORCPT ); Tue, 21 Nov 2023 22:43:33 -0500 Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2096.outbound.protection.outlook.com [40.107.117.96]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5255918E; Tue, 21 Nov 2023 19:43:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UX+d1RNU01WVm2V5ZNhdpRaW6Hy5KTRH2eEiz20EhXSqHJ3Olmvf9hIUHkv8jN8ClvgKtAvgwG5jzeQIdsgr95IMboXSfxr8pepy6+iSVi35VLvXBRq8Dz1gt9MMk7BPC2ee7dQo7qFDrmkPaCkc2ldj6/7lO6N4ct/gAnTaq1+OyTpXiRWRklhsecjWlnWMRzVLdH2sQuddQbdPxA/vLmefgW3cWRYbfpUIw3IrrFX3Q/+QnCbiL+gzFP/mBDSjtWC9Hot4P5KOPFScD3coS9sAZdNDP4f4Y7pknjIG2K0NOviqWon5nXZybGniZw/TvclPCSXxMKzIbs2lgUf1dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=G/qf2T/5cEDHh8tPY410B8H5G0BBARESDNRqdWsycAY=; b=QHeJaVKW1ixqERtsuHHArAJv/ahJST8IFihIe3c9reFey6fjPhewQd+wJeh1dyk3gFBErWJ31uhKMKCe1X7IkT5m3CSFU/kYYNIFhILCReoT/3HWW/TYltEqn7CExM/csP2LIm0j84eHLfsd56P4g700FpgJrfRjvmYCtY6dM43hv7Q/S6nzg8hVMYoepQet2/8PFy9evQ4iVGwOaKsg0QXGu3jbGjxTcqubPQHuKSdulpfu/JmMQRBW9p/ivX63mJoPUt/cuc0M+rm7zCI6NtUTJHguch6nUyJ7yF72uSzx0VZgefJTOR/yQ9m+fecaeb5F6F7B5Gf3AGCMXMD7/g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=G/qf2T/5cEDHh8tPY410B8H5G0BBARESDNRqdWsycAY=; b=WGKr/J4MnmmWtX4u/Ojy1QjAj6JEnMu9fbo5E//7X+5V6C/CNdfzMuetRUMHZ6KasFp8T6fxvocDrnZfOQEXpopNd3/EK6QaW3eCailhcMQGRHguzSJpe/lUPjRAiJSFYvbDi4AZVxY/+rq0HSJUhMjPQG6xBfL+eGWd7fck1zN5r+keV1PbAPM0c7xEkBl4MVKjhVgT4RL6d+omK6db92xYFPQMhmM9ONpp+K6BGZzieILsaTJWxfh828i45De2pSRShRdeeLJ8hJmsu5jtMYoe5J3QXueyvS9YA8pKWta+elHBHwzyCPZ35jP7qqccbvDXrvWIpYine3IMnZkrHQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from PS2PR06MB3509.apcprd06.prod.outlook.com (2603:1096:300:67::17) by KL1PR0601MB3891.apcprd06.prod.outlook.com (2603:1096:820:2a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.18; Wed, 22 Nov 2023 03:43:24 +0000 Received: from PS2PR06MB3509.apcprd06.prod.outlook.com ([fe80::863b:f0a1:3066:24d]) by PS2PR06MB3509.apcprd06.prod.outlook.com ([fe80::863b:f0a1:3066:24d%7]) with mapi id 15.20.7025.017; Wed, 22 Nov 2023 03:43:24 +0000 From: Wu Bo To: Alasdair Kergon , Mike Snitzer , Mikulas Patocka Cc: dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org, Wu Bo , Eric Biggers , Wu Bo , stable@vger.kernel.org Subject: [PATCH v2 1/2] dm verity: init fec io before cleaning it Date: Tue, 21 Nov 2023 20:51:49 -0700 Message-Id: <4257e74602bd0ea192011eaefdbf8a2205382b56.1700623691.git.bo.wu@vivo.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-ClientProxiedBy: SG2P153CA0002.APCP153.PROD.OUTLOOK.COM (2603:1096::12) To PS2PR06MB3509.apcprd06.prod.outlook.com (2603:1096:300:67::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PS2PR06MB3509:EE_|KL1PR0601MB3891:EE_ X-MS-Office365-Filtering-Correlation-Id: 7f1e050b-9880-40ee-06cc-08dbeb0d2e2b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: L3JaM5Xz4X8VnTQOCoUPQ03LdaS8/sabCPE5FVh89FIB2hJz+3hRzD5ATBXjK7nlFEJ0tOVxElqFYZ16qClYKV4NclL9n+93md8hpAuE082QwJ8oaFesrqPgcz7AxkUTFOgCPohbenlCOBEjZ7fjobw6s4X1yul8bvL0sKQ1uqVJrFFw22twBErxeQNx3NEyfmKBIshzVTIctfgqEbWKizO7uVsloTVJEVS8Dj6SRVKcVQQRlCD5BeiMGDYToFbX+02DdM2oFR1lQhSdDakXY/REAhx1czsPN6SRCVlbLKWJi7kjtgA2g5/VYjVL9tx5VhM62optKRHmqy8zbaBewwmjVuUYGRV5zjG+nh05WIXyWZ7sa+iBcqn6QpZff6k7hLuImraPvCKSVitjpiWcGsG9d/nopNBx0tcWQMlZgPm56HJNq6CqgcDEFuoZ5dXYrTRDpc4dLHpxrjT1SKbhXulEPf0UBeIqTIeDiWRwBBLfPar1evGEtivQ7nn0U9RfhZP29Hql+YrXT4UBkZZqT1qaADSFTR6B+ck6MWJ4FS8v6hUO0/bFCDIQbhygxV6HZps4wA8qMboccKkxGT5ODY4VGZx89VXS1qfE6WR/LQqOfVgUK5YlJkCgQRCWuHVs X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PS2PR06MB3509.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(366004)(396003)(346002)(376002)(136003)(230922051799003)(451199024)(64100799003)(186009)(1800799012)(41300700001)(38100700002)(5660300002)(2906002)(86362001)(6666004)(38350700005)(52116002)(6506007)(6512007)(36756003)(478600001)(6486002)(83380400001)(2616005)(26005)(54906003)(316002)(66556008)(110136005)(66946007)(4326008)(66476007)(8676002)(8936002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dUQx9MJIDtkTT29G+1fKJVcSkNBf524s8v7niimZAJ1TKxrZ0ShllsknesvGxvOmKuV+fknORh3u77/G2XnDyaalBgo6h+bIOq0c9w+FZ1FjWdvny4gQzMvAqTVI7nENz2J5gvdbMS++20igocf4aD2II7NQURLBtbQrWwexNiaYiDzoeG+DDeopENTaO+qHki7V2vSbf4yb+khuWOnLRYNUqx2aePursGqa3qM8CcBLVU5N8ZWvmFJTiyegiC/0hQMLb9r4r69XYXKHnfS1/GQMUhsgGpXG5CJjIuF805271XfwpfRAQLobm5B++b0vEKHd3Vo3LO8QOEne1hfQbw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R2jl6L3ou65jngMf/JwDIutvwZssVFST28qmS+sS2nZomK/U8nHNbRkC+jbeB6b5D02Ng41IMvjw2Tf6bG+KM2iExjWPDLngxQdYhf3wQtLLcuV0m31FKNKlMtJTJsNyux/JmhF+f9MwgoSGB8s4rMzDspqk22xvL82fhxpIPiWLkRO X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7f1e050b-9880-40ee-06cc-08dbeb0d2e2b X-MS-Exchange-CrossTenant-AuthSource: PS2PR06MB3509.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Nov 2023 03:43:24.6514 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Mls7Y7bMWyAcYBDja0x9T0j1v2k0BwowSnE7Tg8Cqhr1uYtCx1HvZkTV/7vk3ZAV0AZQhclUPyUYI6SxSULQtg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR0601MB3891 X-Spam-Status: No, score=-0.9 required=5.0 tests=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 groat.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 (groat.vger.email [0.0.0.0]); Tue, 21 Nov 2023 19:43:33 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783234164216402699 X-GMAIL-MSGID: 1783234164216402699 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 Reviewed-by: Mikulas Patocka --- 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);