From nobody Thu Sep 19 00:15:21 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1720046772; cv=none; d=zohomail.com; s=zohoarc; b=Ueg43lw7VVoxdr1yqaYU28MHR9OJ+j9r4xioeXatFGFhToWsx4p5gAOIquUGwHTU4bnrhdfhzCGVYND1DDvyJFP38zUthSBCix6ai0VOszxdLhkS0WHjyToiVa+xuvotM1+Bz1kG20X+Q9ky1k+hVKLGHWOA428YrCGfwQtI4P4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720046772; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Q0Pfb548kulwNGCVafgBGSBiO4uWmp/hiUtG94za6C8=; b=IJgG5636Iq9uIB904cq8gKUPeeBi+MjLLiiEHGeDJ+OupYvuAUP2DC4cYVvKe6Sd9EX3cC0oVCEDZb/zBde79n9UNSBc4zykx3wc02pvOfENameR1ARNmi8nEG9TQtwu9JdJs0WjKj0sRFqMgRuDG91h1V6h7Sb+Tfd9NyYAyTo= 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 1720046772837444.4798109303058; Wed, 3 Jul 2024 15:46:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8iu-000289-PZ; Wed, 03 Jul 2024 18:45:12 -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 1sP8ir-00027K-Ju for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:45:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sP8im-0000vD-J0 for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:45:09 -0400 Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-76-DX0RKLmuOUyaQ21mk_v_Tw-1; Wed, 03 Jul 2024 18:45:02 -0400 Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-52e98697a27so1331658e87.2 for ; Wed, 03 Jul 2024 15:45:02 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5861324ed2dsm7634044a12.28.2024.07.03.15.44.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:44:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046704; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Q0Pfb548kulwNGCVafgBGSBiO4uWmp/hiUtG94za6C8=; b=HNq76qj2Iq4gy4KjT7UfPw0fHWjGm5hAW9Pi4o0F7hV1XjhATZlZ01PTnzsBd3ereK5AiQ P0R/SZwF6jlJg8woN66ZfaF6FW7B7Cd8rn4ASx/olUKSC826xkJlj90KlT3su4IeR50UrP b1W/iLZvkoxxbODY2zPhWgRl0b6rlBs= X-MC-Unique: DX0RKLmuOUyaQ21mk_v_Tw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046701; x=1720651501; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Q0Pfb548kulwNGCVafgBGSBiO4uWmp/hiUtG94za6C8=; b=RM6vEquYEmBVQsnN6f1LniYwtuNViney/SEwYBO8Tx/EREDhxA07PDtvL4fEzjkIec vPWZUfCrLamYII3Xx06LYDr3Vhheyv/wYyPYiwOXPYCDddo5ynvOazuxogrAcOoZKyWq OQzBuBUTGELXbhgiZMMbe0Sxi4NwbHJ3ND3P/9Fv5vDppmbxybtm/j8SwDZHPbclGSyl 2O4nP6HeHRAWfFr8o4MTorNt1luRKHWSdnlb3XKM1C1OV3Va9YM/qDwgmFFy5GKLOJ4q cYnzmtGgglxHtMwfRLYlTyPMEXPSe+lLkxIDpcyjDXjTCRI4IBEf0rCzltu7rhf6JB6A jcyQ== X-Gm-Message-State: AOJu0YxzLb8ueNuRr4g6bJsJoX3gthjcAFrGC+N9N0Z+EI18h7/5lEOs z7y0XHlz/mZIOHV+OlbA5RpR3GADtqOjN0fJ5G4n89mm2TcUyu465BFLEPJDmPyclY+07Xv8cmM 9DFanE95aZs5iM47nI6lKdXvafgudjFuZsX2YCYtIkilYUuEqp56UMGxqVMIVF800K/nbZdI99X ropI96w6QQEPLOdK9hc/sOBu1/gOn1NA== X-Received: by 2002:ac2:4e05:0:b0:52d:6663:5cbe with SMTP id 2adb3069b0e04-52e8264e53fmr8197327e87.12.1720046700784; Wed, 03 Jul 2024 15:45:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFAMVY3DMxNt0O68gztr0SxHQAvxN/VKW+4hzU8/Rfz0z+oAQnEzcY2kFIx+Ku39SSlZKfsPA== X-Received: by 2002:ac2:4e05:0:b0:52d:6663:5cbe with SMTP id 2adb3069b0e04-52e8264e53fmr8197276e87.12.1720046697719; Wed, 03 Jul 2024 15:44:57 -0700 (PDT) Date: Wed, 3 Jul 2024 18:44:52 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Christian =?utf-8?Q?P=C3=B6tzsch?= Subject: [PULL v3 09/85] Fix vhost user assertion when sending more than one fd Message-ID: <5093bee0fa8a6c9712c96653da3a79bc37a4e45d.1720046570.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1720046773278100009 From: Christian P=C3=B6tzsch 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 Message-Id: <20240426083313.3081272-1-christian.poetzsch@kernkonzept.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- 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 MST