From patchwork Fri Jan 27 13:57:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 122602 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 35BAC424A2; Fri, 27 Jan 2023 14:57:39 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C667240223; Fri, 27 Jan 2023 14:57:38 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 5C7F140146 for ; Fri, 27 Jan 2023 14:57:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674827856; 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; bh=NN5JPBffc6NJ/GRltC17X4bPPyAq7Z5dSFJWkmhZFic=; b=Tg7dIAhLaMLgkCJZOgxsZtuM+KXYSShFFMKXFVSgU7YAesePMhXcidK4+vr8mbHsUVUmh2 bhnUY/AUN0+odNcX9y8vst8anw9drjIYh16kCeKR5mQxHFA6lizLyabldwLqZBvKnrY59f LK8GC/+9hPL4SnRbLah9oEDsSkbWNsk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-67-XGxT0nEAPiWznpD4YtwiKQ-1; Fri, 27 Jan 2023 08:57:35 -0500 X-MC-Unique: XGxT0nEAPiWznpD4YtwiKQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 34395858F09; Fri, 27 Jan 2023 13:57:35 +0000 (UTC) Received: from max-t490s.redhat.com (unknown [10.39.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 12C93492C14; Fri, 27 Jan 2023 13:57:33 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, david.marchand@redhat.com, chenbo.xia@intel.com Cc: Maxime Coquelin Subject: [PATCH] vhost: improve truncated messages handling Date: Fri, 27 Jan 2023 14:57:31 +0100 Message-Id: <20230127135731.22499-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org This patch improves truncated messages logging to ease debugging. First, it differentiates between message's buffer truncation and control data truncation. Indeed, MSG_CTRUNC can happen even if enough room was provided, in case LSM detects access rights issue. Then, it does not return directly in case of truncation, but returns normally to let a chance to display request type in Vhost-user protocol layer logs. Signed-off-by: Maxime Coquelin --- lib/vhost/socket.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/vhost/socket.c b/lib/vhost/socket.c index 863a6f6d52..669c322e12 100644 --- a/lib/vhost/socket.c +++ b/lib/vhost/socket.c @@ -129,10 +129,12 @@ read_fd_message(char *ifname, int sockfd, char *buf, int buflen, int *fds, int m return ret; } - if (msgh.msg_flags & (MSG_TRUNC | MSG_CTRUNC)) { + if (msgh.msg_flags & MSG_TRUNC) VHOST_LOG_CONFIG(ifname, ERR, "truncated msg (fd %d)\n", sockfd); - return -1; - } + + /* MSG_CTRUNC may be caused by LSM misconfiguration */ + if (msgh.msg_flags & MSG_CTRUNC) + VHOST_LOG_CONFIG(ifname, ERR, "truncated control data (fd %d)\n", sockfd); for (cmsg = CMSG_FIRSTHDR(&msgh); cmsg != NULL; cmsg = CMSG_NXTHDR(&msgh, cmsg)) {