[dpdk-dev,1/4] vhost: Fix Coverity issue with possible array out-of-bounds read

Message ID 1449770240-103240-2-git-send-email-huawei.xie@intel.com (mailing list archive)
State Accepted, archived
Headers

Commit Message

Huawei@dpdk.org, Xie@dpdk.org Dec. 10, 2015, 5:57 p.m. UTC
  CID 107126 (#1 OF 1): Out-of-bounds read
Fixes: 8f972312b8f4 ("vhost: support vhost-user")

Signed-off-by: Huawei Xie <huawei.xie@intel.com>
---
 lib/librte_vhost/vhost_user/vhost-net-user.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

John McNamara Dec. 11, 2015, 2:48 p.m. UTC | #1
> -----Original Message-----
> From: Huawei Xie
> Sent: Thursday, December 10, 2015 5:57 PM
> To: dev@dpdk.org
> Cc: Mcnamara, John; Xie, Huawei
> Subject: [PATCH 1/4] vhost: Fix Coverity issue with possible array out-of-
> bounds read
> 
> CID 107126 (#1 OF 1): Out-of-bounds read
> Fixes: 8f972312b8f4 ("vhost: support vhost-user")
> 
> Signed-off-by: Huawei Xie <huawei.xie@intel.com>

Thanks. In future could you also update the Coverity Action to "Fix Submitted".
I'll do it this time for the ones I ack. 

Acked-by: John McNamara <john.mcnamara@intel.com>
  
Huawei Xie Dec. 11, 2015, 2:57 p.m. UTC | #2
On 12/11/2015 10:49 PM, Mcnamara, John wrote:
>> -----Original Message-----
>> From: Huawei Xie
>> Sent: Thursday, December 10, 2015 5:57 PM
>> To: dev@dpdk.org
>> Cc: Mcnamara, John; Xie, Huawei
>> Subject: [PATCH 1/4] vhost: Fix Coverity issue with possible array out-of-
>> bounds read
>>
>> CID 107126 (#1 OF 1): Out-of-bounds read
>> Fixes: 8f972312b8f4 ("vhost: support vhost-user")
>>
>> Signed-off-by: Huawei Xie <huawei.xie@intel.com>
> Thanks. In future could you also update the Coverity Action to "Fix Submitted".
> I'll do it this time for the ones I ack. 
Thanks John. I already planned to do this.
>
> Acked-by: John McNamara <john.mcnamara@intel.com>
>
>
  

Patch

diff --git a/lib/librte_vhost/vhost_user/vhost-net-user.c b/lib/librte_vhost/vhost_user/vhost-net-user.c
index 2dc0547..549f907 100644
--- a/lib/librte_vhost/vhost_user/vhost-net-user.c
+++ b/lib/librte_vhost/vhost_user/vhost-net-user.c
@@ -333,7 +333,7 @@  vserver_message_handler(int connfd, void *dat, int *remove)
 
 	ctx.fh = cfd_ctx->fh;
 	ret = read_vhost_message(connfd, &msg);
-	if (ret <= 0 || msg.request > VHOST_USER_MAX) {
+	if (ret <= 0 || msg.request >= VHOST_USER_MAX) {
 		if (ret < 0)
 			RTE_LOG(ERR, VHOST_CONFIG,
 				"vhost read message failed\n");