Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1300063

Re: [PATCH, RESEND] ipc/shm: handle removed segments gracefully in shm_mmap()

Path csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod
From Manfred Spraul <manfred@colorfullife.com>
Newsgroups linux.kernel
Subject Re: [PATCH, RESEND] ipc/shm: handle removed segments gracefully in shm_mmap()
Date Sat, 02 Jan 2016 12:50:02 +0100
Message-ID <qMsR4-7AW-19@gated-at.bofh.it> (permalink)
References <qtzq2-t6-15@gated-at.bofh.it> <qtH4e-5Cm-11@gated-at.bofh.it> <qtJIK-79T-21@gated-at.bofh.it> <quffA-2hL-3@gated-at.bofh.it> <quiGt-4vC-9@gated-at.bofh.it> <quscN-24Q-1@gated-at.bofh.it>
X-Original-To "Kirill A. Shutemov" <kirill@shutemov.name>, "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>, Andrew Morton <akpm@linux-foundation.org>, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Dmitry Vyukov <dvyukov@google.com>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=colorfullife-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type:content-transfer-encoding; bh=f4MWfu1ChLokT9n58YP2/DUBkX1HWGSpCOucX8uUhrA=; b=jPbkN/0xMHO5QZtC3QNi5nFUuW9PF/tJQ+E2cC2Wor+7VdTvoodvP12X/bRTerbYGi 067gXdUz0Sb0QBoDs1dgXaRmAbit0BtIiGG9bDJWoblPIMpIePxKcvv2gl7zApP32P/b z0JZsuVbsUAnS5u8IEtAdooomDid9Sr4XBdBzkmJe5P1F/5a8uAEI15c+alG/H29AggY smQE3KCqsYrvlUbcihxEwvNtAMQtiSpi0olNnYx1XhC356JF2JEZwSEWHeE2AxAi5DMh NX/CSG3j+5r9J7RvNd4GiQyyDoaGreR63pnGfymiCJPmq+w2ZHPT3C+OCd6oeDkWmgb7 gbRw==
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-type :content-transfer-encoding; bh=f4MWfu1ChLokT9n58YP2/DUBkX1HWGSpCOucX8uUhrA=; b=mALX6LGkfypJtcBuxwBRtUUgo36aFLgHvb0OqKAEOmrIclPLve3ElDk8RWnrcUXi+9 slIectt20zX9tt70t/TqxozBBAHM2BStdf2ebMtXVAf+tY7DhxZ/V2orvthCxC8tzc3+ gTaTWaA3mxQ9R4WGHChheg8BqkjiQiPzS0jNMfDfsXTZoPO4j73edtseQiUtLG7iv2DV Y8YoxgjRXCZzFoqwHF+Sc6jjRLw3jtkj7no8Df6CF86PJqWauYYeMnIV4scYhJcjqYJK /0CJraA7F0yWlEBbzjSKLA1CowY61i9uqfydBkHAtnKlHsA3CA+N+Xn6soQa9emOz/XN qU4g==
X-Gm-Message-State ALoCoQlmKGvdy9agUBRJCoytuXDtZ1W4FURqhxYepnC4meshuZ5Zr3HVeAseQ+riKQBQUWcTpaSehoZI+JXI32Ygdutno6TAAA==
X-Received by 10.194.114.34 with SMTP id jd2mr86706554wjb.12.1451735108715; Sat, 02 Jan 2016 03:45:08 -0800 (PST)
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0
MIME-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 38
Organization linux.* mail to news gateway
X-Original-Date Sat, 2 Jan 2016 12:45:07 +0100
X-Original-Message-ID <5687B843.2040804@colorfullife.com>
X-Original-References <1447232220-36879-1-git-send-email-kirill.shutemov@linux.intel.com> <20151111170347.GA3502@linux-uzut.site> <20151111195023.GA17310@node.shutemov.name> <20151113053137.GB3502@linux-uzut.site> <20151113091259.GB28904@node.shutemov.name> <20151113192310.GC3502@linux-uzut.site>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1300063

Show key headers only | View raw


On 11/13/2015 08:23 PM, Davidlohr Bueso wrote:
>
> So considering EINVAL, even your approach to bumping up nattach by 
> calling
> _shm_open earlier isn't enough. Races exposed to user called rmid can 
> still
> occur between dropping the lock and doing ->mmap(). Ultimately this 
> leads to
> all ipc_valid_object() checks, as we totally ignore SHM_DEST segments 
> nowadays
> since we forbid mapping previously removed segments.
>
> I think this is the first thing we must decide before going forward 
> with this
> mess. ipc currently defines invalid objects by merely checking the 
> deleted flag.
>
> Manfred, any thoughts?
>
With regards to locking: Sorry, shm is too different to msg/sem/mqueue.

With regards to EIDRM / EINVAL:
When all kernel memory was released, then the kernel cannot find out if 
the ID was valid at one time or not.
Thus EIDRM can only be a hint, the OS (kernel/libc) cannot guarantee 
that user space will never see something else.
(trivial example: user space sleeps just before the syscall)

So I would not create special code to optimize EIDRM handling for races. 
If we sometimes report EINVAL, it would be probably ok as well.

--
     Manfred
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH, RESEND] ipc/shm: handle removed segments gracefully in  shm_mmap() Manfred Spraul <manfred@colorfullife.com> - 2016-01-02 12:50 +0100
  Re: [PATCH, RESEND] ipc/shm: handle removed segments gracefully in  shm_mmap() "Kirill A. Shutemov" <kirill@shutemov.name> - 2016-01-04 15:20 +0100

csiph-web