Skip to contentSkip to conversation

sys_sendmsg() alignment bug fix

PATCH Applied Alex Williamson 4 participants 6 messages Sep 26, 2005 – Sep 27, 2005

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

PATCH 1/1 sys_sendmsg() alignment bug fix

The patch below adds an alignment attribute to the buffer used in
sys_sendmsg(). This eliminates an unaligned access warning on ia64.

net/socket.c +3 -1
diff -r db9b9552a2b4 net/socket.c
@@ -1700,7 +1700,9 @@
 	struct socket *sock;
 	char address[MAX_SOCK_ADDR];
 	struct iovec iovstack[UIO_FASTIOV], *iov = iovstack;
-	unsigned char ctl[sizeof(struct cmsghdr) + 20];	/* 20 is size of ipv6_pktinfo */
+	unsigned char ctl[sizeof(struct cmsghdr) + 20]
+	                  __attribute__ ((aligned (sizeof(__kernel_size_t))));
+	                  /* 20 is size of ipv6_pktinfo */
 	unsigned char *ctl_buf = ctl;
 	struct msghdr msg_sys;
 	int err, ctl_len, iov_size, total_len;
#1 lore raw
Quoted 4 lines · Alex Williamson

The patch below adds an alignment attribute to the buffer used in
sys_sendmsg(). This eliminates an unaligned access warning on ia64.

Vaguely surprised that the compiler cannot be taught to do this.

Quoted 5 lines

diff -r db9b9552a2b4 net/socket.c

net/socket.c line 1708

Quoted 10 lines
net/socket.c +3 -1
@@ -1700,7 +1700,9 @@
 	struct socket *sock;
 	char address[MAX_SOCK_ADDR];
 	struct iovec iovstack[UIO_FASTIOV], *iov = iovstack;
-	unsigned char ctl[sizeof(struct cmsghdr) + 20];	/* 20 is size of ipv6_pktinfo */
+	unsigned char ctl[sizeof(struct cmsghdr) + 20]
+	                  __attribute__ ((aligned (sizeof(__kernel_size_t))));
+	                  /* 20 is size of ipv6_pktinfo */
 	unsigned char *ctl_buf = ctl;
 	struct msghdr msg_sys;
 	int err, ctl_len, iov_size, total_len;

OK, thanks - I'll send this on to davem. It seems odd to be using __kernel_size_t rather than size_t, but that's what struct cmshdr does (also oddly).

maintainer Applied
#2 lore raw

From: Andrew Morton <[email protected]>
Date: Mon, 26 Sep 2005 13:36:34 -0700

Quoted 3 lines

OK, thanks - I'll send this on to davem. It seems odd to be using __kernel_size_t rather than size_t, but that's what struct cmshdr does (also oddly).

Applied, thanks.

#4 lore raw
Quoted 5 lines · Coywolf Qi Hunt
Quoted 2 lines · Alex Williamson

The patch below adds an alignment attribute to the buffer used in
sys_sendmsg(). This eliminates an unaligned access warning on ia64.

Is this a warning fix or bug fix?

Guess I'd have to classify it as a warning fix. ia64 is fairly
verbose about unaligned accesses by default, so the warning is printed out runtime.

Alex

maintainer
#5 lore raw
In reply to Coywolf Qi Hunt

From: Coywolf Qi Hunt <[email protected]>
Date: Tue, 27 Sep 2005 11:40:38 +0800

Quoted 5 lines · Alex Williamson
Quoted 2 lines

The patch below adds an alignment attribute to the buffer used in
sys_sendmsg(). This eliminates an unaligned access warning on ia64.

Is this a warning fix or bug fix?

It doesn't generate a warning, but it does generate totally unnecessary unaligned access traps on RISC systems.