From nobody Fri May 17 03:01:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1662711027; cv=none; d=zohomail.com; s=zohoarc; b=eXOtYLUAD5+gNodvvsRYf8if7ZbTO943Ira94viCmmE33wZ0vE7Q9L+N08HI/Wu8gqC82b2MKAd6bwd6/D21NJzfQBfUkqt+E/q/nPuaL+J2G/AMvKwYXDuxpJr7DBdjZlqNe7WB6ZEZpy3EW8dXlEBFzJaHCuUAZ3ExOe5JrWk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662711027; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=C77PM0r5Nmstj5eEefW3kaBEN4SowKo/1tOewXmIhn0=; b=c7NiwO+pZdPizVXS3KxnjTrYl64ad4TB0eR9yb35zQXbR0eKzRCQVGR7Pzv5lGBiHuiW+CfCa8U+86d0vqh8qwCxnKwZZPVLw8JlNNoaCyBXlNfINQ757C7Cx8t53DwFinC4nB2Pom6fJFuHwsx+ztd3XvAz9I4dTmTxxKYY4A8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1662711027757822.2399728820795; Fri, 9 Sep 2022 01:10:27 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.403911.646169 (Exim 4.92) (envelope-from ) id 1oWZ5B-0002Jg-Vi; Fri, 09 Sep 2022 08:09:49 +0000 Received: by outflank-mailman (output) from mailman id 403911.646169; Fri, 09 Sep 2022 08:09:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oWZ5B-0002JZ-Sv; Fri, 09 Sep 2022 08:09:49 +0000 Received: by outflank-mailman (input) for mailman id 403911; Fri, 09 Sep 2022 08:09:48 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oWZ5A-0002JT-1O for xen-devel@lists.xenproject.org; Fri, 09 Sep 2022 08:09:48 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id c482408d-3016-11ed-9760-273f2230c3a0; Fri, 09 Sep 2022 10:09:46 +0200 (CEST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id DF9331F8ED; Fri, 9 Sep 2022 08:09:45 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 99222139D5; Fri, 9 Sep 2022 08:09:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id zytxI8n0GmNwQAAAMHmgww (envelope-from ); Fri, 09 Sep 2022 08:09:45 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: c482408d-3016-11ed-9760-273f2230c3a0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1662710985; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=C77PM0r5Nmstj5eEefW3kaBEN4SowKo/1tOewXmIhn0=; b=jdqbuTeZtPzEj3soICIcf1IvFtjNcsc4rbmzS2uF9ozUjVsURcKJmN5+fX4Z646U4xrxQg sTftlFpKYaYYI0kn9OmjyrGfRxGoBuGXomsGkLkVRGY9KUSPDUcM4d180DL9Vyx3wcM1P1 7LPUVeH8Be7e7n7cC5QgfOxQ2RJjuHg= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Henry.Wang@arm.com, Juergen Gross , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu Subject: [PATCH] xen/gnttab: fix gnttab_acquire_resource() Date: Fri, 9 Sep 2022 10:09:44 +0200 Message-Id: <20220909080944.28559-1-jgross@suse.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1662711030032100001 Content-Type: text/plain; charset="utf-8" Commit 9dc46386d89d ("gnttab: work around "may be used uninitialized" warning") was wrong, as vaddr can legitimately be NULL in case XENMEM_resource_grant_table_id_status was specified for a grant table v1. This would result in crashes in debug builds due to ASSERT_UNREACHABLE() triggering. Basically revert said commit, but keep returning -ENODATA in that case. Fixes: 9dc46386d89d ("gnttab: work around "may be used uninitialized" warni= ng") Signed-off-by: Juergen Gross --- Might be considered for 4.17 and for backporting --- xen/common/grant_table.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c index ad773a6996..68e7f1df38 100644 --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -4125,7 +4125,10 @@ int gnttab_acquire_resource( =20 case XENMEM_resource_grant_table_id_status: if ( gt->gt_version !=3D 2 ) + { + rc =3D -ENODATA; break; + } =20 /* Check that void ** is a suitable representation for gt->status.= */ BUILD_BUG_ON(!__builtin_types_compatible_p( @@ -4135,17 +4138,6 @@ int gnttab_acquire_resource( break; } =20 - /* - * Some older toolchains can't spot that vaddrs won't remain uninitial= ized - * on non-error paths, and hence it needs setting to NULL at the top o= f the - * function. Leave some runtime safety. - */ - if ( !vaddrs ) - { - ASSERT_UNREACHABLE(); - rc =3D -ENODATA; - } - /* Any errors? Bad id, or from growing the table? */ if ( rc ) goto out; --=20 2.35.3