From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 79640C433EF for ; Thu, 17 Feb 2022 16:33:02 +0000 (UTC) Received: from localhost ([::1]:56060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKjiH-0005Ve-KH for qemu-devel@archiver.kernel.org; Thu, 17 Feb 2022 11:33:01 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46390) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKjft-00045f-L7; Thu, 17 Feb 2022 11:30:41 -0500 Received: from kylie.crudebyte.com ([5.189.157.229]:52319) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKjfo-0003Ss-Ug; Thu, 17 Feb 2022 11:30:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=kylie; h=Content-Type:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Content-ID:Content-Description; bh=M7AK1zKwTDtTFLQ9r9DDTNAbCAhNVnY4fcgsrE/pDuo=; b=RHz3O7IXOVSsbA5AxjdNVdCb9E BwVjiOPch9KA+fYQvGu+dm2wjqKV6W8zrTUjqn13xM/hVq7iYkpj1tCJqxRqMvpncBC4DKRF2EEYJ av8czO0K67WTJ0HyKtP9ZkRxyd20p9CRp6jBxW6GrPwz2PCMPUBFsQwbXTb4x9eeEHvlYPGYjom1P iKQHbDnSW59k05aApFZaxtRUitIYBBAEaCA3yATVYUsmq7OYVcMxaRHF1EkrxI/QmIhZT9hD+ZJfK idS8qqeKAXHQGslof0xub4Uah4Pif8/flT9BdYTYpTibIequz0rfNwxPSOvmpfAe5ygDcZssQzcNQ UDAsw1qalD3BsPUFOkF1yYztgQxKgGQsqG64pWxpu5IdZ4Ndz7cn1Bpebz7V3+JJ+jnuDkC+HTXjn vBAGMK7rvioiAN2MYfncTq8YHNA+hz6k/odcblrVhUD9yR7OzHdi4fJw27O3Tqf6F6YwPpuTxDA7I Oeo+uDfZI/g5KGd8d2KQbWLnqZxF6f3eyH2eFZ+XcIi2oOgYLFBXmzlNOTahaYYxEWxepNMj5jgA2 ELvxwTFLAAaZGjoErsdRVeJrQH/5nMqwNgMnTkVNkr6E6RlosJje6B0zlB7daf+6kAMbET+mc+o1p eJJcW8ZT8bza4UCRcK4V+hPhg6dvny6XwytiYrCsg=; From: Christian Schoenebeck To: qemu-devel@nongnu.org Cc: Vitaly Chikunov , Greg Kurz , qemu-stable@nongnu.org, "Dmitry V . Levin" Subject: Re: [PATCH v5] 9pfs: Fix segfault in do_readdir_many caused by struct dirent overread Date: Thu, 17 Feb 2022 17:30:11 +0100 Message-ID: <2135244.TdAzAAGDzu@silver> In-Reply-To: <20220216181821.3481527-1-vt@altlinux.org> References: <20220216181821.3481527-1-vt@altlinux.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Received-SPF: pass client-ip=5.189.157.229; envelope-from=qemu_oss@crudebyte.com; helo=kylie.crudebyte.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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" On Mittwoch, 16. Februar 2022 19:18:21 CET Vitaly Chikunov wrote: > `struct dirent' returned from readdir(3) could be shorter (or longer) > than `sizeof(struct dirent)', thus memcpy of sizeof length will overread > into unallocated page causing SIGSEGV. Example stack trace: > > #0 0x00005555559ebeed v9fs_co_readdir_many (/usr/bin/qemu-system-x86_64 + > 0x497eed) #1 0x00005555559ec2e9 v9fs_readdir (/usr/bin/qemu-system-x86_64 > + 0x4982e9) #2 0x0000555555eb7983 coroutine_trampoline > (/usr/bin/qemu-system-x86_64 + 0x963983) #3 0x00007ffff73e0be0 n/a (n/a + > 0x0) > > While fixing this, provide a helper for any future `struct dirent' cloning. > > Resolves: https://gitlab.com/qemu-project/qemu/-/issues/841 > Cc: qemu-stable@nongnu.org > Co-authored-by: Christian Schoenebeck > Reviewed-by: Dmitry V. Levin > Signed-off-by: Vitaly Chikunov > --- Queued on 9p.next: https://github.com/cschoenebeck/qemu/commits/9p.next Thanks! I prepare a new PR now. Best regards, Christian Schoenebeck