From nobody Sat May 30 15:28:59 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1780052601; cv=none; d=zohomail.com; s=zohoarc; b=c5zeCYtV12WcsPYpj78Rbf5+UM54GW0bqjhElNLPAnMSMyYSb79RbBPW31M+cWaQ40YNbakKz31ZSt8hQlNyOquVukr3R7PNZR6eLdghgSjOWzRLph/C93I8N/a9pd+rrW1KMshlG903J9nfbkECrLNXTej5C1AJkp0pLfrNNxA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780052601; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Subject:Subject:To:To:Message-Id; bh=XLLcpqetXNSCl+pzGrn8NF8qDYXKsEZ5b1Z7tG5v0Yc=; b=e52cYSPyBqerU5lzRXhiSAxEV94AJY/VPVvwp1AZXdHGmWN5pPP5YKCxUEioyDUpqe3f64FB/76jCQWKwFewLgf6pjwYpXgko7EIzayXeQsPKCNyZIaWKLxh5hkqyVzbYyPN6iIivpBIu9LwGvCkCuhifwtdzy3JkBG/r/ZFU8M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1780052601312354.245487744467; Fri, 29 May 2026 04:03:21 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 10C893F96F; Fri, 29 May 2026 07:03:20 -0400 (EDT) Received: from [172.19.199.4] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id E285C41AB1; Fri, 29 May 2026 07:02:29 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 401383F95D; Fri, 29 May 2026 07:02:21 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 8EDEC3F95F for ; Fri, 29 May 2026 07:02:19 -0400 (EDT) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-232-Y9lZ7ZWuOu6e869K9k6rHg-1; Fri, 29 May 2026 07:02:17 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BD9AA1956053 for ; Fri, 29 May 2026 11:02:16 +0000 (UTC) Received: from rsmigiel-thinkpadx1carbongen11-remote-csb.redhat.com (unknown [10.44.50.4]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9E75630001BB; Fri, 29 May 2026 11:02:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,SPF_HELO_PASS autolearn=no autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780052539; 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=XLLcpqetXNSCl+pzGrn8NF8qDYXKsEZ5b1Z7tG5v0Yc=; b=bkmLGKUnxV9pFKYIlXCq3pVWLmHLQh691tgYXcyL8CZO6359AfLWQbKHJVYBEcioh3rbzA FGugtdfolpCitgno4Sd8OYW+BvZZBxI014lUenCN6N0jr1SioJEIwxLFlbdZNAgpNdiyRK UyKi1scgQvTz63XI+EUecJiTR+rtSTY= X-MC-Unique: Y9lZ7ZWuOu6e869K9k6rHg-1 X-Mimecast-MFC-AGG-ID: Y9lZ7ZWuOu6e869K9k6rHg_1780052536 To: devel@lists.libvirt.org Subject: [PATCH] lxc: truncate LOOP_GET_STATUS64.lo_file_name for long loop backing paths Date: Fri, 29 May 2026 13:00:22 +0200 Message-ID: <20260529110210.507995-1-rsmigiel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: rCRkLoSoUfUALVok89K1QxFLrSoq4PeEF5ioJvXPQI8_1780052536 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: NSOQDVNLF4XP34KBOGEACJYBVRGDXHQD X-Message-ID-Hash: NSOQDVNLF4XP34KBOGEACJYBVRGDXHQD X-MailFrom: rsmigiel@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Radoslaw Smigielski X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Radoslaw Smigielski via Devel Reply-To: Radoslaw Smigielski X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1780052604674154100 Content-Type: text/plain; charset="utf-8"; x-default="true" LXC domains with long file-backed filesystem path fail to start when the backing image path is longer than LO_NAME_SIZE (64 bytes, 63 characters= plus NUL). When long file path is passed, virFileLoopDeviceAssociate() -> virStrcpy() = fails and user gets missleading error and domain fails to start. Example: To match losetup behavior we copy the path with virStrcpy() and allow trunc= ation of lo_file_name only if needed, while still calling open() on the unchanged= path. Finally log VIR_WARN when the path is expected to be truncated. But still r= eport VIR_ERR_INTERNAL_ERROR for all other virStrcpy() failures. Fixes: https://gitlab.com/libvirt/libvirt/-/work_items/63 Signed-off-by: Radoslaw Smigielski --- src/util/virfile.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index a0c6cb804862..ae33deb8d223 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -995,11 +995,18 @@ int virFileLoopDeviceAssociate(const char *file, =20 lo.lo_flags =3D LO_FLAGS_AUTOCLEAR; =20 - /* Set backing file name for LOOP_GET_STATUS64 queries */ + /* lo_file_name is loop device name, max length is LO_NAME_SIZE bytes. + * Truncate loop device name if file path is longer than LO_NAME_SIZE, + * and still use the full path to open backing file. */ if (virStrcpy((char *) lo.lo_file_name, file, LO_NAME_SIZE) < 0) { - virReportSystemError(errno, - _("Unable to set backing file %1$s"), file); - goto cleanup; + if (strlen(file) >=3D LO_NAME_SIZE) { + VIR_WARN("Loop backing device name %s truncated to %d bytes.", + file, LO_NAME_SIZE); + } else { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to set loop lo_file_name for %1$s"), = file); + goto cleanup; + } } =20 if ((fsfd =3D open(file, O_RDWR)) < 0) { --=20 2.54.0