Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2998670imm; Sun, 1 Jul 2018 10:01:21 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIMqGsh9rWEOTA+R/yaVs5IV0/I1WbpUCVBQ2zsucmx1pSxGdTV8YwHe/TxtHWr/9JH+R6M X-Received: by 2002:a17:902:1e4:: with SMTP id b91-v6mr22749999plb.155.1530464481106; Sun, 01 Jul 2018 10:01:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530464481; cv=none; d=google.com; s=arc-20160816; b=0AwAEbM5uT+Gew0dxL39F0l7kBxUco7enzxAWwD9thnFLiHy7fmsf6jIFe2IOPML3Y NC0Gh52+fyZCEu822kYns8dYrFikS3iQ3aTlJGxJb/jB+ef841ROkmGh5c+YU8pN5tVc 5azcCZrXyzIh9ls0g6YdKnAq/sPNpF+Mo1Vldci3JwVPDSj3g3cVojGIBF/WaWitGG7F rtkfQsKhviXooVNb0v4cGyseSOQwJU+yVK5SsCEXqpT3kxsGxRsJBM/sQAzAWiVryJFV INsyTxKYPGTOCzWHF91mBpJxyFc3yVPFLyWb/vFk7ryzpJGFXNTrP7wRS2CqQ5UkidNJ JjqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Nct22DARR6F2dxyk1sBxR/ysKvoKhP+v6G/ME07/q5I=; b=GLWoIHod5IoFhH+1PUwpoMg3G8Q12nSewcdv3755/0ylYdD92nQTmZW2PnGj125yLq r1kwOVJJiZ/gAHp/pXt2syv1gER8kJv+umv4fcAuMjt5uJzaC0PewLXhHp8SQncEpMwN GT1S5Upq8LG8l02PYdetOfkCJku0vEhzuOXRWw+pIcqG1HvuvVbwWKK1TGkVRut6SjaH CbZ1LUgj7BHYM37dPeROkQx3vpoJAtivrj3Cypgh3AlYA8GbM9Vvf6dbDR6G1kLmSijN 3Y+UvQBjvoIoUKmADQbmQrGOxPpnj2X04X+l3L/TG+o5LGeP+Sp8/VxiXr5AVsCcVVvQ HlFw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y20-v6si13996509pfm.186.2018.07.01.10.01.06; Sun, 01 Jul 2018 10:01:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934082AbeGARAD (ORCPT + 99 others); Sun, 1 Jul 2018 13:00:03 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:37924 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032415AbeGAQnw (ORCPT ); Sun, 1 Jul 2018 12:43:52 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id D8087ACC; Sun, 1 Jul 2018 16:43:51 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Capenter , Anton Ivanov , Richard Weinberger Subject: [PATCH 4.17 160/220] um: Fix initialization of vector queues Date: Sun, 1 Jul 2018 18:23:04 +0200 Message-Id: <20180701160914.962882744@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160908.272447118@linuxfoundation.org> References: <20180701160908.272447118@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.17-stable review patch. If anyone has any objections, please let me know. ------------------ From: Anton Ivanov commit 4579a1ba692af81da7ea6ce197f8169ddc0c327f upstream. UML vector drivers could derefence uninitialized memory when cleaning up after a queue allocation failure. Fixes: 49da7e64f33e ("High Performance UML Vector Network Driver") Cc: Reported-by: Dan Capenter Signed-off-by: Anton Ivanov Signed-off-by: Richard Weinberger Signed-off-by: Greg Kroah-Hartman --- arch/um/drivers/vector_kern.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) --- a/arch/um/drivers/vector_kern.c +++ b/arch/um/drivers/vector_kern.c @@ -504,15 +504,19 @@ static struct vector_queue *create_queue result = kmalloc(sizeof(struct vector_queue), GFP_KERNEL); if (result == NULL) - goto out_fail; + return NULL; result->max_depth = max_size; result->dev = vp->dev; result->mmsg_vector = kmalloc( (sizeof(struct mmsghdr) * max_size), GFP_KERNEL); + if (result->mmsg_vector == NULL) + goto out_mmsg_fail; result->skbuff_vector = kmalloc( (sizeof(void *) * max_size), GFP_KERNEL); - if (result->mmsg_vector == NULL || result->skbuff_vector == NULL) - goto out_fail; + if (result->skbuff_vector == NULL) + goto out_skb_fail; + + /* further failures can be handled safely by destroy_queue*/ mmsg_vector = result->mmsg_vector; for (i = 0; i < max_size; i++) { @@ -563,6 +567,11 @@ static struct vector_queue *create_queue result->head = 0; result->tail = 0; return result; +out_skb_fail: + kfree(result->mmsg_vector); +out_mmsg_fail: + kfree(result); + return NULL; out_fail: destroy_queue(result); return NULL;