From: Andrew Morton <akpm@linux-foundation.org>
To: Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com>
Cc: linux-kernel@vger.kernel.org, Milton Miller <miltonm@bga.com>,
Jack Miller <millerjo@us.ibm.com>,
Pavel Tikhomirov <ptikhomirov@virtuozzo.com>,
Alexander Mikhalitsyn <alexander@mihalicyn.com>,
Manfred Spraul <manfred@colorfullife.com>,
Davidlohr Bueso <dave@stgolabs.net>,
Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@suse.com>,
Vladimir Davydov <vdavydov.dev@gmail.com>,
"Eric W. Biederman" <ebiederm@xmission.com>
Subject: Re: [PATCH 0/2] shm: omit forced shm destroy if task IPC namespace was changed
Date: Fri, 9 Jul 2021 18:12:41 -0700 [thread overview]
Message-ID: <20210709181241.cca57cf83c52964b2cd0dcf0@linux-foundation.org> (raw)
In-Reply-To: <20210706132259.71740-1-alexander.mikhalitsyn@virtuozzo.com>
On Tue, 6 Jul 2021 16:22:57 +0300 Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com> wrote:
> Hello,
>
> Task IPC namespace shm's has shm_rmid_forced feature which is per IPC namespace
> and controlled by kernel.shm_rmid_forced sysctl. When feature is turned on,
> then during task exit (and unshare(CLONE_NEWIPC)) all sysvshm's will be destroyed
> by exit_shm(struct task_struct *task) function. But there is a problem if task
> was changed IPC namespace since shmget() call. In such situation exit_shm() function
> will try to call
> shm_destroy(<new_ipc_namespace_ptr>, <sysvshmem_from_old_ipc_namespace>)
> which leads to the situation when sysvshm object still attached to old
> IPC namespace but freed; later during old IPC namespace cleanup we will try to
> free such sysvshm object for the second time and will get the problem :)
>
> First patch solves this problem by postponing shm_destroy to the moment when
> IPC namespace cleanup will be called.
> Second patch is useful to prevent (or easy catch) such bugs in the future by
> adding corresponding WARNings.
>
(cc's added)
I assume that a
Fixes: b34a6b1da371ed8af ("ipc: introduce shm_rmid_forced sysctl") is
appropriate here?
A double-free is serious. Should this fix be backported into earlier
kernels?
next prev parent reply other threads:[~2021-07-10 1:12 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-06 13:22 Alexander Mikhalitsyn
2021-07-06 13:22 ` [PATCH 1/2] shm: skip shm_destroy " Alexander Mikhalitsyn
2021-07-06 13:22 ` [PATCH 2/2] ipc: WARN if trying to remove ipc object which is absent Alexander Mikhalitsyn
2021-07-10 1:12 ` Andrew Morton [this message]
2021-07-10 10:55 ` [PATCH 0/2] shm: omit forced shm destroy if task IPC namespace was changed Alexander Mihalicyn
[not found] ` <CALgW_8VUk0us_umLncUv2DUMkOi3qixmT+YkHV4Dhpt_nNMZHw@mail.gmail.com>
2021-07-11 10:33 ` Alexander Mihalicyn
2021-07-11 11:46 ` Manfred Spraul
2021-07-12 9:54 ` Alexander Mihalicyn
2021-07-12 19:18 ` Eric W. Biederman
2021-07-12 19:27 ` Alexander Mihalicyn
2021-07-14 17:30 ` [RFC PATCH] shm: extend forced shm destroy to support objects from several IPC nses Alexander Mikhalitsyn
2021-07-21 6:32 ` Manfred Spraul
2021-07-22 18:46 ` Manfred Spraul
2021-07-30 14:52 ` Alexander Mihalicyn
2021-07-14 17:42 ` [PATCH 0/2] shm: omit forced shm destroy if task IPC namespace was changed Alexander Mihalicyn
2021-09-23 16:36 ` Manfred Spraul
2021-09-24 16:45 ` Eric W. Biederman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210709181241.cca57cf83c52964b2cd0dcf0@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=alexander.mikhalitsyn@virtuozzo.com \
--cc=alexander@mihalicyn.com \
--cc=dave@stgolabs.net \
--cc=ebiederm@xmission.com \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=manfred@colorfullife.com \
--cc=mhocko@suse.com \
--cc=millerjo@us.ibm.com \
--cc=miltonm@bga.com \
--cc=ptikhomirov@virtuozzo.com \
--cc=vdavydov.dev@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®