From nobody Tue May 7 01:29:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1615191284; cv=none; d=zohomail.com; s=zohoarc; b=fwFJPEsytmdirFCFCaGWTkyRDZxLPT4e+kSQ9xlB8AhHA+GMvV1jQw9HAnbxw7YhHPNMjCb9gXaufHQ+bT78dvUpp6twDcJei7nAtT39h2U1LpSklTaURihubryen1X6bX/8DpLfZed4ERuoewLXhW6WXOWdsfjv0w5EeCr7tVM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615191284; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=jNXekUoMPfBH7Bx4QyzL+CXhvIQFJjn1uJn2bxGqdUo=; b=gY5ZIjz2unLg32fSnwVz0mBELsEr8TZfiglsaxVcfDRx0oeFgMAz2zrseIdcRo8I2oRIdlk1V57B7ZqfsamSvsREYC+FjeYUDpb19bOUb/0XbrU8CSReCYa80UXDLKjoQrQz+j/xtOvrxkoqZtkp+WDCrhDw0TlKQ79c5xXdN8I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1615191284868116.13095906419073; Mon, 8 Mar 2021 00:14:44 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-504-2XIdue8TPL-aQovervfHQQ-1; Mon, 08 Mar 2021 03:14:41 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B269F26862; Mon, 8 Mar 2021 08:14:35 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9EF3619714; Mon, 8 Mar 2021 08:14:33 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9F6ED1809C86; Mon, 8 Mar 2021 08:14:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1288ER3n030452 for ; Mon, 8 Mar 2021 03:14:27 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8B0B86F98C; Mon, 8 Mar 2021 08:14:27 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F9286F987 for ; Mon, 8 Mar 2021 08:14:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615191283; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=jNXekUoMPfBH7Bx4QyzL+CXhvIQFJjn1uJn2bxGqdUo=; b=T0yQ4K3/iy0bNbLE9vgWUNmIRLQfY3mHTnQF7qwOLn4H6SMPvYGgAxYBMkAeda1m1J6quO CX+0o6R2OgP0OMbiEp06PWFFIWxAZ+/ltRcG+yclFS7cLc7xxJjc1vFXSjCXEYrZIft9fj Jo/xxQfREUQuxbiYUiEMqJpPtTqKetw= X-MC-Unique: 2XIdue8TPL-aQovervfHQQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] virDevMapperGetTargetsImpl: Use correct length when copying into dm.name Date: Mon, 8 Mar 2021 09:14:18 +0100 Message-Id: <1383e1173a51200c7ef5750c773b51fbef8f3ade.1615191258.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" For reasons unknown, when rewriting this code and dropping libdevmapper I've mistakenly used incorrect length of dm.name. In linux/dm-ioctl.h the dm_ioctl struct is defined as follows: #define DM_NAME_LEN 128 struct dm_ioctl { ... char name[DM_NAME_LEN]; /* device name */ ... }; However, when copying string into this member, DM_TABLE_DEPS was used, which is defined as follows: #define DM_TABLE_DEPS _IOWR(DM_IOCTL, DM_TABLE_DEPS_CMD, struct dm_ioc= tl) After decryption, this results in the following size: 3241737483. Fixes: 22494556542c676d1b9e7f1c1f2ea13ac17e1e3e Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/util/virdevmapper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virdevmapper.c b/src/util/virdevmapper.c index fcb11e954f..2c4c2df999 100644 --- a/src/util/virdevmapper.c +++ b/src/util/virdevmapper.c @@ -240,7 +240,7 @@ virDevMapperGetTargetsImpl(int controlFD, if (!(sanitizedPath =3D virDMSanitizepath(path))) return 0; =20 - if (virStrcpy(dm.name, sanitizedPath, DM_TABLE_DEPS) < 0) { + if (virStrcpy(dm.name, sanitizedPath, DM_NAME_LEN) < 0) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("Resolved device mapper name too long")); return -1; --=20 2.26.2