Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 7 May 2014 07:12:02 -0400 (EDT)
From:      Keith White <kwhite@uottawa.ca>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   arm/189415: [patch] mount_smbfs missing from arm
Message-ID:  <201405071112.s47BC2t6012681@localhost.my.domain>
Resent-Message-ID: <201405071140.s47Be0ip089122@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         189415
>Category:       arm
>Synopsis:       [patch] mount_smbfs missing from arm
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-arm
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed May 07 11:40:00 UTC 2014
>Closed-Date:
>Last-Modified:
>Originator:     Keith White
>Release:        FreeBSD 11.0-CURRENT arm
>Organization:
Faculty of Engineering, University of Ottawa
>Environment:
System: FreeBSD beaglebone 11.0-CURRENT FreeBSD 11.0-CURRENT #46 r265404M: Mon May 5 19:27:21 EDT 2014 root@beaglebone:/usr/obj/usr/src/sys/BEAGLEBONE arm

>Description:

mount_smbfs is not included with base arm builds since libsmb uses
casts to u_short that result in unaligned access to memory.

Patch attached.

>How-To-Repeat:

>Fix:

The following patch replaces potential unaligned access in libsmb
with a function call to the internal function memsetw(), and adds
libsmb and mount_smbfs to the base build.


Index: contrib/smbfs/lib/smb/nb_name.c
===================================================================
--- contrib/smbfs/lib/smb/nb_name.c	(revision 265468)
+++ contrib/smbfs/lib/smb/nb_name.c	(working copy)
@@ -146,14 +146,26 @@
 #define	NBENCODE(c)	(htole16((u_short)(((u_char)(c) >> 4) | \
 			 (((u_char)(c) & 0xf) << 8)) + 0x4141))
 
+#ifdef __arm__
 static void
 memsetw(char *dst, int n, u_short word)
 {
 	while (n--) {
+		((u_char*)dst)[0] = word & 0xff;
+		((u_char*)dst)[1] = word >> 8;
+		dst += 2;
+	}
+}
+#else
+static void
+memsetw(char *dst, int n, u_short word)
+{
+	while (n--) {
 		*(u_short*)dst = word;
 		dst += 2;
 	}
 }
+#endif
 
 int
 nb_name_encode(struct nb_name *np, u_char *dst)
@@ -165,18 +177,30 @@
 	*cp++ = NB_ENCNAMELEN;
 	name = np->nn_name;
 	if (name[0] == '*' && name[1] == 0) {
+#ifdef __arm__
+		memsetw(cp, 1, NBENCODE('*'));
+#else
 		*(u_short*)cp = NBENCODE('*');
+#endif
 		memsetw(cp + 2, NB_NAMELEN - 1, NBENCODE(' '));
 		cp += NB_ENCNAMELEN;
 	} else {
 		for (i = 0; *name && i < NB_NAMELEN - 1; i++, cp += 2, name++)
+#ifdef __arm__
+			memsetw(cp, 1, NBENCODE(toupper(*name)));
+#else
 			*(u_short*)cp = NBENCODE(toupper(*name));
+#endif
 		i = NB_NAMELEN - i - 1;
 		if (i > 0) {
 			memsetw(cp, i, NBENCODE(' '));
 			cp += i * 2;
 		}
+#ifdef __arm__
+		memsetw(cp, 1, NBENCODE(np->nn_type));
+#else
 		*(u_short*)cp = NBENCODE(np->nn_type);
+#endif
 		cp += 2;
 	}
 	*cp = 0;
Index: lib/Makefile
===================================================================
--- lib/Makefile	(revision 265468)
+++ lib/Makefile	(working copy)
@@ -217,6 +217,10 @@
 _libvmmapi=	libvmmapi
 .endif
 
+.if ${MACHINE_CPUARCH} == "arm"
+_libsmb=	libsmb
+.endif
+
 .if ${MACHINE_CPUARCH} == "ia64"
 _libefi=	libefi
 _libsmb=	libsmb
Index: usr.sbin/Makefile.arm
===================================================================
--- usr.sbin/Makefile.arm	(revision 265468)
+++ usr.sbin/Makefile.arm	(working copy)
@@ -2,3 +2,4 @@
 
 SUBDIR+=	ofwdump
 SUBDIR+=	kgmon
+SUBDIR+=	mount_smbfs

>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201405071112.s47BC2t6012681>