From: Jan Kara <jack@suse.cz>
To: <linux-fsdevel@vger.kernel.org>
Cc: <linux-mm@kvack.org>,
ocfs2-devel@lists.linux.dev,
Joseph Qi <joseph.qi@linux.alibaba.com>,
Hugh Dickins <hughd@google.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
Farhad Alemi <farhad.alemi@berkeley.edu>, Jan Kara <jack@suse.cz>
Subject: [PATCH v2 2/2] shmem: Refuse to enable tmpfs format for another filesystem
Date: Thu, 3 Sep 2026 11:05:05 +0200 [thread overview]
Message-ID: <20260903090508.1360863-4-jack@suse.cz> (raw)
In-Reply-To: <20260903090053.13120-1-jack@suse.cz>
It is possible to issue Q_QUOTAON quotactl(2) e.g. for ext4 filesystem
requesting to enable quota using tmpfs quota format. With suitable
passed arguments this can actually succeed in enabling tmpfs quota
format on top of ext4 filesystem which leads to crashes later in
dquot_acquire(). As tmpfs quota format is intended for tmpfs
filesystems only, verify we are indeed enabling quotas there.
Reported-by: Farhad Alemi <farhad.alemi@berkeley.edu>
Signed-off-by: Jan Kara <jack@suse.cz>
---
mm/shmem_quota.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/mm/shmem_quota.c b/mm/shmem_quota.c
index d0b92d6da50f..a3fa4bd93e75 100644
--- a/mm/shmem_quota.c
+++ b/mm/shmem_quota.c
@@ -30,6 +30,7 @@
#include <linux/slab.h>
#include <linux/rbtree.h>
#include <linux/shmem_fs.h>
+#include <linux/magic.h>
#include <linux/quotaops.h>
#include <linux/quota.h>
@@ -54,6 +55,10 @@ struct quota_id {
static int shmem_check_quota_file(struct super_block *sb, int type)
{
+ /* Verify enabling happens on tmpfs superblock */
+ if (sb->s_magic != TMPFS_MAGIC)
+ return 0;
+
/* There is no real quota file, nothing to do */
return 1;
}
--
2.51.0
next prev parent reply other threads:[~2026-09-03 9:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 9:05 [PATCH v2 0/2] quota: Verify special quota formats match sb type Jan Kara
2026-09-03 9:05 ` [PATCH v2 1/2] ocfs2: Refuse to enable ocfs2 format for another filesystem Jan Kara
2026-09-03 10:15 ` Joseph Qi
2026-09-03 9:05 ` Jan Kara [this message]
2026-09-03 15:15 ` [PATCH v2 2/2] shmem: Refuse to enable tmpfs " 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=20260903090508.1360863-4-jack@suse.cz \
--to=jack@suse.cz \
--cc=baolin.wang@linux.alibaba.com \
--cc=farhad.alemi@berkeley.edu \
--cc=hughd@google.com \
--cc=joseph.qi@linux.alibaba.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ocfs2-devel@lists.linux.dev \
/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