linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Valdis.Kletnieks@vt.edu
To: dave@gnu.org
Cc: Hugh Dickins <hughd@google.com>,
	Lennart Poettering <lennart@poettering.net>,
	Andrew Morton <akpm@linux-foundation.org>,
	lkml <linux-kernel@vger.kernel.org>,
	linux-mm@kvack.org
Subject: Re: [RFC PATCH] tmpfs: support user quotas
Date: Mon, 07 Nov 2011 04:11:33 -0500	[thread overview]
Message-ID: <25866.1320657093@turing-police.cc.vt.edu> (raw)
In-Reply-To: Your message of "Sun, 06 Nov 2011 18:15:01 -0300." <1320614101.3226.5.camel@offbook>

[-- Attachment #1: Type: text/plain, Size: 1399 bytes --]

On Sun, 06 Nov 2011 18:15:01 -0300, Davidlohr Bueso said:

> @@ -1159,7 +1159,12 @@ shmem_write_begin(struct file *file, struct address_space *mapping,
>  			struct page **pagep, void **fsdata)

> +	if (atomic_long_read(&user->shmem_bytes) + len > 
> +	    rlimit(RLIMIT_TMPFSQUOTA))
> +		return -ENOSPC;

Is this a per-process or per-user limit?  If it's per-process, it doesn't
really do much good, because a user can use multiple processes to over-run the
limit (either intentionally or accidentally).

> @@ -1169,10 +1174,12 @@ shmem_write_end(struct file *file, struct address_space *mapping,
>  			struct page *page, void *fsdata)

> +	if (pos + copied > inode->i_size) {
>  		i_size_write(inode, pos + copied);
> +		atomic_long_add(copied, &user->shmem_bytes);
> +	}

If this is per-user, it's racy with shmem_write_begin() - two processes can hit
the write_begin(), be under quota by (say) 1M, but by the time they both
complete the user is 1M over the quota.

>  @@ -1535,12 +1542,15 @@ static int shmem_unlink(struct inode *dir, struct dentry *dentry)
> +	struct user_struct *user = current_user();
> +	atomic_long_sub(inode->i_size, &user->shmem_bytes);

What happens here if user 'fred' creates a file on a tmpfs, and then logs out so he has
no processes running, and then root does a 'find tmpfs -user fred -exec rm {} \;' to clean up?
We just decremented root's quota, not fred's....


[-- Attachment #2: Type: application/pgp-signature, Size: 227 bytes --]

  parent reply	other threads:[~2011-11-07  9:11 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-06 21:15 Davidlohr Bueso
2011-11-06 22:10 ` Lennart Poettering
2011-11-07  7:31 ` Christoph Hellwig
2011-11-07 11:29   ` Lennart Poettering
2011-11-07 14:20     ` Davidlohr Bueso
2011-11-07 13:58       ` Alan Cox
2011-11-07 14:27         ` Kay Sievers
2011-11-07 22:53           ` Alan Cox
2011-11-07 22:57             ` Glauber Costa
2011-11-07 23:07             ` Lennart Poettering
2011-11-07 23:43               ` Alan Cox
2011-11-08  0:25                 ` Lennart Poettering
2011-11-08  0:46                   ` Alan Cox
2011-11-07 14:30         ` Lennart Poettering
2011-11-07 22:15           ` KOSAKI Motohiro
2011-11-07 22:37             ` Kay Sievers
2011-11-08  0:33               ` KOSAKI Motohiro
2011-11-07 23:01           ` Alan Cox
2011-11-07  9:11 ` Valdis.Kletnieks [this message]
2011-11-07 14:49   ` Davidlohr Bueso

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=25866.1320657093@turing-police.cc.vt.edu \
    --to=valdis.kletnieks@vt.edu \
    --cc=akpm@linux-foundation.org \
    --cc=dave@gnu.org \
    --cc=hughd@google.com \
    --cc=lennart@poettering.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.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