From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 728101FF13B for ; Wed, 03 Jun 2026 14:36:44 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id BA836AED8; Wed, 3 Jun 2026 14:36:42 +0200 (CEST) From: Filip Schauer To: pve-devel@lists.proxmox.com Subject: [PATCH container] fix #7667: prevent stale errno from breaking device passthrough Date: Wed, 3 Jun 2026 14:36:01 +0200 Message-ID: <20260603123603.109373-1-f.schauer@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1780490131292 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.012 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: 6IW5GWQHYOJ7LBLSSL25T6IWSMVZH2GZ X-Message-ID-Hash: 6IW5GWQHYOJ7LBLSSL25T6IWSMVZH2GZ X-MailFrom: f.schauer@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Since a successful stat() call does not reset $!, unconditionally checking it afterward can cause a false error when $! was set earlier. This causes device passthrough to always fail with "Device $path does not exist" for privileged containers with an ostype that doesn't have a matching config in /usr/share/lxc/config/.common.conf. Fix this by checking $! only when stat() actually fails. Also switch to the $!{ENOENT} syntax, allowing the POSIX ENOENT import to be dropped. Signed-off-by: Filip Schauer --- src/PVE/LXC/Tools.pm | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/PVE/LXC/Tools.pm b/src/PVE/LXC/Tools.pm index 40dd270..ce2467e 100644 --- a/src/PVE/LXC/Tools.pm +++ b/src/PVE/LXC/Tools.pm @@ -4,7 +4,7 @@ package PVE::LXC::Tools; use strict; use warnings; -use POSIX qw(ENOENT S_ISBLK S_ISCHR); +use POSIX qw(S_ISBLK S_ISCHR); use PVE::SafeSyslog; @@ -159,9 +159,8 @@ sub get_device_mode_and_rdev($) { die "Path is not defined\n" if !defined($path); - my ($mode, $rdev) = (stat($path))[2, 6]; - die "Device $path does not exist\n" if $! == ENOENT; - die "Error accessing device $path\n" if !defined($mode) || !defined($rdev); + my ($mode, $rdev) = (stat($path))[2, 6] + or die($!{ENOENT} ? "Device $path does not exist\n" : "Error accessing device $path: $!\n"); die "$path is not a device\n" if !S_ISBLK($mode) && !S_ISCHR($mode); return ($mode, $rdev); -- 2.47.3