2004-01-01 08:16:40

by Neale Banks

[permalink] [raw]
Subject: Re: chmod of active swap file blocks

On Mon, 29 Dec 2003, Paul Jakma wrote:

[...]
> > Is chmod of an in-use swapfile an important thing to be able to do?
>
> Had a box under memory pressure and had to add a swapfile to relieve
> said pressure. Noticed afterwards that it had been created under
> umask 0022 - not good, and the chmod to remove read rights for all
> blocked. Thankfully, it was my desktop, not a multiple user server :)
[...]

How much of the original problem goes away if swapon(8) were to refuse to
activate a file/device which has ownership/mode which it doesn't like?

Of course such a change to swapon(8) should be accompanied by a flag to
force swapping on a file/device with non-sane ownership/mode.

Regards,
Neale.


2004-01-01 10:12:51

by Andrew Morton

[permalink] [raw]
Subject: Re: chmod of active swap file blocks

Neale Banks <[email protected]> wrote:
>
> How much of the original problem goes away if swapon(8) were to refuse to
> activate a file/device which has ownership/mode which it doesn't like?

I think swapon(8) should at least warn when the swapfile has inappropriate
permissions. It's an obvious and outright security hole.

2004-01-01 14:10:34

by Andries Brouwer

[permalink] [raw]
Subject: Re: chmod of active swap file blocks

On Thu, Jan 01, 2004 at 02:12:41AM -0800, Andrew Morton wrote:
> Neale Banks <[email protected]> wrote:
> >
> > How much of the original problem goes away if swapon(8) were to refuse to
> > activate a file/device which has ownership/mode which it doesn't like?
>
> I think swapon(8) should at least warn when the swapfile has inappropriate
> permissions. It's an obvious and outright security hole.

swapon had this warning for a while, but that generated lots of complaints.
Now this message is printed only when the -v (verbose) flag is given.

2004-01-01 21:48:48

by Erik Andersen

[permalink] [raw]
Subject: Re: chmod of active swap file blocks

On Thu Jan 01, 2004 at 03:10:27PM +0100, Andries Brouwer wrote:
> On Thu, Jan 01, 2004 at 02:12:41AM -0800, Andrew Morton wrote:
> > Neale Banks <[email protected]> wrote:
> > >
> > > How much of the original problem goes away if swapon(8) were to refuse to
> > > activate a file/device which has ownership/mode which it doesn't like?
> >
> > I think swapon(8) should at least warn when the swapfile has inappropriate
> > permissions. It's an obvious and outright security hole.
>
> swapon had this warning for a while, but that generated lots of complaints.
> Now this message is printed only when the -v (verbose) flag is given.

Perhaps swapon should automagically do a chmod and chown on all
swapfiles, unless specifically asked to be wildly insecure
(perhaps with a -W option -- wildly insecure swapfile permissions
are considered acceptable)....

-Erik

--
Erik B. Andersen http://codepoet-consulting.com/
--This message was written using 73% post-consumer electrons--

2004-01-02 00:44:29

by Paul Jakma

[permalink] [raw]
Subject: Re: chmod of active swap file blocks

On Thu, 1 Jan 2004, Erik Andersen wrote:

> Perhaps swapon should automagically do a chmod and chown on all
> swapfiles, unless specifically asked to be wildly insecure (perhaps
> with a -W option -- wildly insecure swapfile permissions are
> considered acceptable)....

There's no sane reason to have open swap files, so yes, above
behaviour would be good.

> -Erik

regards,
--
Paul Jakma [email protected] [email protected] Key ID: 64A2FF6A
warning: do not ever send email to [email protected]
Fortune:
A prisoner of war is a man who tries to kill you and fails, and then
asks you not to kill him.
-- Sir Winston Churchill, 1952