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 920032 - hypervkvpd segfault when cgred is running
Summary: hypervkvpd segfault when cgred is running
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: hypervkvpd
Version: 6.5
Hardware: Unspecified
OS: Unspecified
medium
unspecified
Target Milestone: rc
: ---
Assignee: Tomáš Hozza
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-03-11 08:28 UTC by jason wang
Modified: 2013-11-21 04:51 UTC (History)
8 users (show)

Fixed In Version: hypervkvpd-0-0.10.el6
Doc Type: Bug Fix
Doc Text:
Cause: Previously hypervkvpd registered to two NetLink multicast groups and one of them was group used by 'cgred'. Consequence: When hypervkvpd received a NetLink message (from cgred) it interpreted it blindly as its own. This caused hypervkvpd to segfault. Fix: Hypervkvpd now registers only to its own NetLink multicast group and checks type of incoming NetLink message. Result: Hypervkvpd does not segfault any more when 'cgred' is running.
Clone Of:
Environment:
Last Closed: 2013-11-21 04:51:38 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2013:1539 0 normal SHIPPED_LIVE hypervkvpd bug fix update 2013-11-20 21:40:49 UTC

Description jason wang 2013-03-11 08:28:35 UTC
Description of problem:

From vaughan <vaughan.cao@xxxxxxxxxx>

I guess I found a bug -- hypervkvpd running alone without hv_utils
loaded encounters segfault when service cgred start on RHEL6.4. It
occurs with both 0.8 and 0.9, regardless of i686 or x86_64.

I read in hv_kvp_daemon.c that the user mode componet should first
registers with the kernel component.
But in my test, the hand shake phase has been ignored.
Things happens like this:
hv_utils.ko and hv_vmbus.ko is not loaded, start hypervkvpd is fine.
Then, I start cgred with the default configuration. cgroup also use
NETLINK_CONNECTOR protocol and send messages with cb_id{1,1}. Hypervkvpd
receive messages without checking their source. Some messages with
cb_id{1,1} were receviced and blindly interpreted as hv_kvp_msg. Since
the hand_shake check is as below:
if ((in_hand_shake) && (op == KVP_OP_REGISTER1)) {
...
continue;
}
//handle kvp messages
switch (op) { ... }
Register phase is also skipped.
Everytime the KVP_OP_SET opcode is reached, kvp_key_add_or_modify() is
invoked with an very large key_size. After several iterations, segfault
occurs in memcpy(record[i].key, key, key_size) (key_size is negative now).

I'm not very familiar with connector. But I ran the sample in
Documentation/connector/ and found that a NETLINK_CONNECTOR socket would
always some messages with cb_id{1,1}. So blindly suppose all messages
are kvp_msg is not correct. hypervkvpd should check the source of
messages and perhaps even check nlmsg_type in the nlmsghdr.

Version-Release number of selected component (if applicable):


How reproducible:
100%

Steps to Reproduce:
1. modprobe -r hv_utils
2. service hypervkvp start
3. service cgred start
  
Actual results:
hypervkvpd segfault

Expected results:
should be normal

Additional info:
http://www.spinics.net/lists/linux-driver-devel/msg33453.html

Comment 1 Tomáš Hozza 2013-03-11 13:20:15 UTC
(In reply to comment #0)
> Description of problem:
> 
> From vaughan <vaughan.cao@xxxxxxxxxx>
> 
> I guess I found a bug -- hypervkvpd running alone without hv_utils
> loaded encounters segfault when service cgred start on RHEL6.4. It
> occurs with both 0.8 and 0.9, regardless of i686 or x86_64.
> 
> I read in hv_kvp_daemon.c that the user mode componet should first
> registers with the kernel component.
> But in my test, the hand shake phase has been ignored.
> Things happens like this:
> hv_utils.ko and hv_vmbus.ko is not loaded, start hypervkvpd is fine.
> Then, I start cgred with the default configuration. cgroup also use
> NETLINK_CONNECTOR protocol and send messages with cb_id{1,1}. Hypervkvpd
> receive messages without checking their source. Some messages with
> cb_id{1,1} were receviced and blindly interpreted as hv_kvp_msg.
> Since the hand_shake check is as below:
> if ((in_hand_shake) && (op == KVP_OP_REGISTER1)) {
> ...
> continue;
> }
> //handle kvp messages
> switch (op) { ... }
> Register phase is also skipped.
> Everytime the KVP_OP_SET opcode is reached, kvp_key_add_or_modify() is
> invoked with an very large key_size. After several iterations, segfault
> occurs in memcpy(record[i].key, key, key_size) (key_size is negative now).
> 
> I'm not very familiar with connector. But I ran the sample in
> Documentation/connector/ and found that a NETLINK_CONNECTOR socket would
> always some messages with cb_id{1,1}. So blindly suppose all messages
> are kvp_msg is not correct. hypervkvpd should check the source of
> messages and perhaps even check nlmsg_type in the nlmsghdr.

I did some testing. It doesn't matter if hv_utils is unloaded or not.
Handling of incoming NetLink messages is not very fortunate and should
be changed for sure.

The registration phase seems to be mandatory. Kernel part of the hyper-v kvp
functionality is depending on user-space daemon to register with it. What's
strange is that the kernel module registers with the daemon only for the first
time. If daemon is restarted, then the registration with kernel module is
never completed. I think this might have something to do with Bug #886781.

I have some ideas, but I need to test them first.

Comment 2 Tomáš Hozza 2013-03-13 13:24:08 UTC
The problem was in setting sockaddr_nl.nl_groups to CN_KVP_IDX of value "9".
Since nl_groups is a bit mask, hypervkvpd was getting Netlink messages also
from group number "1".

I changed sockaddr_nl.nl_groups to "0" (not subscribe to any multicast group)
and rather subscribe to CN_KVP_IDX group using setsockopt().

I also added check for nlmsg_type in received Netlink message header so now
daemon processes the message only if it's type is NLMSG_DONE. Otherwise the
message is ignored.

I tested the solution on Windows Server 2012 Guest with RHEL 6.4 Guest and
everything worked fine. Host was able to get information from Guest and
when starting/restarting cgred service for couple of times hypervkvpd kept
running just fine.

I sent patches to upstream:
http://driverdev.linuxdriverproject.org/pipermail/devel/2013-March/036284.html
http://driverdev.linuxdriverproject.org/pipermail/devel/2013-March/036285.html
http://driverdev.linuxdriverproject.org/pipermail/devel/2013-March/036286.html

Comment 4 Tomáš Hozza 2013-03-18 07:31:17 UTC
Patches were accepted by upstream.

Comment 19 lijing 2013-09-13 05:46:12 UTC
verify this bug in x86_64 and i386 guest, no segfault occur,  the kernel of which is 2.6.32-415.0.1.el6.x86_64/2.6.32-415.0.1.el6.i686 , the package of hypervkvpd is hypervkvpd-0-0.12.el6.x86_64/hypervkvpd-0-0.12.el6.i686

Comment 21 errata-xmlrpc 2013-11-21 04:51:38 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2013-1539.html


Note You need to log in before you can comment on or make changes to this bug.