From patchwork Tue Aug 10 01:39:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 12427679 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,URIBL_BLOCKED,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 89275C4338F for ; Tue, 10 Aug 2021 01:49:29 +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 D4F0061052 for ; Tue, 10 Aug 2021 01:49:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D4F0061052 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:35270 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mDGtT-00034S-RQ for qemu-devel@archiver.kernel.org; Mon, 09 Aug 2021 21:49:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60406) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDGsl-0001dY-Ok for qemu-devel@nongnu.org; Mon, 09 Aug 2021 21:48:43 -0400 Received: from mail-bn8nam08on20611.outbound.protection.outlook.com ([2a01:111:f400:7e8d::611]:27873 helo=NAM04-BN8-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 1mDGsj-0008Ql-J1 for qemu-devel@nongnu.org; Mon, 09 Aug 2021 21:48:43 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nurNTx2Sosth13VtSYKUn01s9U3rSyC0LbqxpQplrZ9pKI5/P5gzn9BKn1/m/asyLAlOuer4TI2FC2v+gREa4Ony7WIWCta8qi9bAvIbCWktp9cPCCA/q+HR2bjq+dUUpfr/GqHE/iFwhNyQsyiklzzq9azrZ5qoofuP1hYGicV5PWm9tIoWGynWpZhNY830YnSYxUFSN946Dqqn/yPZT8TR3E6qR0/yMuZ8SfXYYvrn/mM1M/6uoLIniJrAS48scDiGXigDop2gCO6ztvfQ9gzltriGUDOwtmXkdIjfvLUFsqjI8YJZr7ts92gVyFz0sWsy0I6r0CW1r7lbHzdQGg== 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=zkh9/cX+1VMUXFpdzU9C7SvKUuISGOK/hqOkA/zARJA=; b=ZKKVB26sYzh+TAZspxsYE9cdZO+AAerhDvIBfENBLujUoQAwZWgfqqgsKjESgVKEWUYavrw//Ntp+/6InuIuaIFaz5jM59m5qJ97B0XVCSVJFfHQqM0kH7sOxO7HWNU4AiOYO9xI6ibE01CkDr4qbHo2peTVdxJwakaWOH4Qk/sthKFk3jOqFchwP1Sx9WsGykbc+TH/R4aC1ey/6wCKaAcchXBEmDr6RSY6Y+7owNkIAyPWATbFEgAXtZ+DJwc47Mun8YETT+FcUdU33A3AkCBAKSxCgYnw0+R7bcuEbDJiP07j1Kq+FhOuIZaqjOQEg4E9uDgoKH/CJCCiWtPHLg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zkh9/cX+1VMUXFpdzU9C7SvKUuISGOK/hqOkA/zARJA=; b=ZarnR0jlL0zAEqE4kP/o4IYWkMPuqF1m6EOTnAk+iWii0uCLwWCsCHXiMmg7WBvF3JNYBc+zWTw8YOCyX3MxEDFIhVfKFuJF3iQ7Ht5soOsTBZGJg9WuMAipMI42khmtGU0I0e0b8xzRo8oHuX+tzM714Gmy5mLNRcp5BwxpoU0= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=amd.com; Received: from CH2PR12MB4133.namprd12.prod.outlook.com (2603:10b6:610:7a::13) by CH2PR12MB4119.namprd12.prod.outlook.com (2603:10b6:610:aa::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16; Tue, 10 Aug 2021 01:43:36 +0000 Received: from CH2PR12MB4133.namprd12.prod.outlook.com ([fe80::d19e:b657:5259:24d0]) by CH2PR12MB4133.namprd12.prod.outlook.com ([fe80::d19e:b657:5259:24d0%7]) with mapi id 15.20.4394.022; Tue, 10 Aug 2021 01:43:36 +0000 From: Michael Roth To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Marc?= =?utf-8?q?-Andr=C3=A9_Lureau?= Subject: [PULL for-6.1 1/1] qga: fix leak of base64 decoded data on command error Date: Mon, 9 Aug 2021 20:39:24 -0500 Message-Id: <20210810013922.215443-2-michael.roth@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210810013922.215443-1-michael.roth@amd.com> References: <20210810013922.215443-1-michael.roth@amd.com> X-ClientProxiedBy: SA9PR11CA0015.namprd11.prod.outlook.com (2603:10b6:806:6e::20) To CH2PR12MB4133.namprd12.prod.outlook.com (2603:10b6:610:7a::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost (165.204.77.11) by SA9PR11CA0015.namprd11.prod.outlook.com (2603:10b6:806:6e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.15 via Frontend Transport; Tue, 10 Aug 2021 01:43:36 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 593d440f-25ad-4ca4-7b60-08d95ba0454a X-MS-TrafficTypeDiagnostic: CH2PR12MB4119: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +DXhRSFx2/+qbQY4Q8QrPKRca+M+h27hPqS3GbzS1rQJGXrwiAJwiNrVchEOBeLSu1ple9zsPV+zGMR4lIfyl9QqYNq0BKpgM5wOPvqgcH62dgx2201Q+6Lon8PISYCqyjKnJ/Nm3UIwffeAXKu/5Bl2R4PpKXwn3a8qETTPsaDF3WHuAG8wcnGgHdlt6WfHnUjtzwdWCU/Globpqz0bvsvHEEgNgwaVjF19aWyIN2J3g2wFLvuNw6RNmzjrjLZHRqsuow7TE8yvB48fCUFx0A/EJmdajWvCOjQhJXucEaMGA5GxPdac5per/wnDCocn646yPBoczDUUGGfS6dR/GDJYYsPUDZA2opPo2rCf1kVh4PB5uJXMGlo5YSo8EUP3AXdUJIYlGB+9F6BE7N5kqFy3QoCKGDrYntHnEv4/CIHJs4+TxlYLIxS10xD0vqBD6xOFr9RrCIDzimdudXD1Htxkqsb55pSfzKmFGUotjjgxDAIPj6Bi1VMcmSW6mn9jzC3WcWNnHvgIhNeZxwPOLAQIRBzURGCVMgPz0HFeO36ItugISALRBwSqe4A/2bjTTfHNZYFrZnY/wtW40iCpw8VfhiqBQxRy84OPOEebjK6MmstB1X83rVxZb/UEHVYezUn7Ij3GGwi3MJj+GYi6zezdnypwDb34+wZbDCK7ORjp29jmOJbAYIju4HfWKnFj X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR12MB4133.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(346002)(136003)(39860400002)(376002)(366004)(478600001)(6916009)(66946007)(52116002)(54906003)(2906002)(66556008)(2616005)(38100700002)(66476007)(4326008)(956004)(38350700002)(6496006)(44832011)(8676002)(36756003)(5660300002)(1076003)(6486002)(26005)(6666004)(86362001)(8936002)(83380400001)(316002)(186003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?KwVcegAG2P+g36Io11FNRjQwgnHt?= =?utf-8?q?DmIZurPk02Rd5cV66NzzGWMeKXI0K+d6aeGcMJYW6OUJLIGnj2CwHsVhEVVpNaUcx?= =?utf-8?q?UJz14sy5QcCrTeA7FEB2j9ahtRqhIuBxJkjt7Jk3JbiR4GG8dRWUaeLvhixnIWFqQ?= =?utf-8?q?CRsWqM+sQZ17MWehPT6JIQedTZmkSayAkDQ3JSNPvNy68rCzUqxDr077WuFtUoO3o?= =?utf-8?q?J0PVGqQpYbGCFSwl608JfLSsRu/UutUguF8tWWCkw4MFHGCDwiDe6AcA5aKEHRMsx?= =?utf-8?q?eMerKeA0PPtC+mwGIe7rewJghVkmcGV/XpP/exs4uUT8NFCFjv5/EnKnBw9mYN4+A?= =?utf-8?q?UgaBtMxQsSwFsW5rnKqrFTHeCeIZNg1yEdOUJT2yCe3uFvWQDc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Z8EbmVGXG?= =?utf-8?q?9ubpYqlgCebPwgt8?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 593d440f-25ad-4ca4-7b60-08d95ba0454a X-MS-Exchange-CrossTenant-AuthSource: CH2PR12MB4133.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Aug 2021 01:43:36.6623 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: c8J/o0cEahf76E7dxPIz/u1nSIu+g3BbqqJP+5Y9RbW588mge8wMHv4S13v/c/zdFF3s8iNX4c/yi7F/q8hiZA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4119 Received-SPF: softfail client-ip=2a01:111:f400:7e8d::611; envelope-from=Michael.Roth@amd.com; helo=NAM04-BN8-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, 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" From: Daniel P. Berrangé If the guest command fails to be spawned, then we would leak the decoded base64 input used for the command's stdin feed. Signed-off-by: Daniel P. Berrangé Reviewed-by: Marc-André Lureau Signed-off-by: Michael Roth --- qga/commands.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qga/commands.c b/qga/commands.c index a6491d2cf8..80501e4a73 100644 --- a/qga/commands.c +++ b/qga/commands.c @@ -402,7 +402,7 @@ GuestExec *qmp_guest_exec(const char *path, GIOChannel *in_ch, *out_ch, *err_ch; GSpawnFlags flags; bool has_output = (has_capture_output && capture_output); - uint8_t *input = NULL; + g_autofree uint8_t *input = NULL; size_t ninput = 0; arglist.value = (char *)path; @@ -441,7 +441,7 @@ GuestExec *qmp_guest_exec(const char *path, g_child_watch_add(pid, guest_exec_child_watch, gei); if (has_input_data) { - gei->in.data = input; + gei->in.data = g_steal_pointer(&input); gei->in.size = ninput; #ifdef G_OS_WIN32 in_ch = g_io_channel_win32_new_fd(in_fd);