From nobody Sun May 19 15:05:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=kernkonzept.com ARC-Seal: i=1; a=rsa-sha256; t=1714120459; cv=none; d=zohomail.com; s=zohoarc; b=AElm3T1OEtl6ANIlWDtwM2PQ/8o9uvlyNs/aMWUvoTNlnYeqoR1bUMotPo79XzTryaLWN8eKAlx9BEMyqxhfv2iCOyTP7hd0Ev4iY84BGh+N1rl7FB8ksH7gj+e9ny0BPu3WV4cW0hVewGCqyaKcWagiRKpLZr/0tek8+zyrgNI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1714120459; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3T3uC+uPxOU/vifPXjSQcrQgSVb5h9+GqYbWLNEU9n4=; b=DMOuH9x36HYbBhn3/sQxcn15GMTHsADyL7F5GpShaMYIgOoQcgb9XZFIWq+mxFDF4dlq1lkljo1f9s/QqKwFirqfH1mCs7sdNn79jbNh1AtyQXqDbkArI0LJ8WBRvW8SQaZgD0mCRDtFqKBeeDVOQmrIQgzBty+Up5xjhpllydQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 171412045910483.82642350737717; Fri, 26 Apr 2024 01:34:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s0H1H-00020a-KV; Fri, 26 Apr 2024 04:33:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s0H1F-00020C-Si for qemu-devel@nongnu.org; Fri, 26 Apr 2024 04:33:21 -0400 Received: from serv1.kernkonzept.com ([2a01:4f8:1c1c:b490::2] helo=mx.kernkonzept.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s0H1C-00014u-Tb for qemu-devel@nongnu.org; Fri, 26 Apr 2024 04:33:21 -0400 Received: from pd9fe93de.dip0.t-ipconnect.de ([217.254.147.222] helo=iris.dd1.int.kernkonzept.com) by mx.kernkonzept.com with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) id 1s0H19-00F3kg-19; Fri, 26 Apr 2024 10:33:15 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kernkonzept.com; s=mx1; h=Content-Transfer-Encoding:Content-Type: MIME-Version:Message-Id:Date:Subject:Cc:To:From:References:In-Reply-To: Reply-To:Content-ID:Content-Description; bh=3T3uC+uPxOU/vifPXjSQcrQgSVb5h9+GqYbWLNEU9n4=; b=im+eObZrn+KM3xsguizL4j5Lhw U8+453pvkgsV2BT77odvbMUdIw+AiusUtaHnMmR/55waq1PtuBXEtuQrtFc1EAWCUxy/qJ37J97D4 dJMBlbsZdWNoRAWcfNAADSo9yDs9a94Vh7B36eDXvMC5kOUTtde/r6PQSSmQhmw4lNqXDv+fgVSJT IfHc1jnvcTOQ2EmYglvKcRuaf/OADk2ywPy4y3qZQq13JqoRxmgnZAxeZB8/g5dlNgsdwdt9FwuVb 8NlYD363jzRO/SgrNUZpg2PQlLH+MRlwhgXTiagCEzLmQn6Ba3NFf2NSMR/iR8UuBqID6OHFRUA51 ZQ1OVyMQ==; From: =?UTF-8?q?Christian=20P=C3=B6tzsch?= To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , =?UTF-8?q?Christian=20P=C3=B6tzsch?= Subject: [PATCH] Fix vhost user assertion when sending more than one fd Date: Fri, 26 Apr 2024 10:33:13 +0200 Message-Id: <20240426083313.3081272-1-christian.poetzsch@kernkonzept.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a01:4f8:1c1c:b490::2; envelope-from=christian.poetzsch@kernkonzept.com; helo=mx.kernkonzept.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 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @kernkonzept.com) X-ZM-MESSAGEID: 1714120461195100003 If the client sends more than one region this assert triggers. The reason is that two fd's are 8 bytes and VHOST_MEMORY_BASELINE_NREGIONS is exactly 8. The assert is wrong because it should not test for the size of the fd array, but for the numbers of regions. Signed-off-by: Christian P=C3=B6tzsch --- subprojects/libvhost-user/libvhost-user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvho= st-user/libvhost-user.c index a879149fef..8adb277d54 100644 --- a/subprojects/libvhost-user/libvhost-user.c +++ b/subprojects/libvhost-user/libvhost-user.c @@ -568,7 +568,7 @@ vu_message_read_default(VuDev *dev, int conn_fd, VhostU= serMsg *vmsg) if (cmsg->cmsg_level =3D=3D SOL_SOCKET && cmsg->cmsg_type =3D=3D S= CM_RIGHTS) { fd_size =3D cmsg->cmsg_len - CMSG_LEN(0); vmsg->fd_num =3D fd_size / sizeof(int); - assert(fd_size < VHOST_MEMORY_BASELINE_NREGIONS); + assert(vmsg->fd_num <=3D VHOST_MEMORY_BASELINE_NREGIONS); memcpy(vmsg->fds, CMSG_DATA(cmsg), fd_size); break; } --=20 2.39.2