NetBSD Problem Report #4083
Received: (qmail 3134 invoked from network); 5 Sep 1997 01:16:31 -0000
Message-Id: <199709042349.BAA00624@lyssa.owl.de>
Date: Fri, 5 Sep 1997 01:49:25 +0200 (MEST)
From: Matthias Scheler <tron@lyssa.owl.de>
Reply-To: tron@lyssa.owl.de
To: gnats-bugs@gnats.netbsd.org
Subject: Linux emulation of fcntl(...,F_GETLK,...) is broken
X-Send-Pr-Version: 3.95
>Number: 4083
>Category: port-i386
>Synopsis: Linux emulation of fcntl(...,F_GETLK,...) is broken
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: gnats-admin
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Sep 04 18:20:02 +0000 1997
>Closed-Date: Fri Sep 05 01:51:36 +0000 1997
>Last-Modified: Fri Sep 05 01:52:59 +0000 1997
>Originator: Matthias Scheler
>Release: 970829
>Organization:
Matthias Scheler http://home.owl.de/~tron/
>Environment:
System: NetBSD lyssa 1.2G NetBSD 1.2G (LYSSA) #3: Fri Sep 5 01:37:32 MEST 1997 tron@lyssa:/usr/src/sys/arch/i386/compile/LYSSA i386
>Description:
Because the Linux emulation of fcntl(...,F_GETLK,...) handles its arguments
incorrectly the call to NetBSD's fcntl() syscall will fail with EINVAL.
>How-To-Repeat:
Try to save a file with "swriter3" from the StarOffice 3.1 package.
>Fix:
*** src/sys/compat/linux/linux_file.c.old Fri Aug 29 11:49:43 1997
--- src/sys/compat/linux/linux_file.c Fri Sep 5 01:36:19 1997
*************** linux_sys_fcntl(p, v, retval)
*** 345,360 ****
return sys_fcntl(p, &fca, retval);
case LINUX_F_GETLK:
sg = stackgap_init(p->p_emul);
bfp = (struct flock *) stackgap_alloc(&sg, sizeof *bfp);
SCARG(&fca, fd) = fd;
SCARG(&fca, cmd) = F_GETLK;
SCARG(&fca, arg) = bfp;
! if ((error = sys_fcntl(p, &fca, retval)))
return error;
! if ((error = copyin(bfp, &bfl, sizeof bfl)))
return error;
bsd_to_linux_flock(&bfl, &lfl);
! return copyout(&lfl, arg, sizeof lfl);
break;
case LINUX_F_SETLK:
case LINUX_F_SETLKW:
--- 345,375 ----
return sys_fcntl(p, &fca, retval);
case LINUX_F_GETLK:
sg = stackgap_init(p->p_emul);
+ if ((error = copyin(arg, &lfl, sizeof lfl))) {
+ printf("Fail copyin: %d\n",error);
+ return error;
+ }
+ linux_to_bsd_flock(&lfl, &bfl);
bfp = (struct flock *) stackgap_alloc(&sg, sizeof *bfp);
SCARG(&fca, fd) = fd;
SCARG(&fca, cmd) = F_GETLK;
SCARG(&fca, arg) = bfp;
! if ((error = copyout(&bfl, bfp, sizeof bfl))) {
! printf("Fail copyout: %d\n",error);
! return error;
! }
! if ((error = sys_fcntl(p, &fca, retval))) {
! printf("Fail sys_fcntl: %d\n",error);
return error;
! }
! if ((error = copyin(bfp, &bfl, sizeof bfl))) {
! printf("Fail copyin: %d\n",error);
return error;
+ }
bsd_to_linux_flock(&bfl, &lfl);
! if ((error = copyout(&lfl, arg, sizeof lfl)))
! printf("Fail copyout: %d\n",error);
! return error;
break;
case LINUX_F_SETLK:
case LINUX_F_SETLKW:
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed
State-Changed-By: kleink
State-Changed-When: Thu Sep 4 18:51:36 PDT 1997
State-Changed-Why:
Fixed; stripped off debug printf()s and cleaned up.
>Unformatted:
(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.