Commit beeebc92 authored by Eric Van Hensbergen's avatar Eric Van Hensbergen Committed by David S. Miller

9p: fix endian issues [attempt 3]

When the changes were done to the protocol last release, some endian
bugs crept in.  This patch fixes those endian problems and has been
verified to run on 32/64 bit and x86/ppc architectures.

This version of the patch incorporates the correct annotations
for endian variables.
Signed-off-by: default avatarEric Van Hensbergen <ericvh@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b4bd07c2
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/types.h>
#include <net/9p/9p.h> #include <net/9p/9p.h>
#include <net/9p/client.h> #include <net/9p/client.h>
#include "protocol.h" #include "protocol.h"
...@@ -160,29 +161,32 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) ...@@ -160,29 +161,32 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
break; break;
case 'w':{ case 'w':{
int16_t *val = va_arg(ap, int16_t *); int16_t *val = va_arg(ap, int16_t *);
if (pdu_read(pdu, val, sizeof(*val))) { __le16 le_val;
if (pdu_read(pdu, &le_val, sizeof(le_val))) {
errcode = -EFAULT; errcode = -EFAULT;
break; break;
} }
*val = cpu_to_le16(*val); *val = le16_to_cpu(le_val);
} }
break; break;
case 'd':{ case 'd':{
int32_t *val = va_arg(ap, int32_t *); int32_t *val = va_arg(ap, int32_t *);
if (pdu_read(pdu, val, sizeof(*val))) { __le32 le_val;
if (pdu_read(pdu, &le_val, sizeof(le_val))) {
errcode = -EFAULT; errcode = -EFAULT;
break; break;
} }
*val = cpu_to_le32(*val); *val = le32_to_cpu(le_val);
} }
break; break;
case 'q':{ case 'q':{
int64_t *val = va_arg(ap, int64_t *); int64_t *val = va_arg(ap, int64_t *);
if (pdu_read(pdu, val, sizeof(*val))) { __le64 le_val;
if (pdu_read(pdu, &le_val, sizeof(le_val))) {
errcode = -EFAULT; errcode = -EFAULT;
break; break;
} }
*val = cpu_to_le64(*val); *val = le64_to_cpu(le_val);
} }
break; break;
case 's':{ case 's':{
...@@ -362,19 +366,19 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) ...@@ -362,19 +366,19 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
} }
break; break;
case 'w':{ case 'w':{
int16_t val = va_arg(ap, int); __le16 val = cpu_to_le16(va_arg(ap, int));
if (pdu_write(pdu, &val, sizeof(val))) if (pdu_write(pdu, &val, sizeof(val)))
errcode = -EFAULT; errcode = -EFAULT;
} }
break; break;
case 'd':{ case 'd':{
int32_t val = va_arg(ap, int32_t); __le32 val = cpu_to_le32(va_arg(ap, int32_t));
if (pdu_write(pdu, &val, sizeof(val))) if (pdu_write(pdu, &val, sizeof(val)))
errcode = -EFAULT; errcode = -EFAULT;
} }
break; break;
case 'q':{ case 'q':{
int64_t val = va_arg(ap, int64_t); __le64 val = cpu_to_le64(va_arg(ap, int64_t));
if (pdu_write(pdu, &val, sizeof(val))) if (pdu_write(pdu, &val, sizeof(val)))
errcode = -EFAULT; errcode = -EFAULT;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment