From patchwork Tue Mar 9 10:21:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Edmondson X-Patchwork-Id: 12124621 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=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,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 09AA3C433DB for ; Tue, 9 Mar 2021 10:25:42 +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 8979965268 for ; Tue, 9 Mar 2021 10:25:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8979965268 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:42540 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJZYa-0000In-Ie for qemu-devel@archiver.kernel.org; Tue, 09 Mar 2021 05:25:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47174) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJZVF-0006Sy-9f; Tue, 09 Mar 2021 05:22:13 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:54628) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJZVA-00026f-2Z; Tue, 09 Mar 2021 05:22:13 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 129AJd4Z010915; Tue, 9 Mar 2021 10:22:06 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=OQ6LuMZKmrZe2Rsv9g4XWMsLyPmUbJE7R8shR7N8T+g=; b=KEy4nw+THe8x3uaahi8U61wKIsv1HpA0drQ0TxPZcDo0gL/aiWs9xTTCF0BW9LvWcLU0 zKxnKXJkn08GNy08nOrBXqSDS69LYCWoX/dOm28UiqK/Qrkcho3lrsH9/khi6gX9JV+G VpuOH9kf+ckPCnHTQL1k/vl+ZV1rQptn54JUW+VCM9UYBJANA3y4rl2+sTi0FkxDzGMB 2r1LQrzydjumwqfVZVtOletg+snDgKKdxhJwVGkk15DWpf8IPisXCY2iEf28JATXgB6F oSotxkXQUz+Lz5w3hBv0H5GnIH/W07q++l0ABL0VM54wBEEiwp2uIrXdIqYF5FIeZiCa 3A== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2130.oracle.com with ESMTP id 373y8bpx0a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Mar 2021 10:22:06 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 129ALUa3158580; Tue, 9 Mar 2021 10:22:06 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2177.outbound.protection.outlook.com [104.47.56.177]) by aserp3020.oracle.com with ESMTP id 374kmy995w-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Mar 2021 10:22:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hB7zmvm4l6URo4/LEahkXhJ2PXWn2cwZUPIZ9lCoadwOjZ5AqF1MJe+k1uG1eZZUjmC3xWZGdQDGLmB4Z6gY0sZL6XzoysvTUqwjbl+fSNVrTRYJWdtf73TZy3LSSWUjSP31upkFee54JxoqieHedfmsB8OzgbSrnnBd3pDpxClSFq+uiN5cBmPkJh0LInKDlHWfnK6U72JM4ddjr1XhCzxS61gS77VPvXWrsYo1X2tWsUThXkDWrK2kwt3hRuLEkXflmUN52q+mb/xFiMvLFonIRJY/+Jb/dlPOYeD+/8l/R4sFOYrbarjDcEot0xc2pp8WJ+TyxE7dgDWD64pe3w== 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=OQ6LuMZKmrZe2Rsv9g4XWMsLyPmUbJE7R8shR7N8T+g=; b=lknpsNj8Ddj9EVezWlVa0XFjRzl6sIEc+hY97IFHqUVfH5A7Yk20V07OP9klQUf2ffeZ6NFfDALM3LwwHmHlHzOuqHpNsgqpa8GzKVssgBKrkM06DimEGefaiox+Elae5T51Qej5LxobC8osGUAePEBOl6zAtPmeUYRjb49ivvTuHwFXiwmNjC5UrEmhv90DD/j2N50mH4XCk5ExBeHidNrhahD1cHhsy0neKEiDNFib8CNX8EsZbOFW1KUSzlfyCx9G5LHMEHB4D/9KLudcC8Vu/kNnYW34dmbMLElSqncCKLgdtUrbsnniyWD2IAP0ng6BNjp4/NjijhkWkNDHlg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OQ6LuMZKmrZe2Rsv9g4XWMsLyPmUbJE7R8shR7N8T+g=; b=Uzlt1tNZm81D1o380BVpUbGIom9HzCyyqRz18oZQV4SJwlkyRUKiRxUOav41cDfIHqPf7aSZnRMFpBd+DviQosjuCeI2laD+DMmb9j5paIs3GaERir5/UDj2eX5caticNNse6qXFCuZP0t/xhW1fYSzJcyzk1dGLnjjNxT+mS30= Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=oracle.com; Received: from DM6PR10MB3148.namprd10.prod.outlook.com (2603:10b6:5:1a4::21) by DS7PR10MB5184.namprd10.prod.outlook.com (2603:10b6:5:38e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17; Tue, 9 Mar 2021 10:22:04 +0000 Received: from DM6PR10MB3148.namprd10.prod.outlook.com ([fe80::f871:5965:2081:3934]) by DM6PR10MB3148.namprd10.prod.outlook.com ([fe80::f871:5965:2081:3934%5]) with mapi id 15.20.3890.038; Tue, 9 Mar 2021 10:22:04 +0000 From: David Edmondson To: qemu-devel@nongnu.org Subject: [RFC PATCH 1/4] block/vdi: When writing new bmap entry fails, don't leak the buffer Date: Tue, 9 Mar 2021 10:21:54 +0000 Message-Id: <20210309102157.365356-2-david.edmondson@oracle.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210309102157.365356-1-david.edmondson@oracle.com> References: <20210309102157.365356-1-david.edmondson@oracle.com> X-Originating-IP: [2001:8b0:bb71:7140:64::1] X-ClientProxiedBy: LO4P123CA0297.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:196::14) To DM6PR10MB3148.namprd10.prod.outlook.com (2603:10b6:5:1a4::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from disaster-area.hh.sledj.net (2001:8b0:bb71:7140:64::1) by LO4P123CA0297.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:196::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.26 via Frontend Transport; Tue, 9 Mar 2021 10:22:03 +0000 Received: from localhost (disaster-area.hh.sledj.net [local]) by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id afa22f67; Tue, 9 Mar 2021 10:21:57 +0000 (UTC) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2fb77d77-113c-43ae-3185-08d8e2e52f64 X-MS-TrafficTypeDiagnostic: DS7PR10MB5184: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3968; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6T3Tvpfqz+ngiTWpLfPyEObFMSQOh/ENZR9Hm0MQC6uSti3TVSWw/QRhNcF7UgAIexXmeOk0Lqn21nkoPS++HCQXhRzvqr6cSYO1W3VMzQhQpuiu0RG2KnIvCvyW0GP6VD3f7EDBdjHEf+TUPZZGC/ZUrIYVJkj6HPWer8zkTsFYoI3Ynm8E1NcBKqiLEhMoJ3Axnj+7PKHv8wxLVTjndef8q7xVgeW+709Os6KyjqG9/VDY5TBLVaNsaAmw6vGbyQSEw7YT/AglLtw1hbtd2+8WAwypj+gH2ZhbdyXxRlkDyQBVkfM85J6gURTxFJq+U5B2rigXCHcH/gq+y05jvlbw1ra+6zr7x9LuMrJGXtZSv9ANJxLDgbZP8L56LAgbwC7M5C4GULdHW+iWnlb3BMU29SxgtfF8f57CCneq/0fZasXVw11UOxNZpUlfmCjDt/nnNJjKZJ7h//klmS/wOWEJt2SUKGohAcxvvvgqH2UaCZagx7feQFrnEZ8qM1mhGNiGD6z0zQKnLYnVJwDgXA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR10MB3148.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(376002)(396003)(39860400002)(346002)(366004)(136003)(2616005)(66946007)(6666004)(4744005)(478600001)(107886003)(86362001)(1076003)(6916009)(66556008)(54906003)(66476007)(8936002)(8676002)(186003)(5660300002)(316002)(44832011)(52116002)(2906002)(4326008)(83380400001)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 4gPlYhdccfOFaB4lRpIe5acmeFuzCe8HnIw4HURhM4gSwJFVQRouFqdxwI7O1s3vmPeN586HyCRLWCLSUMFH2g47YkQcMLJhdf7EquCDF6SaE21r1xzjxEhY/Yvp5hQ8iKwy1z5k9uUDnUQEacrApf1pKWcKGe9i16X1FuO7MLP8f/WWqM0DEeF6S/WDQNaZfUXG6cXSXuf+t02r3/iD5LfAlz1O8rKuPMbW6qQ6ZBCYXy956mVfO16kUITN7XXNdZNsJ3MJVmfcLTYzvUTZ8EsZTl2m1lpiZ0afnhcH6DA1CROA0QbfPVUgXxINtw2XnNBiZBeLWZvvLCsPByioeJfiAAP5+k93WiQn22iP8YyqAXFA7Lr9hmJtJVWZadJsSOeR1Gdbqp7S7/cVpqjRtaSOPlORhET+13vilddjgJzV0y/aV4M5kmrO5t4DBYztJ3CaIgiX9hF7xyAYvPPlL0Wjj5d3qEyXVfPjMqiprSouRmGfQZ4mZhh+PRqLWOOitU7xFjTBWuE6WbXxryZzIu76EC7dTWVo3u4eB2GtcVavIuAKamF22x95xv1Pi1zUWvyvtZ0gkoUJT7B+832l75Dr5DxYqx0PoPxs86aWwi/Qot6G3VKBZkIj6dRyDGQqIuRDmCdPJzaBhx5v+nXjc74/AAedtlOhR0lh6k6Q1GusdFHHjjRjpJf4GuCLkhwpro6DMHGiNIhWzmfbt5E/IeFBssxVET684ObWiBsOGjwPVJvai+gA2ph6a2BjBglAf2n7pD8MCZw6Q/WgYExnXlBHWSpPPLHHgDjjzfGcGGMcqOByFlmlopSm5chWTpVkES0wCkgHCcfad4I0sLfyStULQB6pP9xLoVbO6ZhMrqgYJwvN7aQkOcTrdN+Od94b9qoDtkN12iXgbqHb4Mt5KYxxXrpUP944w4zH6FkkbHeLp4E/WJiiMguE8mmndNh13yYhhZPRsSDneTMh+r4H/A7eBvaiTnEdDqLV3JhFXUDzMvQhs8jyvJqqgZLSiVnSpZajUc1qL5R0GTLT6MNYsX9gMbjP9D8KictUHxY7+Hk8ZUnRMuksPLyjpV68TWJsdxVsY/Vj/ZiKm71twcEJJCjE6h/LxVI7Ew9sh2W5gyfI/2UQvaaLWu206x7DWKNxuiZpRRFAmhyrW9EYNADZqiBzlrPjHMIqQQl6Pg4K+q4kWBOTLSbKMwpK27l+XZjQpfAPCLnj1sYHuTCPqovvBEWS2ZNVWLoRF1qFioXvyUlaAZMX4Hu4RwspXNxCil26j/O+V6bFmEQHMF77Aetqb9Zkj2Qxm29Nj4ziILkenYT3GunPXbtir+EYJXMA1tiZbmN1ZFRszHFOE4WhlbU8drkoQVr99ro/DN0FQwMGsuY= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2fb77d77-113c-43ae-3185-08d8e2e52f64 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB3148.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2021 10:22:04.6556 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EtxJ6fdK6+W/aeNs99fFBRXCbco1O7l/YCkUigKfRq3UaPk8ybaXoaAqgtKiL8vCmyOAl6yosCtxHMBC0OPNnKCh3Z0SwOKKfh5WC/CpS5A= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB5184 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9917 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 phishscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103090049 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9917 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 mlxscore=0 phishscore=0 lowpriorityscore=0 malwarescore=0 suspectscore=0 adultscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 priorityscore=1501 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103090049 Received-SPF: pass client-ip=141.146.126.79; envelope-from=david.edmondson@oracle.com; helo=aserp2130.oracle.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=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: , Cc: Kevin Wolf , qemu-block@nongnu.org, Stefan Weil , Max Reitz , David Edmondson , Stefan Hajnoczi Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" If a new bitmap entry is allocated, requiring the entire block to be written, avoiding leaking the buffer allocated for the block should the write fail. Signed-off-by: David Edmondson Reviewed-by: Philippe Mathieu-Daudé --- block/vdi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/vdi.c b/block/vdi.c index 5627e7d764..2a6dc26124 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -690,6 +690,7 @@ nonallocating_write: logout("finished data write\n"); if (ret < 0) { + g_free(block); return ret; }