Skip to contentSkip to conversation

RDMA/core: Fix for parsing netlink string attribute

PATCH Applied Tatyana Nikolova 5 participants 5 messages May 8, 2015 – May 12, 2015 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RDMA/core: Fix for parsing netlink string attribute

The string iwpm_ulib_name is recorded in a nlmsg as a netlink attribute. Without this fix parsing of the nlmsg by the userspace port mapper service fails because of unknown attribute length, causing the port mapper service not to register the client, which has sent the nlmsg.

---
 drivers/infiniband/core/iwpm_msg.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/infiniband/core/iwpm_msg.c +1 -1
index b85ddbc..e5558b2 100644
@@ -33,7 +33,7 @@
 
 #include "iwpm_util.h"
 
-static const char iwpm_ulib_name[] = "iWarpPortMapperUser";
+static const char iwpm_ulib_name[IWPM_ULIBNAME_SIZE] = "iWarpPortMapperUser";
 static int iwpm_ulib_version = 3;
 static int iwpm_user_pid = IWPM_PID_UNDEFINED;
 static atomic_t echo_nlmsg_seq;
Signature · 1 line
1.7.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Tatyana Nikolova

The string iwpm_ulib_name is recorded in a nlmsg as a netlink attribute. Without this fix parsing of the nlmsg by the userspace port mapper service fails because of unknown attribute length, causing the port mapper service not to register the client, which has sent the nlmsg.

This actually will copy some kernel memory to userspace. I think the overflow is in .text, so probably not a security issue..

Jason

Applied
#2 lore raw
Quoted 10 lines · Jason Gunthorpe
Quoted 4 lines · Tatyana Nikolova

The string iwpm_ulib_name is recorded in a nlmsg as a netlink attribute. Without this fix parsing of the nlmsg by the userspace port mapper service fails because of unknown attribute length, causing the port mapper service not to register the client, which has sent the nlmsg.

This actually will copy some kernel memory to userspace. I think the overflow is in .text, so probably not a security issue..

It shouldn't be in the .text section. This is defined as static const char array, so it should be in one of the data sections. And since we are using an initializer smaller than the specific size of the array, I would expect all of the unitialized bits to be 0. But, the proof is in the pudding. A quick compile and check show us:

Contents of section .rodata:
...
01e0 69576172 70506f72 744d6170 70657255 iWarpPortMapperU 01f0 73657200 00000000 00000000 00000000 ser.............

Yep, just right. It created a 32byte ro element, initialized it to 0, then put our text in it. This is exactly what will get copied in the nl message and is precisely what we want.

Applied, thanks.

Signature · 2 lines
Doug Ledford <[email protected]>
              GPG KeyID: 0E572FDD

A message that is not in the archive (sent off-list or not yet received): 1431450866.43876.65.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#4 lore raw
Quoted 7 lines · Doug Ledford
Quoted 6 lines · Jason Gunthorpe
Quoted 4 lines · Tatyana Nikolova

The string iwpm_ulib_name is recorded in a nlmsg as a netlink attribute. Without this fix parsing of the nlmsg by the userspace port mapper service fails because of unknown attribute length, causing the port mapper service not to register the client, which has sent the nlmsg.

Quoted 6 lines
Quoted 4 lines

This actually will copy some kernel memory to userspace. I think the overflow is in .text, so probably not a security issue..

It shouldn't be in the .text section.

Pedantically, that is right, it is an archaic colloquialism to refer to the entire set of post-link read-only sections as .text. (typically the linker used to merge everything into .text)

I realize now I didn't consider modules when looking into this. No time right now, can you check if there is any chance the read can overflow past the page allocated to the module's .rodata?

Quoted 3 lines

char array, so it should be in one of the data sections. And since we are using an initializer smaller than the specific size of the array, I would expect all of the unitialized bits to be 0.

I was talking about the situation before the patch.

C defines a zero fill for incomplete initialization.

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20150512175033.GA15891-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org

#6 lore raw
Quoted 23 lines · Jason Gunthorpe
Quoted 7 lines · Doug Ledford
Quoted 6 lines · Jason Gunthorpe
Quoted 4 lines · Tatyana Nikolova

The string iwpm_ulib_name is recorded in a nlmsg as a netlink attribute. Without this fix parsing of the nlmsg by the userspace port mapper service fails because of unknown attribute length, causing the port mapper service not to register the client, which has sent the nlmsg.

Quoted 6 lines
Quoted 4 lines

This actually will copy some kernel memory to userspace. I think the overflow is in .text, so probably not a security issue..

It shouldn't be in the .text section.

Pedantically, that is right, it is an archaic colloquialism to refer to the entire set of post-link read-only sections as .text. (typically the linker used to merge everything into .text)

I realize now I didn't consider modules when looking into this. No time right now, can you check if there is any chance the read can overflow past the page allocated to the module's .rodata?

Quoted 5 lines
Quoted 3 lines

char array, so it should be in one of the data sections. And since we are using an initializer smaller than the specific size of the array, I would expect all of the unitialized bits to be 0.

I was talking about the situation before the patch.

Sorry, my misunderstanding.

Signature · 2 lines
Doug Ledford <[email protected]>
              GPG KeyID: 0E572FDD