mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Michael Kerrisk" <mtk-lkml@gmx.net>
To: Hugh Dickins <hugh@veritas.com>
Cc: riel@redhat.com, chrisw@osdl.org, manfred@colorfullife.com,
	torvalds@osdl.org, akpm@osdl.org, michael.kerrisk@gmx.net,
	linux-kernel@vger.kernel.org
Subject: Re: Further shmctl() SHM_LOCK strangeness
Date: Thu, 25 Nov 2004 09:45:44 +0100 (MET)	[thread overview]
Message-ID: <5639.1101372344@www65.gmx.net> (raw)
In-Reply-To: <Pine.LNX.4.44.0411242124400.2769-100000@localhost.localdomain>

Hugh,

> On Wed, 24 Nov 2004, Michael Kerrisk wrote:
> > 
> > While studying the RLIMIT_MEMLOCK stuff further, I came 
> > up with another observation: a process can perform a
> > shmctl(SHM_LOCK) on *any* System V shared memory segment, 
> > regardles of the segment's ownership or permissions,
> > providing the size of the segment falls within the 
> > process's RLIMIT_MEMLOCK limit.
> 
> That's a very good observation.

Thanks.

> I think it's unintended, but I'm not sure.
> I've forgotten what can_do_mlock on shm was about.

can_do_mlock() returns true if we have CAP_IPC_LOCK 
or RLIMIT_MEMLOCK != 0.

> Offhand I find it hard to grasp whether it's harmless or bad,
> but inclined to think bad - if there happen to be lots of small
> enough shared memory segments on the system, a series of processes
> run by one unprivileged user can lock down lots of memory?
> 
> Isn't it further the case that any process can now SHM_UNLOCK
> any segment?  

I hadn't got as far as thinking about that, but you are 
correct. Anyone can SHM_UNLOCK a System V shared memory 
segment on 2.6.9, regardless of ownership and permissions.

> That would surely be wrong.

Agreed.  

Cheers,

Michael

> I've added Rik and Chris to the CC list, they seem to be the
> main can_do_mlock guys, hope they can answer.
> 
> Hugh
> 
> > Is this intended behaviour?  For most other System V IPC 
> > "ctl" operations the process must either:
> > 
> > 1. be the owner of the object or have an appropriate 
> >    capability, or
> > 
> > 2. have suitable permissions on the object.
> > 
> > Which of these two conditions applies depends on the
> > "ctl" operation.
> 

-- 
Geschenkt: 3 Monate GMX ProMail + 3 Top-Spielfilme auf DVD
++ Jetzt kostenlos testen http://www.gmx.net/de/go/mail ++

      parent reply	other threads:[~2004-11-25  8:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-23 16:36 [PATCH 2.6.10-rc2] RLIMIT_MEMLOCK accounting of shmctl() SHM_LOCK is broken Michael Kerrisk
2004-11-23 17:04 ` Andrew Morton
2004-11-23 17:55   ` Michael Kerrisk
2004-11-23 18:31   ` Hugh Dickins
2004-11-24 20:14   ` Further shmctl() SHM_LOCK strangeness Michael Kerrisk
2004-11-24 21:41     ` Hugh Dickins
2004-11-25  3:17       ` Rik van Riel
2004-11-25  8:50         ` Michael Kerrisk
2004-11-25 11:40           ` Rik van Riel
2004-11-25 12:45             ` Michael Kerrisk
2004-11-25 14:42               ` Rik van Riel
2004-11-25 16:30                 ` Michael Kerrisk
2004-11-25  8:45       ` Michael Kerrisk [this message]

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=5639.1101372344@www65.gmx.net \
    --to=mtk-lkml@gmx.net \
    --cc=akpm@osdl.org \
    --cc=chrisw@osdl.org \
    --cc=hugh@veritas.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manfred@colorfullife.com \
    --cc=michael.kerrisk@gmx.net \
    --cc=riel@redhat.com \
    --cc=torvalds@osdl.org \
    /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®