Here's a patch that fixes the problem. I have only tested it on my
target (arm926ejs), so tests on other architectures would be
worthwhile. Hope this helps, and let me know if I can do anything
else.

-- Tyler

diff --git a/agent/mibgroup/ip-mib/data_access/defaultrouter_linux.c
b/agent/mibgroup/ip-mib/data_access/defaultrouter_linux.c
index 702128b..4cb5dd9 100644
--- a/agent/mibgroup/ip-mib/data_access/defaultrouter_linux.c
+++ b/agent/mibgroup/ip-mib/data_access/defaultrouter_linux.c
@@ -11,7 +11,7 @@

 #include "ip-mib/ipDefaultRouterTable/ipDefaultRouterTable.h"

-#include <asm/types.h>
+#include <stdint.h>
 #ifdef HAVE_LINUX_RTNETLINK_H
 #include <linux/netlink.h>
 #include <linux/rtnetlink.h>
@@ -93,9 +93,18 @@ _load(netsnmp_container *container)
     netsnmp_defaultrouter_entry *entry;
     int nlsk;
     struct sockaddr_nl addr;
-    unsigned char rcvbuf[RCVBUF_SIZE];
     int rcvbuf_size = RCVBUF_SIZE;
-    unsigned char sndbuf[SNDBUF_SIZE];
+
+    /* Buffers must be memory aligned. Message structure internal alignment is
+    * maintained by the netlink API. */
+    unsigned char rcvbufmem[RCVBUF_SIZE + sizeof(intmax_t)];
+    unsigned char *rcvbuf = rcvbufmem +
+        sizeof(intmax_t) - (((intptr_t)rcvbufmem) % sizeof(intmax_t));
+
+    unsigned char sndbufmem[SNDBUF_SIZE + sizeof(intmax_t)];
+    unsigned char *sndbuf = sndbufmem +
+        sizeof(intmax_t) - (((intptr_t)sndbufmem) % sizeof(intmax_t));
+
     struct nlmsghdr *hdr;
     struct rtmsg *rthdr;
     int count;


On Mon, Jun 11, 2012 at 8:46 PM, Magnus Fromreide <ma...@lysator.liu.se> wrote:
> On Mon, 2012-06-11 at 16:32 -0700, Tyler Olmstead wrote:
>> Hi all,
>>
>> I have cross-compiled net-snmp 5.7.1 for a custom port of Linux 2.6.37
>> on an armv5tejl core (AM1808). I have encountered some alignment traps
>> in syslog after MIB-walking.
>>
>> According to objdump, most of the traps seem to be triggered by an
>> unaligned access to stack memory in defaultrouter_linux.c:static int
>> _load(netsnmp_container *container). Has anyone else encountered this?
>> Is this a known issue or should I submit a patch?
>
> I have not heard of this before so a patch or enough information to let
> us debug this would be highly appreciated.
>
> /MF
>

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to