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 X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2852C3A5A2 for ; Tue, 3 Sep 2019 20:08:14 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 82D672173E for ; Tue, 3 Sep 2019 20:08:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 82D672173E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sipsolutions.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:50496 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5F65-00061s-PD for qemu-devel@archiver.kernel.org; Tue, 03 Sep 2019 16:08:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46176) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5F2U-0002Wc-Mk for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:04:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5F2T-00049J-Hy for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:04:30 -0400 Received: from s3.sipsolutions.net ([2a01:4f8:191:4433::2]:37076 helo=sipsolutions.net) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5F2T-000484-Ao for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:04:29 -0400 Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.92.1) (envelope-from ) id 1i5F2P-0008HB-VJ; Tue, 03 Sep 2019 22:04:26 +0200 From: Johannes Berg To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 23:04:22 +0300 Message-Id: <20190903200422.11693-1-johannes@sipsolutions.net> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a01:4f8:191:4433::2 Subject: [Qemu-devel] [PATCH v2] libvhost-user: fix SLAVE_SEND_FD handling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Johannes Berg , Tiwei Bie , "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Johannes Berg It doesn't look like this could possibly work properly since VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD is defined to 10, but the dev->protocol_features has a bitmap. I suppose the peer this was tested with also supported VHOST_USER_PROTOCOL_F_LOG_SHMFD, in which case the test would always be false, but nevertheless the code seems wrong. Use has_feature() to fix this. Fixes: d84599f56c82 ("libvhost-user: support host notifier") Signed-off-by: Johannes Berg --- contrib/libvhost-user/libvhost-user.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contrib/libvhost-user/libvhost-user.c b/contrib/libvhost-user/libvhost-user.c index 6a02eaffc672..fcf4a8a00ed2 100644 --- a/contrib/libvhost-user/libvhost-user.c +++ b/contrib/libvhost-user/libvhost-user.c @@ -1097,7 +1097,8 @@ bool vu_set_queue_host_notifier(VuDev *dev, VuVirtq *vq, int fd, vmsg.fd_num = fd_num; - if ((dev->protocol_features & VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD) == 0) { + if (!has_feature(dev->protocol_features, + VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD)) { return false; } -- 2.23.0 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 X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B820CC3A5A7 for ; Wed, 4 Sep 2019 12:08:31 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 9167D22CED for ; Wed, 4 Sep 2019 12:08:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9167D22CED Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:57084 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5U5O-0003wl-Lh for qemu-devel@archiver.kernel.org; Wed, 04 Sep 2019 08:08:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43312) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5TyS-0006AV-RW for qemu-devel@nongnu.org; Wed, 04 Sep 2019 08:01:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5TyQ-0002QH-8w for qemu-devel@nongnu.org; Wed, 04 Sep 2019 08:01:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:61460) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5TyP-0002Ns-Rv for qemu-devel@nongnu.org; Wed, 04 Sep 2019 08:01:18 -0400 Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3353281DF7 for ; Wed, 4 Sep 2019 12:01:15 +0000 (UTC) Received: by mail-qt1-f197.google.com with SMTP id k13so22469672qtp.15 for ; Wed, 04 Sep 2019 05:01:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=S/wdHeehpc8LTayuXzoK+l1PfYDr/hOA256Q3HmfrYY=; b=CH/ZKBlY9YKdg4Ox2O9dKxou4HYAmuIQDbpqIk5Xu/xIL3FMkJNpGJh/d+n5pIEj6I wfIq7xn8Ld5XQWOWp/lo07YjGMVwbAVA961ZMbxcIWl7KX6NCr84dQKn2tVMTt1k7ZMu tQ7LTfxK5LstwGgzJ6GyAD6wcZ/bGmTODH7RuKizCSn8yxx6WgFzkVgkLQcb/+gb7OKi 1x7cJ6hgH0n1X1XdsSq9ZUnU88feDf07mKtvVrGUKCV/20F15WNiYcZznlznWTnrR9S3 r4F7F36JgebSG4frheEqHrX6SZgjV4kP+5G2KUDphYjkfHH9HfGlZCbgRMV5mWFL9u2a fXlg== X-Gm-Message-State: APjAAAWM6fBLmZ9tEiWI+JCY934p039XU2BHLH6yKAHmgJbfw1gl17jr wjFQBchskx5AmG6W315x9TtwSrqdGnKdVjwi/OwLqrvOZQPtBDaPzCpQH8i6A2Dw9Jfsi9u42TU u/ims7/QUnjOAFx0= X-Received: by 2002:a37:a00f:: with SMTP id j15mr36063552qke.335.1567598474005; Wed, 04 Sep 2019 05:01:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqz8MBFFJqwJQfDSBDFalW+O9MqYhUMvhhihL1zNDlGRc8tVQX0CM0JKAAsFTzJQmIIKFWKjLQ== X-Received: by 2002:a37:a00f:: with SMTP id j15mr36063527qke.335.1567598473849; Wed, 04 Sep 2019 05:01:13 -0700 (PDT) Received: from redhat.com (bzq-79-176-40-226.red.bezeqint.net. [79.176.40.226]) by smtp.gmail.com with ESMTPSA id j80sm5052776qke.94.2019.09.04.05.01.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2019 05:01:13 -0700 (PDT) Date: Wed, 4 Sep 2019 08:01:08 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <20190903200422.11693-1-johannes@sipsolutions.net> References: <20190904120026.3220-1-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline In-Reply-To: <20190904120026.3220-1-mst@redhat.com> X-Mailer: git-send-email 2.22.0.678.g13338e74b8 X-Mutt-Fcc: =sent X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 5/6] libvhost-user: fix SLAVE_SEND_FD handling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Johannes Berg , Tiwei Bie , Gerd Hoffmann , Stefan Hajnoczi , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , Xie Yongji Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Message-ID: <20190904120108.5NmtJRv3jeC5OlCk1BO1wXVMbJ8Q0TuQaJQI4EILkqY@z> From: Johannes Berg It doesn't look like this could possibly work properly since VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD is defined to 10, but the dev->protocol_features has a bitmap. I suppose the peer this was tested with also supported VHOST_USER_PROTOCOL_F_LOG_SHMFD, in which case the test would always be false, but nevertheless the code seems wrong. Use has_feature() to fix this. Fixes: d84599f56c82 ("libvhost-user: support host notifier") Signed-off-by: Johannes Berg Message-Id: <20190903200422.11693-1-johannes@sipsolutions.net> Reviewed-by: Tiwei Bie Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- contrib/libvhost-user/libvhost-user.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contrib/libvhost-user/libvhost-user.c b/contrib/libvhost-user/libvhost-user.c index 4b36e35a82..cb5f5770e4 100644 --- a/contrib/libvhost-user/libvhost-user.c +++ b/contrib/libvhost-user/libvhost-user.c @@ -1097,7 +1097,8 @@ bool vu_set_queue_host_notifier(VuDev *dev, VuVirtq *vq, int fd, vmsg.fd_num = fd_num; - if ((dev->protocol_features & VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD) == 0) { + if (!has_feature(dev->protocol_features, + VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD)) { return false; } -- MST