From patchwork Tue Nov 21 08:55:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wu Bo X-Patchwork-Id: 167557 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp482932vqb; Tue, 21 Nov 2023 00:48:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IFFjTd4zExkvdaDIErlfD1oVftlDxlEoGgbyiUBLGcez7ZzeElAx75sD9KK3wV7Ty6mMk8n X-Received: by 2002:a17:902:d4c4:b0:1cc:5920:1d2a with SMTP id o4-20020a170902d4c400b001cc59201d2amr9815853plg.13.1700556512509; Tue, 21 Nov 2023 00:48:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700556512; cv=pass; d=google.com; s=arc-20160816; b=01sTaWc/Mt+EmjWDq+OvnU9+6yFWOEfHgOAssvV8r2tL5TKUYvBhnvpkq6V268fHCb g82uzjuIvUld944yQp5+K9lSOoHl108KUG3Zefn3LEbA0TdJrCwxsLVVZO2mARvTzmLr KfPSrXSb+4FpZDHcijytNFy+gOEzLScj1lvsbhUZ3/pe6uSAnDpe2pTLRqZ+Oupfw3Rk NYsARwI/ffI10IJCULe3Ff81DrYQQhQYosmSb7enPlztLYcDE3/x6mkR8jBHgxjrow1d DbBPJ+xTteoyRFSfLMDSBFCHVat7IZlHnOa/uZna8FfL07NHm79ExcqA8mKZ5raweX4K pcKA== 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=zOZj09/M3VElLeovXt9H4i98jVpN1nF8xPItEn3ROYM=; fh=J30sqVfw9OjtpxbNumwD0tVG0bXXvvrP5TOHSwVy/Ns=; b=NN2nwwLd5sL4Nw9cOOxo7Jl5ZaNS+pfZjBF1XekhzIhc3KJy8u9Xrwzw0wqfmF3vgz Ni9i1nU+rtnoMR1Tq9tdiiq7zVgJcoo8LByADCYEg+Bub+8P1KMe3AYhcJLiNC325vdt UwftKFzfqVRR7JsQUUYkecu9Gp8FyV1MC0ivC11fRJby0ApeGgVYDl0t2NF2qi9TgNRK UWC0v7J5W3PavxXG4OtDBNnjYEoSRBWt1PbR1vaHvc5aOUjLc1yG2GyvRoMrqPeoxxsc MYobaYppxDv7HudsJ2WYZ4dtqRgLj/maHtn3PaT8MAl9QpQ05ZRT685m/jhWIrAJsFZ6 OzHQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=K08EHM4E; 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:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id f9-20020a170902ce8900b001cf652d73fdsi3048891plg.284.2023.11.21.00.48.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 00:48:32 -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=@vivo.com header.s=selector2 header.b=K08EHM4E; 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:7 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 snail.vger.email (Postfix) with ESMTP id E0DD480E06A7; Tue, 21 Nov 2023 00:47:13 -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 S230435AbjKUIrB (ORCPT + 99 others); Tue, 21 Nov 2023 03:47:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230385AbjKUIq4 (ORCPT ); Tue, 21 Nov 2023 03:46:56 -0500 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2118.outbound.protection.outlook.com [40.107.215.118]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5799210F for ; Tue, 21 Nov 2023 00:46:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mPQU4m/AS87lg6iWtsGwCzR46n90I/w8PlBOnzfIYDUupEFhorrhtpLYpFoXq7wuS6AiQcRYoxnli7+5fuirs++GC7wzaIEtDWGMNdIg7lWqTHtAG0MPAh9zXMr539BE9gk5KUSVOrPAqCz8EMHON+V5CCXQVDcdt7r5AXE+4oJkmacxSJyUQqT9zoaOlMDbDMGR+aTF5XsxAiyOLbakGNigw63CTMUEU9R5joAbzmW7T206V+1/uATql+F/TvL2lcpNCWkgSmvCBkU2k3KBR+dr69tQMbFbGujNjM5W3RaELSLUfz6QI2IIpr4JnAYJnZ3ywpQNznXOUBr/WqkTCw== 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=zOZj09/M3VElLeovXt9H4i98jVpN1nF8xPItEn3ROYM=; b=WpyIlTPpph/jHHfuF920Gk/WpABY9F+IdvjPOgCrlZtEjX5u+lx+EtEJswJC2cwxo54gVHd1UEZ3tUstYYyOXfYlkfgNxWKclA5kmy7QOCfyjLMIVdLehZHL2k1pPt+D8R3mVJ0PleGF2sQlW8o74DLsuYgO13irrzhvZgr0jieANdAwGK9+K8q7UiHnS/4I/yefSSte4WEFc5m4MpzPlWW4JVnYG3WYuwxSPwsqkhQV4VcEit4kX0YiF9pYsjuKiPH7Cy28e9UKUeXKZsUeu9MEOo9m/+NncnwTjZ/uI5vb6hrMCTZ0IYMyCumMKHIrpNdMerjW2JRVHSJtHtM2hA== 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=zOZj09/M3VElLeovXt9H4i98jVpN1nF8xPItEn3ROYM=; b=K08EHM4EAlZgF30fhPjlwekJlR1DGpM3H1kZEbDG1SUp8usIBvS2iRlDAlg1Sh3cP9fQEETI6JfA0Obyo6wO3a30apMIPwgCZJiv/fjLgchqaiXOCs/iCFF7WOXdvgUq0FtYHhP6vhj66Urtu01vJZgqbKnVKcrHWNePJVHjccvn12KrksmqKHdOSKf1bHx6VKQiUWuJ6AlieYwHIGBx3883JmTL2DqXqg4kDfIqFW408VKj32oyz+6ufLpcLxlbpMkvQwP8mNYHKGNigxAEvJBajqvsyvWRZAli8705c6gom1YC1dK/Im1+XGvyE0fPu7k8PhQ2gdRm3Mo7LKpcYA== 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 TYZPR06MB4127.apcprd06.prod.outlook.com (2603:1096:400:6::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.28; Tue, 21 Nov 2023 08:46:49 +0000 Received: from PS2PR06MB3509.apcprd06.prod.outlook.com ([fe80::863b:f0a1:3066:24d]) by PS2PR06MB3509.apcprd06.prod.outlook.com ([fe80::863b:f0a1:3066:24d%6]) with mapi id 15.20.7002.027; Tue, 21 Nov 2023 08:46:49 +0000 From: Wu Bo To: Alasdair Kergon , Mike Snitzer , Mikulas Patocka Cc: dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org, Wu Bo , Wu Bo Subject: [PATCH 1/2] dm verity: init fec io before cleaning it Date: Tue, 21 Nov 2023 01:55:28 -0700 Message-Id: <419e7aa58f67d90020512892f7652623e8c9f059.1700555778.git.bo.wu@vivo.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-ClientProxiedBy: SI1PR02CA0047.apcprd02.prod.outlook.com (2603:1096:4:1f5::15) To PS2PR06MB3509.apcprd06.prod.outlook.com (2603:1096:300:67::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PS2PR06MB3509:EE_|TYZPR06MB4127:EE_ X-MS-Office365-Filtering-Correlation-Id: 7739ea1a-2ffe-4979-ca50-08dbea6e6604 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: c2Dc2uRDVOb8o3V/CCaEvHWup+z+f+KM2YIiVfb2b/D+KaBezp5wKFjqrYSvdA+vHZp8Bdrg3Nrv09g+lmYvK2Q5kSUFE+hHdWPNsnz3F3/ucgqbYsisfJcvA0Q+wEm4vrnKEnvfWnaEIc9vrhQXlEwpf1ISAP68S2e2kp26H+29V9/B47OsANndDHHgp4UGfWepkvSEWNSi9eiYXTJAYbIKTFjb/SS+qC4m+KXj/FU1mR+CwQSR4fVaUmrTZz6/mw2JY/3ifzJD7hSjxDkfwvg0nTWuMiVHoMQhnMOJLd3W37ZaowbD158S3yw211D55PdKDpVfDgIW0gXn438cCauqnh05miPPYnO4oWZ9IGrRe4x1cKQvXKWSHWavdRK+uwIH5zAl0lXqhHna0xrOmI4wJojoBKOAQJ8FPFveRfUiuZpj7MlZ9ZeNsGRjbo7HgdFBxrYpZgKQmMhS99E7cUy437YdgoJ8Xhv6zI9elc2KZq6uE/gcE6BWhisX7Nx0P83b/MJ2dYdTdbKPvWe5AVhksC0eSUZrcnr4XkN1SpJyeJHd5HRbSee/nMWVujdu6V6Xt3Z2pLClsE4PhmLLFs7sL94Pjw/h3ecS/MN8tMQIIGwIxuorOXn9dOrfMp6R 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)(346002)(376002)(39850400004)(136003)(396003)(366004)(230922051799003)(451199024)(64100799003)(186009)(1800799012)(316002)(110136005)(54906003)(66946007)(66476007)(66556008)(36756003)(52116002)(6512007)(6666004)(6506007)(2616005)(26005)(107886003)(6486002)(478600001)(38350700005)(38100700002)(83380400001)(86362001)(2906002)(5660300002)(8936002)(4326008)(8676002)(41300700001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LGRtE2X/rNXFYOOsS5YubsX3M33L89w7KtXvMR74dzL0nUbWKN2GnKqX4jNlwgBFngNSJEzVDsvNL6Jn/r/4fc0u1zCQ8sKGpiJOgWNgd83Pm472+6NksyYdYlmb1/YuOVY+Qutv5mUNDmvVZrt6YmIEBMdKcku110QwT6jFbkYdniYTH95gkkW7RNAxlcYpWYJejlnB5K4Ofu3KmBjpCWCfidAayzmoZW+t75jzDkQEG00DI4s10mxFaY/tC8aYX4AXJXkxmNxPa5p3SAIftR6pcnJGY1LnBTdurq6BjFymcaa/Zr6UrxosjspeR6r2fm4ihKt/i61sD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10xGTjmS9PKEYgmrn8yNZqZAhvlmdha9FCLVuInDokrFeYeh++RCv7SQF7FeYIT45+ZAkbb7WcsJv7HQL4Qpw3WWf592rVnfZ6E2oPETseyJdqXZGftKvApFe+jDEyvDO8aFg58+QeKJm6BJvtgw3/nqbYPJxOSGgXa1lq4tPWLZVNmY2XUglo X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7739ea1a-2ffe-4979-ca50-08dbea6e6604 X-MS-Exchange-CrossTenant-AuthSource: PS2PR06MB3509.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 08:46:48.9329 (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: 21kDYlBMzv3tj0+xmxqKhAppm5qU9rdOoJTApDKOi+Ywub/FNR+nsl1X6yW02DuGNiB4PmNTg1mAru9zztDPJQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR06MB4127 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 00:47:14 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783162745898750492 X-GMAIL-MSGID: 1783162745898750492 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 --- drivers/md/dm-verity-target.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c index e115fcfe723c..42b2483eb08c 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))); } @@ -667,6 +666,7 @@ static void verity_end_io(struct bio *bio) { struct dm_verity_io *io = bio->bi_private; + verity_fec_init_io(io); if (bio->bi_status && (!verity_fec_is_enabled(io->v) || verity_is_system_shutting_down())) { verity_finish_io(io, bio->bi_status);