From patchwork Wed Jan 31 22:59:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bethany Jamison X-Patchwork-Id: 1893673 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TQHYG4XS2z23gx for ; Thu, 1 Feb 2024 09:59:45 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1rVJYM-0000dK-5d; Wed, 31 Jan 2024 22:59:34 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1rVJYH-0000cj-66 for kernel-team@lists.ubuntu.com; Wed, 31 Jan 2024 22:59:29 +0000 Received: from mail-io1-f72.google.com (mail-io1-f72.google.com [209.85.166.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id EFF713F10B for ; Wed, 31 Jan 2024 22:59:28 +0000 (UTC) Received: by mail-io1-f72.google.com with SMTP id ca18e2360f4ac-7bf863c324dso80515139f.0 for ; Wed, 31 Jan 2024 14:59:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706741967; x=1707346767; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+kGQ/D+J5FUuryEDH3RZc4dWnS8oykzcV0yl749fvcg=; b=jy6FotaFpd7kB12fe2BOoZyWzK2mtAqJRCJYOq70NMHoVcCh+wyaSS0P0e+RxQoCDt m8d11zONO0y2qThYMBXvJsAW//yQpNA/KTzYT71xSGmNzl8UPB6BVbYreGaiX2KoWiRr tcg8vY6Bq/9MIcsBpsQx6DDYycV60W+NrsojqbriIBCrGT28QxOYBPgt/uOVttOr6GAN i6TqaGOQ0xggqpO9trF9dGVppftuM88ZyERMa3KD+Lkt5xw9+GXK58EdYMzDSUeyqMl+ 5hp9xzZkWL10Ht9wza3e0OlrQR06UuCv6/dIhY2nhwjcSkel968h6TTKCj7Ux/E4S6+D 3Tbw== X-Gm-Message-State: AOJu0YzklFQKe87r6ZlPVvNObplULySH95+fjfxU7A3p/upUrtzpxNK0 ciHPuhl51qXguff2cbbv5SD8772aoQX8sHlvC1KZ7j0tU1PN6necw5/dCfPd/BIrLwy1S/4rP6d APl8gze6zo+zZAbgVn5fC9qo7SRImXJB4PbI8+tEHYehQLj87AdDFAkK53yeT7f8VMMf3D8ZNAM 7Nz3coKUCQiA== X-Received: by 2002:a05:6602:131d:b0:7c0:18f4:8919 with SMTP id h29-20020a056602131d00b007c018f48919mr2889408iov.6.1706741967666; Wed, 31 Jan 2024 14:59:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IH8KJPwss8yxyxQ/d2tIdeehmdhXKUpC9H9o7o+4inggTQyGphu11yR3n+UEDelM1MH+xTUcg== X-Received: by 2002:a05:6602:131d:b0:7c0:18f4:8919 with SMTP id h29-20020a056602131d00b007c018f48919mr2889403iov.6.1706741967390; Wed, 31 Jan 2024 14:59:27 -0800 (PST) Received: from smtp.gmail.com (104-218-69-129.dynamic.lnk.ne.allofiber.net. [104.218.69.129]) by smtp.gmail.com with ESMTPSA id r17-20020a056638131100b00470faabba39sm138725jad.133.2024.01.31.14.59.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 14:59:27 -0800 (PST) From: Bethany Jamison To: kernel-team@lists.ubuntu.com Subject: [SRU][Jammy][Focal][PATCH 1/1] vhost: use kzalloc() instead of kmalloc() followed by memset() Date: Wed, 31 Jan 2024 16:59:25 -0600 Message-Id: <20240131225925.47013-2-bethany.jamison@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240131225925.47013-1-bethany.jamison@canonical.com> References: <20240131225925.47013-1-bethany.jamison@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Prathu Baronia Use kzalloc() to allocate new zeroed out msg node instead of memsetting a node allocated with kmalloc(). Signed-off-by: Prathu Baronia Message-Id: <20230522085019.42914-1-prathubaronia2011@gmail.com> Signed-off-by: Michael S. Tsirkin Reviewed-by: Stefano Garzarella (cherry picked from commit 4d8df0f5f79f747d75a7d356d9b9ea40a4e4c8a9) CVE-2023-0340 Signed-off-by: Bethany Jamison Acked-by: Timo Aaltonen --- drivers/vhost/vhost.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index bc14f1245a651..99cdd59f4e0c1 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -2582,12 +2582,11 @@ EXPORT_SYMBOL_GPL(vhost_disable_notify); /* Create a new message. */ struct vhost_msg_node *vhost_new_msg(struct vhost_virtqueue *vq, int type) { - struct vhost_msg_node *node = kmalloc(sizeof *node, GFP_KERNEL); + /* Make sure all padding within the structure is initialized. */ + struct vhost_msg_node *node = kzalloc(sizeof(*node), GFP_KERNEL); if (!node) return NULL; - /* Make sure all padding within the structure is initialized. */ - memset(&node->msg, 0, sizeof node->msg); node->vq = vq; node->msg.type = type; return node;