NetBSD Problem Report #22360

Received: (qmail 8079 invoked by uid 605); 5 Aug 2003 10:05:30 -0000
Message-Id: <200308051005.h75A5Q729439@hiram.ics.muni.cz>
Date: Tue, 5 Aug 2003 12:05:26 +0200 (CEST)
From: ljocha@ics.muni.cz
Sender: gnats-bugs-owner@NetBSD.org
Reply-To: ljocha@ics.muni.cz
To: gnats-bugs@gnats.netbsd.org
Subject: broken linux ftruncate64()
X-Send-Pr-Version: 3.95

>Number:         22360
>Category:       kern
>Synopsis:       linux ftruncate64() is broken due to bad arg alignment
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    jdolecek
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Aug 05 10:06:00 +0000 2003
>Closed-Date:    Sun Aug 10 20:18:31 +0000 2003
>Last-Modified:  Tue May 11 14:32:00 +0000 2004
>Originator:     Ales Krenek
>Release:        NetBSD 1.6.1
>Organization:
Masaryk University
>Environment:
System: NetBSD balkis.ics.muni.cz 1.6.1 NetBSD 1.6.1 (BALKIS) #4: Mon Aug 4 20:59:20 CEST 2003 ljocha@balkis.ics.muni.cz:/usr/src/sys/arch/i386/compile/BALKIS i386
Architecture: i386
Machine: i386
>Description:
The call used to return just EFBIG, apparently because linux does not align the `length' arg to 64b boundary

Most likely the problem also applies to -current, as well as other archs.
>How-To-Repeat:
any linux binary calling ftruncate64()
>Fix:
--- compat/linux/arch/i386/syscalls.master.orig	Mon Aug  4 20:31:41 2003
+++ compat/linux/arch/i386/syscalls.master	Mon Aug  4 20:34:07 2003
@@ -329,7 +329,7 @@
 			    linux_off_t offset); }
 193	STD		{ int linux_sys_truncate64(const char *path, \
 			    off_t length); }
-194	NOARGS		linux_ftruncate64 { int sys_ftruncate(int fd, \
+194	STD		{ int linux_sys_ftruncate64(int fd, \
 			    off_t length); }
 195	STD		{ int linux_sys_stat64(const char *path, \
 			    struct linux_stat64 *sp); }
--- compat/linux/common/linux_file64.c.ljocha	Mon Aug  4 20:17:30 2003
+++ compat/linux/common/linux_file64.c	Mon Aug  4 20:59:02 2003
@@ -231,6 +231,22 @@
 	return sys_truncate(p, uap, retval);
 }

+int
+linux_sys_ftruncate64(p, v, retval)
+	struct proc *p;
+	void *v;
+	register_t *retval;
+{
+	struct linux_sys_ftruncate64_args *uap = v;
+	struct sys_ftruncate_args	fta;
+
+	SCARG(&fta,fd) = SCARG(uap,fd);
+	SCARG(&fta,length) = SCARG(uap,length);
+
+	return sys_ftruncate(p,&fta,retval);
+}
+
+
 #if !defined(__m68k__)
 static void bsd_to_linux_flock64 __P((struct linux_flock64 *,
     const struct flock *));
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: kern-bug-people->jdolecek 
Responsible-Changed-By: jdolecek 
Responsible-Changed-When: Tue Aug 5 11:12:10 UTC 2003 
Responsible-Changed-Why:  
I'll look on this one. 
State-Changed-From-To: open->analyzed 
State-Changed-By: jdolecek 
State-Changed-When: Sat Aug 9 12:41:40 UTC 2003 
State-Changed-Why:  
Problem happens because NetBSD truncate(2) syscall has actually 
three arguments, not two - there is 'int pad' between 'fd' 
and 'length' parameter. The linux syscall has only two arguments, 
so the compat code used some random register value instead of correct 
number. 
I'll commit proposed patch later. 

From: Jaromir Dolecek <jdolecek@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:  
Subject: pr/22360 CVS commit: src/sys/compat/linux
Date: Sun, 10 Aug 2003 20:16:29 +0000 (UTC)

 Module Name:	src
 Committed By:	jdolecek
 Date:		Sun Aug 10 20:16:28 UTC 2003

 Modified Files:
 	src/sys/compat/linux/arch/arm: syscalls.master
 	src/sys/compat/linux/arch/i386: syscalls.master
 	src/sys/compat/linux/arch/m68k: syscalls.master
 	src/sys/compat/linux/arch/mips: syscalls.master
 	src/sys/compat/linux/arch/powerpc: syscalls.master
 	src/sys/compat/linux/common: linux_file64.c

 Log Message:
 add Linux compat arg wrapper for ftruncate64(), and change linux compat
 truncate64() wrapper to translate args structure
 NetBSD truncate() and ftrucate() have hidden 'pad' argument, so we have
 to do the argument translation

 Problem found and patch supplied in PR kern/22360 by Ales Krenek

 This is the last of syscalls with hidden 'pad' arg we didn't have
 wrapper for; all the others (lseek, mmap, pwrite, pread) already had
 wrapper before.


 To generate a diff of this commit:
 cvs rdiff -r1.14 -r1.15 src/sys/compat/linux/arch/arm/syscalls.master
 cvs rdiff -r1.66 -r1.67 src/sys/compat/linux/arch/i386/syscalls.master
 cvs rdiff -r1.42 -r1.43 src/sys/compat/linux/arch/m68k/syscalls.master
 cvs rdiff -r1.11 -r1.12 src/sys/compat/linux/arch/mips/syscalls.master
 cvs rdiff -r1.15 -r1.16 src/sys/compat/linux/arch/powerpc/syscalls.master
 cvs rdiff -r1.21 -r1.22 src/sys/compat/linux/common/linux_file64.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: analyzed->closed 
State-Changed-By: jdolecek 
State-Changed-When: Sun Aug 10 20:18:08 UTC 2003 
State-Changed-Why:  
Proposed fix committed. Thanks for report and the fix. 

From: Matthias Scheler <tron@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:  
Subject: pr/22360 CVS commit: [netbsd-1-6] src/sys/compat/linux/arch/powerpc
Date: Tue, 11 May 2004 14:30:27 +0000 (UTC)

 Module Name:	src
 Committed By:	tron
 Date:		Tue May 11 14:30:27 UTC 2004

 Modified Files:
 	src/sys/compat/linux/arch/powerpc [netbsd-1-6]: syscalls.master

 Log Message:
 Pull up revision 1.16 via patch (requested by wennmach in ticket #1686):
 add Linux compat arg wrapper for ftruncate64(), and change linux compat
 truncate64() wrapper to translate args structure
 NetBSD truncate() and ftrucate() have hidden 'pad' argument, so we have
 to do the argument translation
 Problem found and patch supplied in PR kern/22360 by Ales Krenek
 This is the last of syscalls with hidden 'pad' arg we didn't have
 wrapper for; all the others (lseek, mmap, pwrite, pread) already had
 wrapper before.


 To generate a diff of this commit:
 cvs rdiff -r1.13.2.1 -r1.13.2.2 \
     src/sys/compat/linux/arch/powerpc/syscalls.master

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.


From: Matthias Scheler <tron@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:  
Subject: pr/22360 CVS commit: [netbsd-1-6] src/sys/compat/linux/arch/m68k
Date: Tue, 11 May 2004 14:30:33 +0000 (UTC)

 Module Name:	src
 Committed By:	tron
 Date:		Tue May 11 14:30:33 UTC 2004

 Modified Files:
 	src/sys/compat/linux/arch/m68k [netbsd-1-6]: syscalls.master

 Log Message:
 Pull up revision 1.43 via patch (requested by wennmach in ticket #1686):
 add Linux compat arg wrapper for ftruncate64(), and change linux compat
 truncate64() wrapper to translate args structure
 NetBSD truncate() and ftrucate() have hidden 'pad' argument, so we have
 to do the argument translation
 Problem found and patch supplied in PR kern/22360 by Ales Krenek
 This is the last of syscalls with hidden 'pad' arg we didn't have
 wrapper for; all the others (lseek, mmap, pwrite, pread) already had
 wrapper before.


 To generate a diff of this commit:
 cvs rdiff -r1.39.4.2 -r1.39.4.3 \
     src/sys/compat/linux/arch/m68k/syscalls.master

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.


From: Matthias Scheler <tron@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:  
Subject: pr/22360 CVS commit: [netbsd-1-6] src/sys/compat/linux/arch/i386
Date: Tue, 11 May 2004 14:30:38 +0000 (UTC)

 Module Name:	src
 Committed By:	tron
 Date:		Tue May 11 14:30:38 UTC 2004

 Modified Files:
 	src/sys/compat/linux/arch/i386 [netbsd-1-6]: syscalls.master

 Log Message:
 Pull up revision 1.67 via patch (requested by wennmach in ticket #1686):
 add Linux compat arg wrapper for ftruncate64(), and change linux compat
 truncate64() wrapper to translate args structure
 NetBSD truncate() and ftrucate() have hidden 'pad' argument, so we have
 to do the argument translation
 Problem found and patch supplied in PR kern/22360 by Ales Krenek
 This is the last of syscalls with hidden 'pad' arg we didn't have
 wrapper for; all the others (lseek, mmap, pwrite, pread) already had
 wrapper before.


 To generate a diff of this commit:
 cvs rdiff -r1.63.4.1 -r1.63.4.2 \
     src/sys/compat/linux/arch/i386/syscalls.master

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.


From: Matthias Scheler <tron@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:  
Subject: pr/22360 CVS commit: [netbsd-1-6] src/sys/compat/linux/arch/mips
Date: Tue, 11 May 2004 14:30:44 +0000 (UTC)

 Module Name:	src
 Committed By:	tron
 Date:		Tue May 11 14:30:44 UTC 2004

 Modified Files:
 	src/sys/compat/linux/arch/mips [netbsd-1-6]: syscalls.master

 Log Message:
 Pull up revision 1.12 via patch (requested by wennmach in ticket #1686):
 add Linux compat arg wrapper for ftruncate64(), and change linux compat
 truncate64() wrapper to translate args structure
 NetBSD truncate() and ftrucate() have hidden 'pad' argument, so we have
 to do the argument translation
 Problem found and patch supplied in PR kern/22360 by Ales Krenek
 This is the last of syscalls with hidden 'pad' arg we didn't have
 wrapper for; all the others (lseek, mmap, pwrite, pread) already had
 wrapper before.


 To generate a diff of this commit:
 cvs rdiff -r1.9.4.1 -r1.9.4.2 src/sys/compat/linux/arch/mips/syscalls.master

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.


From: Matthias Scheler <tron@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:  
Subject: pr/22360 CVS commit: [netbsd-1-6] src/sys/compat/linux/common
Date: Tue, 11 May 2004 14:30:50 +0000 (UTC)

 Module Name:	src
 Committed By:	tron
 Date:		Tue May 11 14:30:50 UTC 2004

 Modified Files:
 	src/sys/compat/linux/common [netbsd-1-6]: linux_file64.c

 Log Message:
 Pull up revision 1.22 via patch (requested by wennmach in ticket #1686):
 add Linux compat arg wrapper for ftruncate64(), and change linux compat
 truncate64() wrapper to translate args structure
 NetBSD truncate() and ftrucate() have hidden 'pad' argument, so we have
 to do the argument translation
 Problem found and patch supplied in PR kern/22360 by Ales Krenek
 This is the last of syscalls with hidden 'pad' arg we didn't have
 wrapper for; all the others (lseek, mmap, pwrite, pread) already had
 wrapper before.


 To generate a diff of this commit:
 cvs rdiff -r1.18 -r1.18.2.1 src/sys/compat/linux/common/linux_file64.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.


From: Matthias Scheler <tron@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:  
Subject: pr/22360 CVS commit: [netbsd-1-6] src/sys/compat/linux/arch/arm
Date: Tue, 11 May 2004 14:30:57 +0000 (UTC)

 Module Name:	src
 Committed By:	tron
 Date:		Tue May 11 14:30:57 UTC 2004

 Modified Files:
 	src/sys/compat/linux/arch/arm [netbsd-1-6]: syscalls.master

 Log Message:
 Pull up revision 1.15 via patch (requested by wennmach in ticket #1686):
 add Linux compat arg wrapper for ftruncate64(), and change linux compat
 truncate64() wrapper to translate args structure
 NetBSD truncate() and ftrucate() have hidden 'pad' argument, so we have
 to do the argument translation
 Problem found and patch supplied in PR kern/22360 by Ales Krenek
 This is the last of syscalls with hidden 'pad' arg we didn't have
 wrapper for; all the others (lseek, mmap, pwrite, pread) already had
 wrapper before.


 To generate a diff of this commit:
 cvs rdiff -r1.11.4.2 -r1.11.4.3 src/sys/compat/linux/arch/arm/syscalls.master

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.