NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/53666: tcpdump for i386 does not work with COMPAT_NETBSD32 on amd64



>Number:         53666
>Category:       kern
>Synopsis:       tcpdump for i386 does not work with COMPAT_NETBSD32 on amd64
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Oct 11 14:10:00 +0000 2018
>Originator:     Rin Okuyama
>Release:        8.99.25
>Organization:
School of Science and Technology, Meiji University
>Environment:
NetBSD latipes 8.99.25 NetBSD 8.99.25 (AMD64) #21: Thu Sep 13 19:27:53 JST 2018  rin@latipes:/var/build/src/sys/arch/amd64/compile/AMD64 amd64
>Description:
tcpdump compiled for i386 does not work with COMPAT_NETBSD32 on amd64.
>How-To-Repeat:
# uname -p
x86_64
# /somewhere/netbsd32/usr/bin/tcpdump
tcpdump: BIOCSRTIMEOUT: Invalid argument
#
>Fix:
This is because argument for BIOCSRTIMEOUT ioctl for bpf(4),
struct timeval *, is not appropriately converted. Note that this
problem does not affect for architectures that have 8-byte
alignment for int64 on 32-bit environment, i.e., struct timeval
and netbsd32_timeval coincide.

This patch fixes the problem:

http://www.netbsd.org/~rin/netbsd32_ioctl_20181011.patch

----
Index: sys/compat/netbsd32/netbsd32_ioctl.c
===================================================================
RCS file: /home/netbsd/src/sys/compat/netbsd32/netbsd32_ioctl.c,v
retrieving revision 1.95
diff -p -u -r1.95 netbsd32_ioctl.c
--- sys/compat/netbsd32/netbsd32_ioctl.c	24 Sep 2018 21:15:39 -0000	1.95
+++ sys/compat/netbsd32/netbsd32_ioctl.c	11 Oct 2018 12:16:35 -0000
@@ -1388,6 +1388,12 @@ netbsd32_ioctl(struct lwp *l, const stru
 		IOCTL_STRUCT_CONV_TO(BIOCSUDPF, bpf_program);
 	case BIOCGDLTLIST32:
 		IOCTL_STRUCT_CONV_TO(BIOCGDLTLIST, bpf_dltlist);
+	case BIOCSRTIMEOUT32:
+#define netbsd32_to_timeval(p, s32p, cmd) netbsd32_to_timeval(p, s32p)
+#define netbsd32_from_timeval(p, s32p, cmd) netbsd32_from_timeval(p, s32p)
+		IOCTL_STRUCT_CONV_TO(BIOCSRTIMEOUT, timeval);
+#undef netbsd32_to_timeval
+#undef netbsd32_from_timeval
 
 	case WSDISPLAYIO_ADDSCREEN32:
 		IOCTL_STRUCT_CONV_TO(WSDISPLAYIO_ADDSCREEN, wsdisplay_addscreendata);
Index: sys/compat/netbsd32/netbsd32_ioctl.h
===================================================================
RCS file: /home/netbsd/src/sys/compat/netbsd32/netbsd32_ioctl.h,v
retrieving revision 1.63
diff -p -u -r1.63 netbsd32_ioctl.h
--- sys/compat/netbsd32/netbsd32_ioctl.h	24 Sep 2018 21:15:39 -0000	1.63
+++ sys/compat/netbsd32/netbsd32_ioctl.h	11 Oct 2018 12:00:06 -0000
@@ -116,6 +116,7 @@ struct netbsd32_bpf_dltlist {
 #define BIOCSTCPF32	_IOW('B',114, struct netbsd32_bpf_program)
 #define BIOCSUDPF32	_IOW('B',115, struct netbsd32_bpf_program)
 #define BIOCGDLTLIST32	_IOWR('B',119, struct netbsd32_bpf_dltlist)
+#define BIOCSRTIMEOUT32	_IOW('B',122, struct netbsd32_timeval)
 
 
 struct netbsd32_wsdisplay_addscreendata {
----

In the patch, I need preprocessor hacks in order to get along with
IOCTL_STRUCT_CONV_TO() macro in netbsd32_ioctl.h:

https://nxr.netbsd.org/xref/src/sys/compat/netbsd32/netbsd32_ioctl.h#41



Home | Main Index | Thread Index | Old Index