Linux ocfs2 filesystem development
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] vfs: Add general support to enforce project quota limits
Date: Thu, 9 Apr 2015 22:39:54 +0300	[thread overview]
Message-ID: <20150409193954.GA19913@mwanda> (raw)

Hello Li Xi,

The patch 847aac644e92: "vfs: Add general support to enforce project
quota limits" from Mar 19, 2015, leads to the following static
checker warning:

	fs/ocfs2/quota_local.c:183 ocfs2_local_check_quota_file()
	error: buffer overflow 'lmagics' 2 <= 2

fs/ocfs2/quota_local.c
   159  /* Check whether we understand format of quota files */
   160  static int ocfs2_local_check_quota_file(struct super_block *sb, int type)
   161  {
   162          unsigned int lmagics[OCFS2_MAXQUOTAS] = OCFS2_LOCAL_QMAGICS;
                                     ^^^^^^^^^^^^^^^
This is 2.  Maybe the fix is to change this to MAXQUOTAS.

   163          unsigned int lversions[OCFS2_MAXQUOTAS] = OCFS2_LOCAL_QVERSIONS;
   164          unsigned int gmagics[OCFS2_MAXQUOTAS] = OCFS2_GLOBAL_QMAGICS;
   165          unsigned int gversions[OCFS2_MAXQUOTAS] = OCFS2_GLOBAL_QVERSIONS;
   166          unsigned int ino[OCFS2_MAXQUOTAS] = { USER_QUOTA_SYSTEM_INODE,
   167                                                GROUP_QUOTA_SYSTEM_INODE };
   168          struct buffer_head *bh = NULL;
   169          struct inode *linode = sb_dqopt(sb)->files[type];
   170          struct inode *ginode = NULL;
   171          struct ocfs2_disk_dqheader *dqhead;
   172          int status, ret = 0;
   173  
   174          /* First check whether we understand local quota file */
   175          status = ocfs2_read_quota_block(linode, 0, &bh);
   176          if (status) {
   177                  mlog_errno(status);
   178                  mlog(ML_ERROR, "failed to read quota file header (type=%d)\n",
   179                          type);
   180                  goto out_err;
   181          }
   182          dqhead = (struct ocfs2_disk_dqheader *)(bh->b_data);
   183          if (le32_to_cpu(dqhead->dqh_magic) != lmagics[type]) {
                                                      ^^^^^^^^^^^^^
This is one past the end of the array.  It used to be limitied in
do_quotactl().

	if (type >= (XQM_COMMAND(cmd) ? XQM_MAXQUOTAS : MAXQUOTAS))

The old logic was the XFS had 3 quotas and everyone else had 2 but now
we raised MAXQUOTAS to 3 as well.

   184                  mlog(ML_ERROR, "quota file magic does not match (%u != %u),"
   185                          " type=%d\n", le32_to_cpu(dqhead->dqh_magic),
   186                          lmagics[type], type);
   187                  goto out_err;
   188          }

regards,
dan carpenter

             reply	other threads:[~2015-04-09 19:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-09 19:39 Dan Carpenter [this message]
2015-04-09 19:46 ` [Ocfs2-devel] vfs: Add general support to enforce project quota limits Dan Carpenter
2015-04-13 10:10 ` Jan Kara
2015-04-13 11:48   ` Dan Carpenter
2015-04-13 12:19     ` Jan Kara

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=20150409193954.GA19913@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=ocfs2-devel@oss.oracle.com \
    /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