kern/73778: linux emulation: semctl(IPC_STAT) has broken return
value
Andriy Gapon
avg at icyb.net.ua
Wed Nov 10 08:50:29 PST 2004
>Number: 73778
>Category: kern
>Synopsis: linux emulation: semctl(IPC_STAT) has broken return value
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Wed Nov 10 16:50:28 GMT 2004
>Closed-Date:
>Last-Modified:
>Originator: Andriy Gapon
>Release: FreeBSD 5.2.1-RELEASE-p11 i386
>Organization:
>Environment:
System:
FreeBSD 4.X, 5.X
>Description:
semctl with IPC_STAT command should return zero in case of success, see:
semctl(2)
http://www.opengroup.org/onlinepubs/009695399/functions/semctl.html
because of a bug in linux_semctl() a positive value is returned:
td_retval is assigned a value for both LINUX_IPC_STAT and LINUX_SEM_STAT
this breaks some linux applications with error check "semctl() != 0",
while applications with error check "semctl() < 0" remain happy.
among affected applications is IBM MQ / WEMPS.
>How-To-Repeat:
write a small test program or just look at the code
>Fix:
apply the following patch
--- ipc.patch begins here ---
--- /usr/src/sys/compat/linux/linux_ipc.c.orig Mon Nov 8 19:10:48 2004
+++ /usr/src/sys/compat/linux/linux_ipc.c Tue Nov 9 20:00:56 2004
@@ -532,8 +532,11 @@
error = __semctl(td, &bsd_args);
if (error)
return error;
- td->td_retval[0] = IXSEQ_TO_IPCID(bsd_args.semid,
+ if(bsd_args.cmd == SEM_STAT)
+ td->td_retval[0] = IXSEQ_TO_IPCID(bsd_args.semid,
unptr->buf->sem_perm);
+ else
+ td->td_retval[0] = 0;
bsd_to_linux_semid_ds(unptr->buf, &linux_semid);
return (linux_semid_pushdown(args->cmd & LINUX_IPC_64,
&linux_semid, (caddr_t)args->arg.buf));
--- ipc.patch ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list