From owner-freebsd-hackers@freebsd.org Sat Aug 12 09:03:16 2017 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C7FAEDC7C0D for ; Sat, 12 Aug 2017 09:03:16 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4804D7E16F for ; Sat, 12 Aug 2017 09:03:16 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id v7C93AHs089394 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sat, 12 Aug 2017 12:03:10 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua v7C93AHs089394 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id v7C9392N089393; Sat, 12 Aug 2017 12:03:09 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 12 Aug 2017 12:03:09 +0300 From: Konstantin Belousov To: Yuri Cc: Freebsd hackers list Subject: Re: How can the shared memory object be undeletable when all shared memory segments belong to the same user? Message-ID: <20170812090308.GH1700@kib.kiev.ua> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.8.3 (2017-05-23) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Aug 2017 09:03:16 -0000 On Fri, Aug 11, 2017 at 09:58:52PM -0700, Yuri wrote: > I got this sequence of shm_* failures that I can't understand: > > 16151 scsynth CALL shm_unlink(0x803fdb3e0) > 16151 scsynth NAMI "/SuperColliderServer_57110" > 16151 scsynth RET shm_unlink -1 errno 13 Permission denied POSIX specifies that shm_unlink returns EACCES when Permission is denied to unlink the named shared memory object. Rationale for the shm_open() explains that actual interpretation of EACCES for shm_*(2) functions is implementation-defined. FreeBSD requires the caller euid to have read/write permissions to the shared memory segment for the unlink to be allowed. > ... > 16151 scsynth CALL > shm_open(0x803fdb3e0,0xa02,0644) > 16151 scsynth NAMI "/SuperColliderServer_57110" > 16151 scsynth RET shm_open -1 errno 17 File exists > ... > 16151 scsynth CALL > shm_open(0x803fdb3e0,0x2,0644) > 16151 scsynth NAMI "/SuperColliderServer_57110" > 16151 scsynth RET shm_open -1 errno 13 Permission denied > > > Deletion operation fails with EACCESS, creation operation fails with > EEXIST, opening operation fails with EACCESS again. So the object > exists, but this user can't delete or open it. Which is consistent with the euid not having read/write permissions on the segment. > At the same time, 'ipcs > -m' shows that all active segments belong to the same user. Failures are > persistent with application restarts. Why do you think that SysV IPC shared memory, which is displayed by ipcs(8) tool, has any relations to the POSIX shared memory ? > > > Only renaming of the shared memory object in the code or reboot helped. Root should be able to unlink it.