From: Michael Marineau <mike@marineau.org>
To: linux-kernel@vger.kernel.org
Cc: trivial@kernel.org, Michael Marineau <mike@marineau.org>
Subject: [PATCH] tmpfs: fix mounts when size is less than the page size
Date: Sat, 3 Nov 2007 15:11:42 -0700 [thread overview]
Message-ID: <11941279021705-git-send-email-mike@marineau.org> (raw)
When tmpfs is mounted with a size less than one page the number of blocks
is set to 0 which makes the tmpfs mount unlimited. This can lead to a quick
and surprising death is someone typos a tmpfs mount command and writes to much.
tmpfs can still be mounted as unlimited if size or nr_blocks is exactly 0.
Signed-off-by: Michael Marineau <mike@marineau.org>
---
mm/shmem.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/mm/shmem.c b/mm/shmem.c
index 253d205..66b07f2 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2138,6 +2138,8 @@ static int shmem_parse_options(char *options, int *mode, uid_t *uid,
if (*rest)
goto bad_val;
*blocks = size >> PAGE_CACHE_SHIFT;
+ if (size && blocks == 0)
+ blocks = 1;
} else if (!strcmp(this_char,"nr_blocks")) {
*blocks = memparse(value,&rest);
if (*rest)
--
1.5.1.6
next reply other threads:[~2007-11-03 22:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-03 22:11 Michael Marineau [this message]
2007-11-03 23:46 ` [PATCH, RESEND] " Michael Marineau
2007-11-04 12:19 ` Hugh Dickins
2007-11-04 18:12 ` Michael Marineau
2007-11-04 18:29 ` Hugh Dickins
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=11941279021705-git-send-email-mike@marineau.org \
--to=mike@marineau.org \
--cc=linux-kernel@vger.kernel.org \
--cc=trivial@kernel.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®