提交 bc375ea7 编写于 作者: D David S. Miller

[SUNRPC]: Make sure on-stack cmsg buffer is properly aligned.

Based upon a report from Meelis Roos.
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 1d51c69f
...@@ -452,6 +452,8 @@ union svc_pktinfo_u { ...@@ -452,6 +452,8 @@ union svc_pktinfo_u {
struct in_pktinfo pkti; struct in_pktinfo pkti;
struct in6_pktinfo pkti6; struct in6_pktinfo pkti6;
}; };
#define SVC_PKTINFO_SPACE \
CMSG_SPACE(sizeof(union svc_pktinfo_u))
static void svc_set_cmsg_data(struct svc_rqst *rqstp, struct cmsghdr *cmh) static void svc_set_cmsg_data(struct svc_rqst *rqstp, struct cmsghdr *cmh)
{ {
...@@ -491,8 +493,11 @@ svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr) ...@@ -491,8 +493,11 @@ svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr)
struct svc_sock *svsk = rqstp->rq_sock; struct svc_sock *svsk = rqstp->rq_sock;
struct socket *sock = svsk->sk_sock; struct socket *sock = svsk->sk_sock;
int slen; int slen;
char buffer[CMSG_SPACE(sizeof(union svc_pktinfo_u))]; union {
struct cmsghdr *cmh = (struct cmsghdr *)buffer; struct cmsghdr hdr;
long all[SVC_PKTINFO_SPACE / sizeof(long)];
} buffer;
struct cmsghdr *cmh = &buffer.hdr;
int len = 0; int len = 0;
int result; int result;
int size; int size;
...@@ -745,8 +750,11 @@ svc_udp_recvfrom(struct svc_rqst *rqstp) ...@@ -745,8 +750,11 @@ svc_udp_recvfrom(struct svc_rqst *rqstp)
struct svc_sock *svsk = rqstp->rq_sock; struct svc_sock *svsk = rqstp->rq_sock;
struct svc_serv *serv = svsk->sk_server; struct svc_serv *serv = svsk->sk_server;
struct sk_buff *skb; struct sk_buff *skb;
char buffer[CMSG_SPACE(sizeof(union svc_pktinfo_u))]; union {
struct cmsghdr *cmh = (struct cmsghdr *)buffer; struct cmsghdr hdr;
long all[SVC_PKTINFO_SPACE / sizeof(long)];
} buffer;
struct cmsghdr *cmh = &buffer.hdr;
int err, len; int err, len;
struct msghdr msg = { struct msghdr msg = {
.msg_name = svc_addr(rqstp), .msg_name = svc_addr(rqstp),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册