From: Stoiko Ivanov <s.ivanov@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH storage 1/2] LIO: untaint values read from remote config
Date: Mon, 12 Oct 2020 17:34:57 +0200 [thread overview]
Message-ID: <20201012153458.18685-2-s.ivanov@proxmox.com> (raw)
In-Reply-To: <20201012153458.18685-1-s.ivanov@proxmox.com>
The LIO backend for ZFS over iSCSI fetches the json-config periodically from
the target.
This patch reduces the stored config values to those which are actually used
and additonally untaints the values read from the remote host's config-file.
Since the LUN index is used in calls to targetcli on the remote host (via
run_command), untainting prevents the call to crash when run with '-T'.
Tested by creating a zfs over iscsi backed VM, starting it, adding disks,
resizing disks, removing disks, creating snapshots, rolling back to a snapshot.
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
PVE/Storage/LunCmd/LIO.pm | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/PVE/Storage/LunCmd/LIO.pm b/PVE/Storage/LunCmd/LIO.pm
index 15ddabf..f9e7143 100644
--- a/PVE/Storage/LunCmd/LIO.pm
+++ b/PVE/Storage/LunCmd/LIO.pm
@@ -154,8 +154,22 @@ my $parser = sub {
# find correct TPG
foreach my $tpg (@{$target->{tpgs}}) {
if ($tpg->{tag} == $tpg_tag) {
+ my $res = [];
+ foreach my $lun (@{$tpg->{luns}}) {
+ my ($idx, $storage_object);
+ if ($lun->{index} =~ /^(\d+)$/) {
+ $idx = $1;
+ }
+ if ($lun->{storage_object} =~ m|^($BACKSTORE/.*)$|) {
+ $storage_object = $1;
+ }
+ die "Invalid lun definition in config!\n"
+ if !(defined($idx) && defined($storage_object));
+ push @$res, { index => $idx, storage_object => $storage_object };
+ }
+
my $id = "$scfg->{portal}.$scfg->{target}";
- $SETTINGS->{$id} = $tpg;
+ $SETTINGS->{$id}->{luns} = $res;
$haveTarget = 1;
last;
}
--
2.20.1
next prev parent reply other threads:[~2020-10-12 15:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-12 15:34 [pve-devel] [PATCH storage 0/2] LIO: fix tainted config and minor cleanup Stoiko Ivanov
2020-10-12 15:34 ` Stoiko Ivanov [this message]
2020-10-12 15:34 ` [pve-devel] [PATCH storage 2/2] LIO: drop unused statements Stoiko Ivanov
2020-10-12 16:37 ` [pve-devel] [PATCH storage 0/2] LIO: fix tainted config and minor cleanup Daniel Berteaud
2020-10-13 9:15 ` [pve-devel] applied-series: " Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201012153458.18685-2-s.ivanov@proxmox.com \
--to=s.ivanov@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox