From owner-freebsd-bugs@FreeBSD.ORG Wed Nov 10 16:50:29 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 01BD716A4CE for ; Wed, 10 Nov 2004 16:50:29 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id C3C6C43D48 for ; Wed, 10 Nov 2004 16:50:28 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.11/8.12.11) with ESMTP id iAAGoSqo087046 for ; Wed, 10 Nov 2004 16:50:28 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id iAAGoSb0087045; Wed, 10 Nov 2004 16:50:28 GMT (envelope-from gnats) Resent-Date: Wed, 10 Nov 2004 16:50:28 GMT Resent-Message-Id: <200411101650.iAAGoSb0087045@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Andriy Gapon Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8DA3116A4CE for ; Wed, 10 Nov 2004 16:46:30 +0000 (GMT) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2F2EF43D6E for ; Wed, 10 Nov 2004 16:46:29 +0000 (GMT) (envelope-from avg@oddity.topspin.kiev.ua) Received: from oddity.topspin.kiev.ua (oddity.topspin.kiev.ua [212.40.38.87]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id SAA07546 for ; Wed, 10 Nov 2004 18:46:27 +0200 (EET) (envelope-from avg@oddity.topspin.kiev.ua) Received: from oddity.topspin.kiev.ua (localhost [127.0.0.1]) iAAGkLpb018367 for ; Wed, 10 Nov 2004 18:46:27 +0200 (EET) (envelope-from avg@oddity.topspin.kiev.ua) Received: (from avg@localhost) by oddity.topspin.kiev.ua (8.12.10/8.12.10/Submit) id iAAGi8Mf018363; Wed, 10 Nov 2004 18:44:08 +0200 (EET) (envelope-from avg) Message-Id: <200411101644.iAAGi8Mf018363@oddity.topspin.kiev.ua> Date: Wed, 10 Nov 2004 18:44:08 +0200 (EET) From: Andriy Gapon To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: kern/73778: linux emulation: semctl(IPC_STAT) has broken return value X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Nov 2004 16:50:29 -0000 >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: