From patchwork Mon Mar 7 11:15:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 12771597 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 00D75C433F5 for ; Mon, 7 Mar 2022 11:35:48 +0000 (UTC) Received: from localhost ([::1]:37648 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRBeW-00046k-2J for qemu-devel@archiver.kernel.org; Mon, 07 Mar 2022 06:35:48 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53396) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <38d7fd68b0c8775b5253ab84367419621aa032e6@lizzy.crudebyte.com>) id 1nRBUd-0005Y1-3V for qemu-devel@nongnu.org; Mon, 07 Mar 2022 06:25:37 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:41381) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <38d7fd68b0c8775b5253ab84367419621aa032e6@lizzy.crudebyte.com>) id 1nRBUY-000761-R6 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 06:25:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=E9U8f+CE/a5/AN3TPLs6/9FG2x5Jkw+GdC7Z0ig5vNY=; b=TieuR 9Hnh238l020bjL+vqLWJvES9vM2rM1NT9J2E6fctWAkLawfEyltvQxGATGMTI4/HD3FScFP72KOPo v4EGKrMldRZzUbHc13cX+YG02Iuzxk63Yt0+8UGTKz/f54Kg0lanlHFPS7IHJkOkm8drkfcnVq1P5 ZeIhYy0LQ0DJ/bMbHBi0V1c0cAAiqyzt9MS8Joe0HCelqvVHafm+9wKFfHXv7qSFzTFu7z6JMxQzY A1JJk5FUsPqGqe8aQyiapIu4a2xFdvx7nJ7atRbEQT5SJHTaH1GKH1n3ahxAcFThFASrAp+Djab8I 9toQaAaz6xze8nBQ8g8OAma55mhTw==; Message-Id: <38d7fd68b0c8775b5253ab84367419621aa032e6.1646651700.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Mon, 07 Mar 2022 12:15:00 +0100 Subject: [PULL v2 06/19] 9p: darwin: Move XATTR_SIZE_MAX->P9_XATTR_SIZE_MAX To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz , Will Cohen , Keno Fischer , Michael Roitzsch , Fabian Franz , Paolo Bonzini Received-SPF: none client-ip=91.194.90.13; envelope-from=38d7fd68b0c8775b5253ab84367419621aa032e6@lizzy.crudebyte.com; helo=lizzy.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_NONE=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" From: Keno Fischer Signed-off-by: Keno Fischer Signed-off-by: Michael Roitzsch Because XATTR_SIZE_MAX is not defined on Darwin, create a cross-platform P9_XATTR_SIZE_MAX instead. [Will Cohen: - Adjust coding style - Lower XATTR_SIZE_MAX to 64k - Add explanatory context related to XATTR_SIZE_MAX] [Fabian Franz: - Move XATTR_SIZE_MAX reference from 9p.c to P9_XATTR_SIZE_MAX in 9p.h] Signed-off-by: Will Cohen Signed-off-by: Fabian Franz [Will Cohen: - For P9_XATTR_MAX, ensure that Linux uses XATTR_SIZE_MAX, Darwin uses 64k, and error out for undefined hosts] Signed-off-by: Will Cohen Message-Id: <20220227223522.91937-7-wwcohen@gmail.com> Signed-off-by: Christian Schoenebeck Reviewed-by: Christian Schoenebeck --- hw/9pfs/9p.c | 2 +- hw/9pfs/9p.h | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 14e84c3bcf..7405352c37 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -3949,7 +3949,7 @@ static void coroutine_fn v9fs_xattrcreate(void *opaque) rflags |= XATTR_REPLACE; } - if (size > XATTR_SIZE_MAX) { + if (size > P9_XATTR_SIZE_MAX) { err = -E2BIG; goto out_nofid; } diff --git a/hw/9pfs/9p.h b/hw/9pfs/9p.h index 1567b67841..94b273b3d0 100644 --- a/hw/9pfs/9p.h +++ b/hw/9pfs/9p.h @@ -479,4 +479,22 @@ struct V9fsTransport { void (*push_and_notify)(V9fsPDU *pdu); }; +#if defined(XATTR_SIZE_MAX) +/* Linux */ +#define P9_XATTR_SIZE_MAX XATTR_SIZE_MAX +#elif defined(CONFIG_DARWIN) +/* + * Darwin doesn't seem to define a maximum xattr size in its user + * space header, so manually configure it across platforms as 64k. + * + * Having no limit at all can lead to QEMU crashing during large g_malloc() + * calls. Because QEMU does not currently support macOS guests, the below + * preliminary solution only works due to its being a reflection of the limit of + * Linux guests. + */ +#define P9_XATTR_SIZE_MAX 65536 +#else +#error Missing definition for P9_XATTR_SIZE_MAX for this host system +#endif + #endif