linux-kernel-mentees.lists.linuxfoundation.org archive mirror
 help / color / mirror / Atom feed
From: Andreas Gruenbacher <agruenba@redhat.com>
To: Anant Thazhemadam <anant.thazhemadam@gmail.com>
Cc: syzbot+af90d47a37376844e731@syzkaller.appspotmail.com,
	Fox Chen <foxhlchen@gmail.com>,
	LKML <linux-kernel@vger.kernel.org>,
	syzbot+a5e2482a693e6b1e444b@syzkaller.appspotmail.com,
	cluster-devel <cluster-devel@redhat.com>,
	Andrew Price <anprice@redhat.com>,
	Bob Peterson <rpeterso@redhat.com>,
	linux-kernel-mentees@lists.linuxfoundation.org
Subject: Re: [Linux-kernel-mentees] [PATCH v2] fs: gfs2: add validation checks for size of superblock
Date: Wed, 14 Oct 2020 21:00:51 +0200	[thread overview]
Message-ID: <CAHc6FU5s3xL745-gUueSW3JO+V78ySsk1ueZ6tT-jrc6w5FD5g@mail.gmail.com> (raw)
In-Reply-To: <20201014163109.98739-1-anant.thazhemadam@gmail.com>

Anant,

On Wed, Oct 14, 2020 at 6:31 PM Anant Thazhemadam
<anant.thazhemadam@gmail.com> wrote:
> In gfs2_check_sb(), no validation checks are performed with regards to
> the size of the superblock.
> syzkaller detected a slab-out-of-bounds bug that was primarily caused
> because the block size for a superblock was set to zero.
> A valid size for a superblock is a power of 2 between 512 and PAGE_SIZE.
> Performing validation checks and ensuring that the size of the superblock
> is valid fixes this bug.
>
> Reported-by: syzbot+af90d47a37376844e731@syzkaller.appspotmail.com
> Tested-by: syzbot+af90d47a37376844e731@syzkaller.appspotmail.com
> Suggested-by: Andrew Price <anprice@redhat.com>
> Signed-off-by: Anant Thazhemadam <anant.thazhemadam@gmail.com>
> ---
>
> Changes in v2:
>
>         * Completely dropped the changes proposed in v1. Instead,
>           validity checks for superblock size have been introduced.
>           (Suggested by Andrew Price<anprice@redhat.com>)
>
>         * Addded a "Suggested-by" tag accrediting the patch idea to
>           Andrew. If there's any issue with that, please let me know.
>
>         * Changed the commit header and commit message appropriately.
>
>         * Updated "Reported-by" and "Tested-by" tags to the same instance
>           of the bug that was detected earlier (non consequential change).
>
>
>  fs/gfs2/ops_fstype.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
> index 6d18d2c91add..f0605fae2c4c 100644
> --- a/fs/gfs2/ops_fstype.c
> +++ b/fs/gfs2/ops_fstype.c
> @@ -169,6 +169,13 @@ static int gfs2_check_sb(struct gfs2_sbd *sdp, int silent)
>                 return -EINVAL;
>         }
>
> +       /* Check if the size of the block is valid - a power of 2 between 512 and  PAGE_SIZE */
> +       if (sb->sb_bsize < 512 || sb->sb_bsize > PAGE_SIZE || (sb->sb_bsize & (sb->sb_bsize - 1))) {
> +               if (!silent)
> +                       pr_warn("Invalid superblock size\n");
> +               return -EINVAL;
> +       }
> +

I'll add that to for-next.

Thanks,
Andreas

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

      reply	other threads:[~2020-10-14 19:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-14 16:31 [Linux-kernel-mentees] [PATCH v2] fs: gfs2: add validation checks for size of superblock Anant Thazhemadam
2020-10-14 19:00 ` Andreas Gruenbacher [this message]

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=CAHc6FU5s3xL745-gUueSW3JO+V78ySsk1ueZ6tT-jrc6w5FD5g@mail.gmail.com \
    --to=agruenba@redhat.com \
    --cc=anant.thazhemadam@gmail.com \
    --cc=anprice@redhat.com \
    --cc=cluster-devel@redhat.com \
    --cc=foxhlchen@gmail.com \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rpeterso@redhat.com \
    --cc=syzbot+a5e2482a693e6b1e444b@syzkaller.appspotmail.com \
    --cc=syzbot+af90d47a37376844e731@syzkaller.appspotmail.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;
as well as URLs for NNTP newsgroup(s).