From patchwork Mon May 24 10:12:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12275789 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C76D6C04FF3 for ; Mon, 24 May 2021 10:14:23 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2CD29610FA for ; Mon, 24 May 2021 10:14:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2CD29610FA Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:40052 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ll7bK-0000qI-5J for qemu-devel@archiver.kernel.org; Mon, 24 May 2021 06:14:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40558) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ll7aJ-0007Ea-J5; Mon, 24 May 2021 06:13:19 -0400 Received: from mail-am6eur05on2116.outbound.protection.outlook.com ([40.107.22.116]:27488 helo=EUR05-AM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ll7aG-0001TQ-PD; Mon, 24 May 2021 06:13:19 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SLTP9u0Qgtoakrt6I2lVZuzCKPibmHaPMDzDiYbz0VvxPRDlocXwX0IE3jBMl1mZGtag/McXd6gxczWOSc8zN2nactRqq7r9AGMKRTEz+66cO7j08KWz6dFuZ045VLlYMRVTe2mEc7U80I99Ia6PuIQOSmFxh8ySS+j4YEr3LOeNAcNbz2roQ+Zg6XEb/jg50b4zkaJE4ZRVl3DBkqqhPu/1pVtams/kS3MGfpclNBq0JPdsy8MMRH7vdnTx4fGFx9vd0mf0nC+EAiTE4NL/N0ZPAkXkjw3uY+Pbo7FGZnsSP7V2lBcog+AuZqtF8PN0krC8Rlo4anGQntJr/Zxplg== 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-SenderADCheck; bh=lrRcxNGDo3e80KjlboCQjyQxSfr9lqu56ZMhbQjd0xw=; b=a9TpPBa4mbxz3qiykVQ6q4S50aSQbBOzLiuz249oTENYzaFd+KXap1CEWVF8SvaTTUkcfOSzZoVhWmK9jd/v4uhQxO1OaGuPTgr3AwmGB9hP82GsMry4eOjOsqRugoik+IIb1ymf7V92wMg2+pYy6sYyKzlFxlFWzGWFQY8DUqkDOI28hKioFt6aZXXtIgmck4AXBjbBOliox9Mh3AVq0hvKeJyaGNQTdapCePX9mxeE/lGiTSlOIeUxwZsUq965NSICboOxNQBDrgN4+mb8+PQu0vJtEKBwnywh0tl7fA7j1FFoT9GcGhyYl1or7S4fOJswExY91iY6grVyejAwrA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lrRcxNGDo3e80KjlboCQjyQxSfr9lqu56ZMhbQjd0xw=; b=fbWTuvP8GeQMOy1w9RaZVX+bwFTB5UpKyVK3jxIRGqmfXOVJRX95Y+IX+40pxVM7L0ITmUvA0dTpJbVhcOOIpXQuGftHxlAHTa2F1sF68Yt6O80AMLpiuET7urCT1R4tfkgL9nqVgKjz5H8bvYNn8TtOyqQ7H2NLUDQGd3mwLDo= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM7PR08MB5446.eurprd08.prod.outlook.com (2603:10a6:20b:107::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.31; Mon, 24 May 2021 10:13:12 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133%8]) with mapi id 15.20.4150.027; Mon, 24 May 2021 10:13:12 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, mreitz@redhat.com, kwolf@redhat.com, berto@igalia.com, programmingkidx@gmail.com, Vladimir Sementsov-Ogievskiy Subject: [PATCH 1/2] block/vvfat: child_vvfat_qcow: add .get_parent_aio_context, fix crash Date: Mon, 24 May 2021 13:12:56 +0300 Message-Id: <20210524101257.119377-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210524101257.119377-1-vsementsov@virtuozzo.com> References: <20210524101257.119377-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.195] X-ClientProxiedBy: HE1PR05CA0186.eurprd05.prod.outlook.com (2603:10a6:3:f8::34) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.195) by HE1PR05CA0186.eurprd05.prod.outlook.com (2603:10a6:3:f8::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.23 via Frontend Transport; Mon, 24 May 2021 10:13:11 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fc096b63-1f43-4e58-9004-08d91e9c89d4 X-MS-TrafficTypeDiagnostic: AM7PR08MB5446: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:19; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eyioSCUmw4SOOSrQRjklz7T3AZMmS8BW8OpoSYyQCPKZ1ru3wR4ZRNt8jhgN8YLKuyzs8rzY/B413FDTK0OF4wplBU0tr6I1+97iVZpH6DqWq8S5gzplqRocy5mGqKSg5M+MShbqrmVhBplWoDF/w6vECGbWtivL1+vv3XhW8FGBrQ87faBA+91Za8sBvWI0KZLG21qg8WcovTnTJtNBatfShathKJGCH5iI723OMGjWwG0wPusNScBPZjq6QEBq+SAmZ9m0XBL16kQndXTFWKjygKSpbAr0BadKnhGP+38Xf7WNxvqOoZ9OHuvT4+b8ROuvuMvrC3phZfatjWjdPx5GgukP6PFKir8e2LwYNWTgpq8c9WQPTSeHBUYdCLU62vQkRxyFAMoDw3Gn3uM5EfhOACmGlqh1gCPMqgIlkiCSrI/RHTRNcncg/Y9KPDSQ60VP/uoaY3DPr63bPTXG6pfxP+KuG9avrEB9F/WwKyeIlLXL5XLkSeaE16TmGiAgyEuWRiYr8a1YZ1TcfqaB2YNmmFJKxk9MneIOizxL66kEYuPb7q07vBNFymRPUscDtA0s8QSS16qbPEBvI7dOEpHPgf0sL6dKOaZeIqUJYHsizm38vsiKa/pZ05iQ1mvV0nwZOk2Qq/WhgLpuBU4EJoOvEx5GSKMCNQm2H9Dmx6b3ScCDSfUdMEO0Ns1r0mEkB5Ojel1MrigzJRXs4ltT4A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(346002)(366004)(39840400004)(136003)(6506007)(66946007)(66556008)(6512007)(4326008)(6666004)(66476007)(52116002)(86362001)(6486002)(2616005)(107886003)(36756003)(5660300002)(2906002)(186003)(6916009)(956004)(316002)(38100700002)(38350700002)(478600001)(8936002)(1076003)(26005)(8676002)(16526019)(83380400001)(69590400013)(142923001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 8B/81IUAIVIUMhFBrebAbTxWM4gu/055g0HKZdeIBoKO1yQ2KsOJ9n8od7R6/TOdMiC1k3IM4I7ksOzKXz8s8tMgOddYPBVycfjgWJ24fckMolInMLyoGWpQk7JVNmxETNd6rkvHHuobc14Nct8QRCfc1h7mhFx8+UrSHjgCSe1X+2ANYgE7/ETqnhtJ8qS01ByNU+F+Pkadtse3oO93kBwvE7IyVxXNMM3nle1/9D6t7W21r7bhXlqVN067qBAxqIbmXhlYDxCQDJBvF5pPXHXdQ/ubVyWqyTpCIpKW6DWnCiNqhoDVyTCIHRpnw4OflWOYRqrIzXoNYoGXvlGoZ4ttwdJHViY5T1pW/q38txrfgHwRVQH3lNJQknqlMq72sEWeE1ig5hJ36yPXFPsh3Rq7AMd6egpPs+06UlLOTuOog+CixvboE3RvRvnD5GdjbzccHv8q8MPAOl4nqX71pLT2nDKU++Lu3RTBFwzw4U2a23UvAtYqS5K3xu4Q/9kmKhOQRT5P3r1qXbq1tU5Y2jWmqUamNZdKgdfONHv48dp2jCh5DA3P2C6V+hFl9eiwYOj9FgBjQZnpP9O4eknYoVcv/dS5jeYLvSFES6RiqHCj6GzUNaBs8Vy9HMV+xoJQD2yXFGFXMbl8Dl+97/Dm+iWQTMQQISlYubMtEB0sReLWA39w2kfQ4x+1MSs3X/0Ydzn3BAF1SmlgEJRYdtKRHBuxLPOq/rVfNiWtp7RNREKgQcsRnMnE+JKC/NHMxvfWYo9RK+1/RwQRRNHXUqIadEua+D8dSbeP6avCg9yOSXsRXOLSsGRIf79tT2QruHKbBPhKZX3fp9zskK7NkqXVrzOjaBfBpj9BGND971RZ08MIPJfnuZLflRS4lE31ACSsrZRi47jvTbpksu0oU/sJ3Cix1JGvrawHIF5aweeDWT5c3Xp8JVcscGy8hiMy1TqUICe9SokXb8dCJyrP+sLnX3b4NU9evxMY1TUlLFDZTNDVBSG1P/vYq1O2mFOE8Sw6WE/bxPL3oB49zDAZihD8KVbv5RzM6QIgCy+cwJIbClzT0+/1rBEy2s5qzG7W2LHRHrRE5OCddSPQxPlTVziO4VcT5VQxAHEUlZHi16QqsV9etcCIDhJfQ4MGlhSr2qii43YM3uhdyTjOHvoNe5UnlvwwR6ZhiGATu4/HrjtsD3n0APEXNbQnAWW2klulDG1wm7PKMCdy2R2pvDiZ5XUAeY9qa/0TTvbKwda9M8nwcmRgypezPuxWtIAsIXpCL037MWszko1cKyq8clI1JYZUf+bwzSk5lVtg+veJXF1zVPe9tf/xZ3RlZ/5OxOVKhVWH X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: fc096b63-1f43-4e58-9004-08d91e9c89d4 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2021 10:13:12.7478 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: iOFXwq1T3SWXrMK9fFItmlsS/xIGI3+UXODJJ7Gfk1Fim3eYgQCYWX+T6Bwy4XECE3gwj/JcTxyD2bGv7oj3NxS3S/Ud/ayKJENjR7BKywE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5446 Received-SPF: pass client-ip=40.107.22.116; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Commit 3ca1f3225727419ba573673b744edac10904276f "block: BdrvChildClass: add .get_parent_aio_context handler" introduced new handler and commit 228ca37e12f97788e05bd0c92f89b3e5e4019607 "block: drop ctx argument from bdrv_root_attach_child" made a generic use of it. But 3ca1f3225727419ba573673b744edac10904276f didn't update child_vvfat_qcow. Fix that. Before that fix the command ./build/qemu-system-x86_64 -usb -device usb-storage,drive=fat16 \ -drive file=fat:rw:fat-type=16:"",id=fat16,format=raw,if=none crashes: 1 bdrv_child_get_parent_aio_context (c=0x559d62426d20) at ../block.c:1440 2 bdrv_attach_child_common (child_bs=0x559d62468190, child_name=0x559d606f9e3d "write-target", child_class=0x559d60c58d20 , child_role=3, perm=3, shared_perm=4, opaque=0x559d62445690, child=0x7ffc74c2acc8, tran=0x559d6246ddd0, errp=0x7ffc74c2ae60) at ../block.c:2795 3 bdrv_attach_child_noperm (parent_bs=0x559d62445690, child_bs=0x559d62468190, child_name=0x559d606f9e3d "write-target", child_class=0x559d60c58d20 , child_role=3, child=0x7ffc74c2acc8, tran=0x559d6246ddd0, errp=0x7ffc74c2ae60) at ../block.c:2855 4 bdrv_attach_child (parent_bs=0x559d62445690, child_bs=0x559d62468190, child_name=0x559d606f9e3d "write-target", child_class=0x559d60c58d20 , child_role=3, errp=0x7ffc74c2ae60) at ../block.c:2953 5 bdrv_open_child (filename=0x559d62464b80 "/var/tmp/vl.h3TIS4", options=0x559d6246ec20, bdref_key=0x559d606f9e3d "write-target", parent=0x559d62445690, child_class=0x559d60c58d20 , child_role=3, allow_none=false, errp=0x7ffc74c2ae60) at ../block.c:3351 6 enable_write_target (bs=0x559d62445690, errp=0x7ffc74c2ae60) at ../block/vvfat.c:3176 7 vvfat_open (bs=0x559d62445690, options=0x559d6244adb0, flags=155650, errp=0x7ffc74c2ae60) at ../block/vvfat.c:1236 8 bdrv_open_driver (bs=0x559d62445690, drv=0x559d60d4f7e0 , node_name=0x0, options=0x559d6244adb0, open_flags=155650, errp=0x7ffc74c2af70) at ../block.c:1557 9 bdrv_open_common (bs=0x559d62445690, file=0x0, options=0x559d6244adb0, errp=0x7ffc74c2af70) at ... (gdb) fr 1 #1 0x0000559d603ea3bf in bdrv_child_get_parent_aio_context (c=0x559d62426d20) at ../block.c:1440 1440 return c->klass->get_parent_aio_context(c); (gdb) p c->klass $1 = (const BdrvChildClass *) 0x559d60c58d20 (gdb) p c->klass->get_parent_aio_context $2 = (AioContext *(*)(BdrvChild *)) 0x0 Fixes: 3ca1f3225727419ba573673b744edac10904276f Fixes: 228ca37e12f97788e05bd0c92f89b3e5e4019607 Reported-by: Programmingkid Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/block.h | 1 + block.c | 4 ++-- block/vvfat.c | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index 82185965ff..8e707a83b7 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -701,6 +701,7 @@ bool bdrv_child_can_set_aio_context(BdrvChild *c, AioContext *ctx, bool bdrv_can_set_aio_context(BlockDriverState *bs, AioContext *ctx, GSList **ignore, Error **errp); AioContext *bdrv_child_get_parent_aio_context(BdrvChild *c); +AioContext *child_of_bds_get_parent_aio_context(BdrvChild *c); int bdrv_probe_blocksizes(BlockDriverState *bs, BlockSizes *bsz); int bdrv_probe_geometry(BlockDriverState *bs, HDGeometry *geo); diff --git a/block.c b/block.c index 0dc97281dc..ef13076c4c 100644 --- a/block.c +++ b/block.c @@ -1412,7 +1412,7 @@ static int bdrv_child_cb_update_filename(BdrvChild *c, BlockDriverState *base, return 0; } -static AioContext *bdrv_child_cb_get_parent_aio_context(BdrvChild *c) +AioContext *child_of_bds_get_parent_aio_context(BdrvChild *c) { BlockDriverState *bs = c->opaque; @@ -1432,7 +1432,7 @@ const BdrvChildClass child_of_bds = { .can_set_aio_ctx = bdrv_child_cb_can_set_aio_ctx, .set_aio_ctx = bdrv_child_cb_set_aio_ctx, .update_filename = bdrv_child_cb_update_filename, - .get_parent_aio_context = bdrv_child_cb_get_parent_aio_context, + .get_parent_aio_context = child_of_bds_get_parent_aio_context, }; AioContext *bdrv_child_get_parent_aio_context(BdrvChild *c) diff --git a/block/vvfat.c b/block/vvfat.c index 54807f82ca..07232a7cfc 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -3130,6 +3130,7 @@ static void vvfat_qcow_options(BdrvChildRole role, bool parent_is_format, static const BdrvChildClass child_vvfat_qcow = { .parent_is_bds = true, .inherit_options = vvfat_qcow_options, + .get_parent_aio_context = child_of_bds_get_parent_aio_context, }; static int enable_write_target(BlockDriverState *bs, Error **errp) From patchwork Mon May 24 10:12:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12275791 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99A26C04FF3 for ; Mon, 24 May 2021 10:14:44 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 042C2610FA for ; Mon, 24 May 2021 10:14:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 042C2610FA Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:40792 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ll7bf-0001Ly-4n for qemu-devel@archiver.kernel.org; Mon, 24 May 2021 06:14:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40570) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ll7aL-0007Hg-Nm; Mon, 24 May 2021 06:13:21 -0400 Received: from mail-am6eur05on2116.outbound.protection.outlook.com ([40.107.22.116]:27488 helo=EUR05-AM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ll7aJ-0001TQ-Ub; Mon, 24 May 2021 06:13:21 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j5VDFxByMk/ZADvYJIJcMOpVGDVmi912pdtrPaMVD4frHRfXf8Fo3PIyYe5UU4hF4J5vfPmG64u0LpThtQw4hgLk2oakKqg67vymGjbDw+OSzP7u6CMslmt4+EGCh0TOnMVYPFbl0gAMXee0PDKOrnAuUKQSHpGMmfexHBN0CpQMjo5YRsgYvP9ZPaMDt08DF4b2PwIaTJPYqDsP5KOy51XNTxIrocsgaF2u1BH8aGpfdtSWtJz1GsamS3y59qfODFZzXaClIgPgsAMqeu9Xq3MDYUR4Q/t7hUMBY5vVbWEKJwxeMYcZtnvZSiLhNtvfDkg6yoS+HMMwpXO8N7Kllw== 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-SenderADCheck; bh=e4W9auNu1VkK/QntkwWrvlaR5BxI6dNGqbw0D0vADzY=; b=MYgHONznWGi+C7CfNGvMOwCVgiEfdf4zHhWFWBYu6aQCitWtxhoIug6mqIFnwVUe5x1XMXqxKTycR1jO0wZx02qAcndlaplLXRsX27Pf+P9rUUEjtHrydMchYfgP+3pEHd2zxTNlYLcQ+OlzewiwcukUy0xybGkSdqzaJX3ICOs/kKPf28OwnnBQA0AFbnL4EfohNVzBqBfg37j9iCqXm4med7UbxDRID4YMkazwENutOUewgNOqoVMe7xewInUpwt9+sRzqZ5ZM3LT0+fEzpVdkTVHjXv9j7KQWQoOvpMIdGitchvh/qtszg5cX3TsLgzH6VjWAVB6rA9PFuKdPvA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=e4W9auNu1VkK/QntkwWrvlaR5BxI6dNGqbw0D0vADzY=; b=YC42+NYZ688DrlRVIPJldmziZq50v8LQ2He7AM8+WOw4o74mScfuZoHOsdS8j32xuf1kjjyhmomd2ccXg+oKhOsFbJusXXPOtflDxM/3NvW3m9zKevNGtVj2eqbA67S2r3BXT7dj+xvT7EXac7+hq6Rx2v+9QPgEU+3RgWSfwmU= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM7PR08MB5446.eurprd08.prod.outlook.com (2603:10a6:20b:107::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.31; Mon, 24 May 2021 10:13:13 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133%8]) with mapi id 15.20.4150.027; Mon, 24 May 2021 10:13:13 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, mreitz@redhat.com, kwolf@redhat.com, berto@igalia.com, programmingkidx@gmail.com, Vladimir Sementsov-Ogievskiy Subject: [PATCH 2/2] block/vvfat: fix vvfat_child_perm crash Date: Mon, 24 May 2021 13:12:57 +0300 Message-Id: <20210524101257.119377-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210524101257.119377-1-vsementsov@virtuozzo.com> References: <20210524101257.119377-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.195] X-ClientProxiedBy: HE1PR05CA0186.eurprd05.prod.outlook.com (2603:10a6:3:f8::34) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.195) by HE1PR05CA0186.eurprd05.prod.outlook.com (2603:10a6:3:f8::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.23 via Frontend Transport; Mon, 24 May 2021 10:13:12 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 54b6fe3b-8419-45d4-0a90-08d91e9c8a71 X-MS-TrafficTypeDiagnostic: AM7PR08MB5446: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:37; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: T6JcCOt0E0nhT3wrlCKqYYRqK9gdvPfbimazwKRicqC2wCtJLZoFxgjJUmvCHewV4cCkwRoJaPZxItjaN0wAA8KMDVznnjGm9ShR/JTcCaLlkeAGisoo9O4s5HaWRe7bWxIR0G/B2Q9Y4LNVfR+FZ6zxh5SGr8FB9hjUEFs7zwSIcb/Vh+PFwva+ulIHecaVeri09W5mp+BRwyvL7/qu6wAUefFSJDekyg9W+LcSnZ6dZI9wrm9vaH8dopl0L0IwDbpULgTrdg0B4KdEw5ELAUBVS3BHztSMsJvxXORQZgW8pZNGgPdatnsFAI0oIMX6YC1vzH0FbDUbbsmoOIdQFFS72yuU841i5tZCTP0K2BTZaRccRwvITkckaxxpj3zlC62pccvGafr8C0K70CdYez6Vtt4DBxth7TZtAY4tTltV5c/O4OUl7rLuzJKNKwrTWoKN71YUzWn2t8P4o3q+gbxGIRKi7IIwUVrqs5reOOnkaTzLF/VUZfHlZ5TnK2r9MAmnUAw7IlAImozCJM22yoUJEK5QFA2B1X87PBvAt9NCqmFR0/KgTpYcSHtRPUXnIqrNZezUxw5vOtC2CuX85gzNK89MwfBmyGFrl+K0E1dbbjEzAfs16OL7duWyh9Nrc3f35de8n9XEcl0OOX+wPJmfxC4x008vmJ+gh+CYR7p/O/TYn0jvMoXRT4FFBLBK X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(346002)(366004)(39840400004)(136003)(6506007)(66946007)(66556008)(6512007)(4326008)(6666004)(66476007)(52116002)(86362001)(6486002)(2616005)(107886003)(36756003)(5660300002)(2906002)(186003)(6916009)(956004)(316002)(38100700002)(38350700002)(478600001)(8936002)(1076003)(26005)(8676002)(16526019)(83380400001)(69590400013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: KBw20XA4dUJVS1Sq/ihnOEdOsRR0tOveG6q35Vw5aYjGjOfLN2tKiH1cUq9tdvy6K/+jwHXLjqrU9s9CrGp6lpA5QI5R+zGMFD4maTiKW5KQfHc/lS9XJ1oyZC1ExkZR0qbiaVqrmQTAXKlO8vjL+7NVlK5VPFC69BYXszRIhWwVLZ5iXj1U50dpinM4FqAROFsvk/ZDQGr0jFaPTh7G+IfV1LMbLd4rkdJDsz5lRr39y5SThRIFgbNkbVRjFoHSHiVDhkdfsyY1hhqDfW30km9yFn7zSjnQzN1CjF3IX98SHorGqUN4WDDGYC5/lZVHVHTmeKHp8QbZ9YXL7tTl4obiuiUKgzQp/qd8Y9zc65BOiixbJFWyfQ2h/3UtNI5sMi0+hPe6phw/A1UF5d34lefGOe/mJVsUS6E+YG0xk1l7sA0SfGXz9ARXj7snTJ21s4l9ypsnrxNlRFK8eQtnroAi0RdzsiaWX8L1UK3n4LAYx2FL0L8MwYvCwW7b3ap+BzTnv/PP1/7kCpl4ALdFjXJGfwfcRVWR/KyouL6kQylanGnSC+ss2W1j2ZD0FtN4NKlMGx7JQEzyujOR0z/7kI6yPzpKMWoZllpBzVkpCuBkRollDqQv3vpQz11IGxVDS3ewD+h5ihvJZPAGndwM8Qeh9lVvwyPxj+yZvvWxpZM1GLKPmpH16XPfV3Z7VbItA5pxEonLgV8UbKVII4AoEFoClkHq5kWIuOdkEkedhZeXnAQ7m8R5BY0wjGbs6fFvT/GRELBDcYpNBd0odzPdJ4EB7jzemXSSIf6UwRVTV+eExyM6GewhPqcgKSHLMxE3TkLmPPALdskUAEySj6Vut7b8CPWE1ZbWSqq9bX/L5Cb3uI/UiCCl40iiHQy7InboL8pA0n4+r0O6TqI/vQh786jIZK2by9GxBuYjOURc9NfdiIQY8eWeNAZxNjF50CGtsYEMGNxszugigtwMWEogwTXJMQLApOWa6cObnrQqozSJdLoGiwp9QHm283pTIapKIesvBcjkb+cHX4cd8fcCLBqA9dM85WbtXOUnFN7Ay7n2yuCIcAxANfSGIszIULMIdLBzN6xRXyZ/sQELr5CvRhYxN50GdO96+FrnRoZnVgHlK+bU2YIuS2ZDQPD7FVyuGERvVViyekaVvzkhBbgFBgLjFggs7juKx0so8LL6TICC5FZwyKJIz1fwsw5ZLXlmnR3XcXK0V7S01hyv78wh5XFxtErA721qoVXag/gUKphipXfiY1h4GgXSyIvbHUILmkmlbpZ4VMz8BVeNu/njiAAYYE5GUleiQZiF62OY3++sE3DTjkwTQ/0e67eRnVgx X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 54b6fe3b-8419-45d4-0a90-08d91e9c8a71 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2021 10:13:13.7694 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: bz493QCGyQCeRM0DRH03cIULiinS9bXVp2aFKWMdbCd7W0pic0N6C1HRUJyzp4j18m3I5A/OPLRjfuimVyeTyClU9B+RkowwAokarpj5zis= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5446 Received-SPF: pass client-ip=40.107.22.116; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" It's wrong to rely on s->qcow in vvfat_child_perm, as on permission update during bdrv_open_child() call this field is not set yet. Still prior to aa5a04c7db27eea6b36de32f241b155f0d9ce34d, it didn't crash, as bdrv_open_child passed NULL as child to bdrv_child_perm(), and NULL was equal to NULL in assertion (still, it was bad guarantee for child being s->qcow, not backing :). Since aa5a04c7db27eea6b36de32f241b155f0d9ce34d "add bdrv_attach_child_noperm" bdrv_refresh_perms called on parent node when attaching child, and new correct child pointer is passed to .bdrv_child_perm. Still, s->qcow is NULL at the moment. Let's rely only on role instead. Without that fix, ./build/qemu-system-x86_64 -usb -device usb-storage,drive=fat16 \ -drive \ file=fat:rw:fat-type=16:"",id=fat16,format=raw,if=none crashes: (gdb) bt 0 raise () at /lib64/libc.so.6 1 abort () at /lib64/libc.so.6 2 _nl_load_domain.cold () at /lib64/libc.so.6 3 annobin_assert.c_end () at /lib64/libc.so.6 4 vvfat_child_perm (bs=0x559186f3d690, c=0x559186f1ed20, role=3, reopen_queue=0x0, perm=0, shared=31, nperm=0x7ffe56f28298, nshared=0x7ffe56f282a0) at ../block/vvfat.c:3214 5 bdrv_child_perm (bs=0x559186f3d690, child_bs=0x559186f60190, c=0x559186f1ed20, role=3, reopen_queue=0x0, parent_perm=0, parent_shared=31, nperm=0x7ffe56f28298, nshared=0x7ffe56f282a0) at ../block.c:2094 6 bdrv_node_refresh_perm (bs=0x559186f3d690, q=0x0, tran=0x559186f65850, errp=0x7ffe56f28530) at ../block.c:2336 7 bdrv_list_refresh_perms (list=0x559186db5b90 = {...}, q=0x0, tran=0x559186f65850, errp=0x7ffe56f28530) at ../block.c:2358 8 bdrv_refresh_perms (bs=0x559186f3d690, errp=0x7ffe56f28530) at ../block.c:2419 9 bdrv_attach_child (parent_bs=0x559186f3d690, child_bs=0x559186f60190, child_name=0x559184d83e3d "write-target", child_class=0x5591852f3b00 , child_role=3, errp=0x7ffe56f28530) at ../block.c:2959 10 bdrv_open_child (filename=0x559186f5cb80 "/var/tmp/vl.7WYmFU", options=0x559186f66c20, bdref_key=0x559184d83e3d "write-target", parent=0x559186f3d690, child_class=0x5591852f3b00 , child_role=3, allow_none=false, errp=0x7ffe56f28530) at ../block.c:3351 11 enable_write_target (bs=0x559186f3d690, errp=0x7ffe56f28530) at ../block/vvfat.c:3177 12 vvfat_open (bs=0x559186f3d690, options=0x559186f42db0, flags=155650, errp=0x7ffe56f28530) at ../block/vvfat.c:1236 13 bdrv_open_driver (bs=0x559186f3d690, drv=0x5591853d97e0 , node_name=0x0, options=0x559186f42db0, open_flags=155650, errp=0x7ffe56f28640) at ../block.c:1557 14 bdrv_open_common (bs=0x559186f3d690, file=0x0, options=0x559186f42db0, errp=0x7ffe56f28640) at ../block.c:1833 ... (gdb) fr 4 #4 vvfat_child_perm (bs=0x559186f3d690, c=0x559186f1ed20, role=3, reopen_queue=0x0, perm=0, shared=31, nperm=0x7ffe56f28298, nshared=0x7ffe56f282a0) at ../block/vvfat.c:3214 3214 assert(c == s->qcow || (role & BDRV_CHILD_COW)); (gdb) p role $1 = 3 # BDRV_CHILD_DATA | BDRV_CHILD_METADATA (gdb) p *c $2 = {bs = 0x559186f60190, name = 0x559186f669d0 "write-target", klass = 0x5591852f3b00 , role = 3, opaque = 0x559186f3d690, perm = 3, shared_perm = 4, frozen = false, parent_quiesce_counter = 0, next = {le_next = 0x0, le_prev = 0x559186f41818}, next_parent = {le_next = 0x0, le_prev = 0x559186f64320}} (gdb) p s->qcow $3 = (BdrvChild *) 0x0 Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/vvfat.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/block/vvfat.c b/block/vvfat.c index 07232a7cfc..86d99c899c 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -3209,15 +3209,12 @@ static void vvfat_child_perm(BlockDriverState *bs, BdrvChild *c, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) { - BDRVVVFATState *s = bs->opaque; - - assert(c == s->qcow || (role & BDRV_CHILD_COW)); - - if (c == s->qcow) { + if (role & BDRV_CHILD_DATA) { /* This is a private node, nobody should try to attach to it */ *nperm = BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE; *nshared = BLK_PERM_WRITE_UNCHANGED; } else { + assert(role & BDRV_CHILD_COW); /* The backing file is there so 'commit' can use it. vvfat doesn't * access it in any way. */ *nperm = 0;