Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 670910

Summary: fence_scsi: need stricter regular expression when looking for specific keys
Product: Red Hat Enterprise Linux 6 Reporter: Ryan O'Hara <rohara>
Component: fence-agentsAssignee: Ryan O'Hara <rohara>
Status: CLOSED ERRATA QA Contact: Cluster QE <mspqa-list>
Severity: high Docs Contact:
Priority: low    
Version: 6.1CC: cluster-maint, djansa, fdinitto
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: fence-agents-3.0.12-13.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-05-19 14:21:53 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Fix regular expression used to grep for specific registration keys. none

Description Ryan O'Hara 2011-01-19 16:33:30 UTC
In fence_scsi, there are a handful of places where it will look to see if a specific key is registered for a device. Currently the code looks like this:

my @keys = grep { /$node_key/ } get_registration_keys ($dev);

This line of code will get all keys registered with a specific device and filter (grep) for the key we are interested in. The code typically then checks to see if @keys is empty. The problem is with the regular expression used for grep. It needs to be more specific to avoid false positives.

An example:

# register key "11" with device /dev/sdb
% /usr/sbin/fence_scsi -o on -k 11 -d /dev/sdb

# list keys register with device /dev/sdb
sg_persist -i -k /dev/sdb
  DELL      MD3000            0617
  Peripheral device type: disk
  PR generation=0x20, 2 registered reservation keys follow:
    0x11

# check to see if key "11" is registered with /dev/sdb
% /usr/sbin/fence_scsi -o status -k 11 -d /dev/sdb; echo $?
0 <-- correct

# check to see if key "2" is registered with /dev/sdb
% /usr/sbin/fence_scsi -o status -k 2 -d /dev/sdb; echo $?
2 <-- correct

# check to see if key "1" is registered with /dev/sdb
 /usr/sbin/fence_scsi -o status -k 1 -d /dev/sdb; echo $?
0 <-- incorrect

In this example, fence_scsi is incorrectly reporting that key "1" is registered with /dev/sdb because the regular expression is not specific. This fix is simple -- use anchors to make the regular expression more specific:

my @keys = grep { /^$node_key$/ } get_registration_keys ($dev);

Comment 2 Ryan O'Hara 2011-01-19 17:06:07 UTC
Created attachment 474324 [details]
Fix regular expression used to grep for specific registration keys.

Patch to fix problem described above.

Comment 3 Ryan O'Hara 2011-01-19 17:08:55 UTC
Here is test of fence_scsi with patch:

# register key "11" with device /dev/sdb
% ./fence_scsi -o on -k 11 -d /dev/sdb

# list keys register with device /dev/sdb
sg_persist -i -k /dev/sdb
  DELL      MD3000            0617
  Peripheral device type: disk
  PR generation=0x20, 2 registered reservation keys follow:
    0x11

# check to see if key "11" is registered with /dev/sdb
% ./fence_scsi -o status -k 11 -d /dev/sdb; echo $?
0 <-- correct

# check to see if key "2" is registered with /dev/sdb
% ./fence_scsi -o status -k 2 -d /dev/sdb; echo $?
2 <-- correct

# check to see if key "1" is registered with /dev/sdb
% ./fence_scsi -o status -k 1 -d /dev/sdb; echo $?
2 <-- correct

Comment 4 Ryan O'Hara 2011-01-21 18:42:26 UTC
Pushed to RHEL6 branch.

commit cecc4a5fd1e3f494d6f7cf2eeded1a5b77336336

Comment 6 Dean Jansa 2011-03-29 16:10:24 UTC
[root@marathon-05 sbin]# ./fence_scsi -o on -k 11 -d /dev/sdb
Mar 29 11:08:25 fence_scsi: [debug] main::do_register_ignore (node_key=11, dev=/dev/sdb)
Mar 29 11:08:25 fence_scsi: [debug] main::do_reset (dev=/dev/sdb, status=0)
[root@marathon-05 sbin]# sg_persist -i -k /dev/sdb
  WINSYS    SA3478            347C
  Peripheral device type: disk
  PR generation=0x62, 1 registered reservation key follows:
    0x11
[root@marathon-05 sbin]# ./fence_scsi -o status -k 11 -d /dev/sdb; echo $?
Mar 29 11:08:38 fence_scsi: [debug] main::do_reset (dev=/dev/sdb, status=0)
0
[root@marathon-05 sbin]# ./fence_scsi -o status -k 2 -d /dev/sdb; echo $?
Mar 29 11:08:45 fence_scsi: [debug] main::do_reset (dev=/dev/sdb, status=0)
2
[root@marathon-05 sbin]# ./fence_scsi -o status -k 1 -d /dev/sdb; echo $?
Mar 29 11:08:51 fence_scsi: [debug] main::do_reset (dev=/dev/sdb, status=0)
2


Verified in fence-agents-3.0.12-21.el6

Comment 7 errata-xmlrpc 2011-05-19 14:21:53 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-0745.html