iSCSI: don't crash when LUN ID >= 256
Resolves: RHEL-122858
This commit is contained in:
parent
90984c5d00
commit
c678f04796
91
0039-iSCSI-dont-crash-when-LUN-ID-256.patch
Normal file
91
0039-iSCSI-dont-crash-when-LUN-ID-256.patch
Normal file
@ -0,0 +1,91 @@
|
||||
From d232cb63fa964b2636e0cba38b23b31d29e6b93c Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Renaud=20M=C3=A9trich?= <rmetrich@redhat.com>
|
||||
Date: Fri, 17 Oct 2025 14:21:06 +0200
|
||||
Subject: [PATCH 1/2] iSCSI: don't crash when LUN ID >= 256
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
When LUN ID >= 256, systemd udev function format_lun_number() generates
|
||||
an address of the form "lun-0x...".
|
||||
Due to this, using int(lun) fails with a backtrace.
|
||||
|
||||
Signed-off-by: Renaud Métrich <rmetrich@redhat.com>
|
||||
|
||||
Resolves: RHEL-122858
|
||||
---
|
||||
blivet/devices/disk.py | 12 +++++++++++-
|
||||
1 file changed, 11 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/blivet/devices/disk.py b/blivet/devices/disk.py
|
||||
index d0976d584..bfebf37fa 100644
|
||||
--- a/blivet/devices/disk.py
|
||||
+++ b/blivet/devices/disk.py
|
||||
@@ -28,6 +28,7 @@
|
||||
from gi.repository import GLib
|
||||
|
||||
import os
|
||||
+import re
|
||||
from collections import namedtuple
|
||||
|
||||
from .. import errors
|
||||
@@ -433,8 +434,17 @@ def __init__(self, device, **kwargs):
|
||||
self.offload = kwargs.pop("offload")
|
||||
name = kwargs.pop("name")
|
||||
self.target = kwargs.pop("target")
|
||||
+ lun = kwargs.pop("lun")
|
||||
try:
|
||||
- self.lun = int(kwargs.pop("lun"))
|
||||
+ self.lun = int(lun)
|
||||
+ except ValueError:
|
||||
+ # See systemd udev function format_lun_number()
|
||||
+ m = re.fullmatch('0x([0-9a-fA-F]{4})([0-9a-fA-F]{4})00000000', lun)
|
||||
+ if m is None:
|
||||
+ log.warning("Failed to extract hex from lun '%s'", lun)
|
||||
+ self.lun = None
|
||||
+ else:
|
||||
+ self.lun = int(m.group(1), 16) + (1 << 16) * int(m.group(2), 16)
|
||||
except TypeError as e:
|
||||
log.warning("Failed to set lun attribute of iscsi disk: %s", e)
|
||||
self.lun = None
|
||||
|
||||
From 033160f166130dd95a822277761da414692f65ed Mon Sep 17 00:00:00 2001
|
||||
From: Vojtech Trefny <vtrefny@redhat.com>
|
||||
Date: Mon, 20 Oct 2025 11:19:39 +0200
|
||||
Subject: [PATCH 2/2] tests: Add a simple test case for parsing iSCSI lun
|
||||
|
||||
Related: RHEL-122858
|
||||
---
|
||||
tests/unit_tests/devices_test/disk_test.py | 15 ++++++++++++++-
|
||||
1 file changed, 14 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/tests/unit_tests/devices_test/disk_test.py b/tests/unit_tests/devices_test/disk_test.py
|
||||
index cc8454e14..f6e033728 100644
|
||||
--- a/tests/unit_tests/devices_test/disk_test.py
|
||||
+++ b/tests/unit_tests/devices_test/disk_test.py
|
||||
@@ -5,7 +5,7 @@
|
||||
from mock import patch
|
||||
import unittest
|
||||
|
||||
-from blivet.devices import DiskDevice
|
||||
+from blivet.devices import DiskDevice, iScsiDiskDevice
|
||||
from blivet.devicelibs import disk as disklib
|
||||
from blivet.devicelibs import raid
|
||||
from blivet.size import Size
|
||||
@@ -51,3 +51,16 @@ def test_disk_raid_properties(self):
|
||||
self.assertIsNone(test3.raid_level)
|
||||
self.assertIsNone(test3.raid_stripe_size)
|
||||
self.assertIsNone(test3.raid_disk_count)
|
||||
+
|
||||
+
|
||||
+class iScsiDiskDeviceTestCase(unittest.TestCase):
|
||||
+ def test_iscsi_lun(self):
|
||||
+ kwargs = {"node": "", "ibft": "", "nic": "", "initiator": "",
|
||||
+ "offload": False, "name": "", "target": "",
|
||||
+ "address": "", "port": "", "iface": "", "id_path": ""}
|
||||
+
|
||||
+ disk1 = iScsiDiskDevice("test1", lun="1", **kwargs)
|
||||
+ self.assertEqual(disk1.lun, 1)
|
||||
+
|
||||
+ disk2 = iScsiDiskDevice("test1", lun="0x0101000000000000", **kwargs)
|
||||
+ self.assertEqual(disk2.lun, 257)
|
||||
@ -23,7 +23,7 @@ Version: 3.6.0
|
||||
|
||||
#%%global prerelease .b2
|
||||
# prerelease, if defined, should be something like .a1, .b1, .b2.dev1, or .c2
|
||||
Release: 28%{?prerelease}%{?dist}
|
||||
Release: 29%{?prerelease}%{?dist}
|
||||
Epoch: 1
|
||||
License: LGPLv2+
|
||||
%global realname blivet
|
||||
@ -68,6 +68,7 @@ Patch34: 0035-LVMPV-format-size-fix.patch
|
||||
Patch35: 0036-Make-ActionDestroyFormat-optional.patch
|
||||
Patch36: 0037-Wipe-end-partition-before-creating-it-as-well-as-the-start.patch
|
||||
Patch37: 0038-Add-a-pre-wipe-fixup-function-for-LVM-logical-volume.patch
|
||||
Patch38: 0039-iSCSI-dont-crash-when-LUN-ID-256.patch
|
||||
|
||||
# Versions of required components (done so we make sure the buildrequires
|
||||
# match the requires versions of things).
|
||||
@ -231,6 +232,10 @@ configuration.
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Mon Nov 03 2025 Vojtech Trefny <vtrefny@redhat.com> - 3.6.0-29
|
||||
- iSCSI: don't crash when LUN ID >= 256
|
||||
Resolves: RHEL-122858
|
||||
|
||||
* Mon Aug 04 2025 Vojtech Trefny <vtrefny@redhat.com> - 3.6.0-28
|
||||
- Add a pre-wipe fixup function for LVM logical volumes
|
||||
Resolves: RHEL-68368
|
||||
|
||||
Loading…
Reference in New Issue
Block a user