Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp725711pxu; Wed, 14 Oct 2020 12:03:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcLmzOz27pKvRDAC2QStChjcOkZKkY42E+eqJEbwOThGYtTtudrhD1Y21Kv4FlpMG6BvXL X-Received: by 2002:a17:906:4d03:: with SMTP id r3mr505445eju.364.1602702215965; Wed, 14 Oct 2020 12:03:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602702215; cv=none; d=google.com; s=arc-20160816; b=UpUKMS8TbnFi/1TANCrvt48nQiVt7uNtWEb6zvEELlQ7qBcj0OpT4/betsxlrGtHqy yVBTHqxCVswtk+Ny21ir6pyeHZRv2rCS4piXLTUJ43sQEefxty4HBvPO8LND1gwwaXZN O1LzVldQ6KxfK1srdCLcKL8j3G8E6HdL7M2nf2zHBV+iwB2yatvN3PdOi+fODgDPtNja ZZiFvR8GquCe1Z+Gik9S9iCKDyjUt6mKG4ocGn1vZwxJhzjx7TrvvcyhG06cXoIaZzoa 9aVYvY+0VmFTf3wVbgfvK7kmL+0zU1fy+wdRt5FGB2nV/+Grf8m/UwVT6txN3G9lavEk WUGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=p+JrADlr5t+YAAhULA0pqV3ZIZBiEjPrGaYhwMVIKV4=; b=g8SJgRXsg8QYdIHX6n090vdbr98OJ29vj9HOCjeOZnFmnzVyenPEYG2kZ96yKl2frf +HgYHwTmY4ilSufPzGcY4wSNGUGGAILm+guIYEpfWp4Yp47z02GjQT+lg+Uz4NEcqw/0 C02qDC+l0th/GxPIwmUi9J7pdM0KRroS0UeMtlfjKS/jZj0nuf6rKUzo9Nxp12ZYzgbk 62aft7/pxZaSUHv+jYeM6wV+UR343qJz4NsMfWBsdXxhWd+LKMklH4kHWspBaSIb2HUi uXpaWk/4VjLmrQKHqV91apJASf291lOmbIox0v/FZIHQdcHVOHc5lPDZwGzsIIcxLtP7 Sxhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=N4ycceOK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t20si400627ejx.187.2020.10.14.12.03.08; Wed, 14 Oct 2020 12:03:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=N4ycceOK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730272AbgJNTBH (ORCPT + 99 others); Wed, 14 Oct 2020 15:01:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:22974 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730160AbgJNTBH (ORCPT ); Wed, 14 Oct 2020 15:01:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602702066; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=p+JrADlr5t+YAAhULA0pqV3ZIZBiEjPrGaYhwMVIKV4=; b=N4ycceOKEzHurJ8/X7qy86oRImwQFDPaONqSISxRHQvpQVL3kEezQs9ttrD02wfS3eb3Ly D+gcIgIefVtWcYNojeLDI9EDqbHKfYx2z6V/hJMYoCLZj04+V2/ArEgStOkHCI9EZw/8Bx FIU2nBpF0sAY7kxxlIkCSZ2bow5GyFU= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-416-b3tvlVZlN_-ZrZPQ9_EAgg-1; Wed, 14 Oct 2020 15:01:04 -0400 X-MC-Unique: b3tvlVZlN_-ZrZPQ9_EAgg-1 Received: by mail-wr1-f71.google.com with SMTP id f11so76980wro.15 for ; Wed, 14 Oct 2020 12:01:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=p+JrADlr5t+YAAhULA0pqV3ZIZBiEjPrGaYhwMVIKV4=; b=sFgDxXCf0+wmA6n/QiDjRrmL33XtfggatCBGKHkLLs+2fL+MYBadc+qAu4Jx4tMGNl kMzaKQ20qewGd19LJGNY8tKcxp+qoVLnUhiDNzUiZ/ek1pgo2MQJR9vjoH57kcJlmNKt NGx3rnPNc/qWE7yKCGoaPMcEXTcp/ul1sV0OPQbldmjTzWce+pehBH/ibINOyieymTn2 GMvcb1u2xK4HwWsSiBQOXghiCzWUbQIzj/WUL3Rw+nlJ7bNhS9tat8OkehjkbMSi40jL pzw7WxfseLLfbQX07HpwpQEaHn0sln1lfLW+a2TyRXUwpEGdb1ASe4pR0bq0Wb1OwWAI jzVg== X-Gm-Message-State: AOAM532O567sU/2gPkbUQEoB6pb++iKW0dDkkZUhq5yGyJFrSf5R/VCB 1aMqkejkfdXEcGcchyYE6EwPcQIVDVztUAiXcTMBlAo8T2xbIfwOYhtEw3vVK0/gXFXWzudVqT2 J2dOhNG/gBq54Z9TwGXtZpRPi6SIKagvtSHoxp/Yo X-Received: by 2002:a5d:458c:: with SMTP id p12mr186314wrq.329.1602702063048; Wed, 14 Oct 2020 12:01:03 -0700 (PDT) X-Received: by 2002:a5d:458c:: with SMTP id p12mr186290wrq.329.1602702062813; Wed, 14 Oct 2020 12:01:02 -0700 (PDT) MIME-Version: 1.0 References: <20201014163109.98739-1-anant.thazhemadam@gmail.com> In-Reply-To: <20201014163109.98739-1-anant.thazhemadam@gmail.com> From: Andreas Gruenbacher Date: Wed, 14 Oct 2020 21:00:51 +0200 Message-ID: Subject: Re: [PATCH v2] fs: gfs2: add validation checks for size of superblock To: Anant Thazhemadam Cc: Andrew Price , Bob Peterson , syzbot+a5e2482a693e6b1e444b@syzkaller.appspotmail.com, LKML , linux-kernel-mentees@lists.linuxfoundation.org, cluster-devel , Fox Chen , syzbot+af90d47a37376844e731@syzkaller.appspotmail.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Anant, On Wed, Oct 14, 2020 at 6:31 PM Anant Thazhemadam 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 > Signed-off-by: Anant Thazhemadam > --- > > Changes in v2: > > * Completely dropped the changes proposed in v1. Instead, > validity checks for superblock size have been introduced. > (Suggested by Andrew Price) > > * 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