Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1133587pxb; Fri, 20 Nov 2020 01:52:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJyVRxug3EkSNEt98aCO0gtAodAyfx+gCVrXK3CcbKnKoR6PM+0UNv45M196rsX+8DDTzL6l X-Received: by 2002:a17:906:77c5:: with SMTP id m5mr32611657ejn.424.1605865960744; Fri, 20 Nov 2020 01:52:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605865960; cv=none; d=google.com; s=arc-20160816; b=E+vFXxD7Lhjf06MRrb/utTiLOsWlQf3Zo4MA0YkHnmoq5gQXRJw4Cm9beqyPXnyFgO ENY+zVOTjjxX9Xv0oeigZuUXO+Mi+TSckgdXZ3Hk/1ro0r3s9OIalhiV4r/03jceOC9Z NEqHOD0TSuQ4o4IWtDCuaGhhNNGrIw19G0eU31QWMBaVAS/q71Ecar9CEvxuHNyNeGww 1cArfHrURd3vKvGajorOv+bxd6hAxj8d+8/Z5h3MX8Cky4laMEdoiKlsWS7XjIuBLTH/ YO2RhD+EAjKvmMtD6bvCN3ZPXC1L1vhBVY/Jy4vp+gkMUB2B7jShzcUsk3D1PnNnCNSg 4BIw== 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=v+lvM0oe2csxAdgkijCshZJQ9aSiN+9+WmHYhC9WJtA=; b=UcaYcKmeYlsJCA7sRo7WLxJ/oS+lHN/T+Ao1XcQnEwrj9Il3x7ccIO1fFZqGsydY0E c91wremaCQiJwC8qqWLZn0AVxKTsTT5j6knqWBjbBrA8mx3R66jzNqgEmOFbPKrcOQCx 5wNPhh3Bt6L/EhvRL111zXLktjjjZPJfmHTPcigWIS2NkXF/cNnRZOm/9+4fvVJgszI5 eTHgPF+xdnI8rEv6aFxRdVRIV/tZ2C0n/9V4cewYlWyLALvy3tJpoNOWMopEHF20MmmQ QQc4uibraY9pcFXAKRzEPEwRcGzcVs28tpOGWs+6cKJt9NM1Mo2tfG75XLymv/zvw728 uDiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qtMggYAd; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w10si1394390ejc.434.2020.11.20.01.52.16; Fri, 20 Nov 2020 01:52:40 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=qtMggYAd; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727123AbgKTJui (ORCPT + 99 others); Fri, 20 Nov 2020 04:50:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725809AbgKTJuh (ORCPT ); Fri, 20 Nov 2020 04:50:37 -0500 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B1C6C0613CF for ; Fri, 20 Nov 2020 01:50:37 -0800 (PST) Received: by mail-lj1-x241.google.com with SMTP id 142so9383502ljj.10 for ; Fri, 20 Nov 2020 01:50:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=v+lvM0oe2csxAdgkijCshZJQ9aSiN+9+WmHYhC9WJtA=; b=qtMggYAdJf1aw4+cMpfp/iom82fLnRQp6EBvBByIIavdGTqYBTerpCmF6Bkn0HlXfy 9ODbKv0z1uWs0g8Wzcdkeqwe7Jq3wFv132D0+fgkw4T1YT3EC6b2DlsouJ6Fah7uvBoz WqYY2Z58ts/+lxxErpcIkuSSVOq6HfrCNYAio+odE6ORDsrSqUgtp8fPuIulyzCzDcXw kuHBBeAOw3kKoh7Ui8H25NTALqb+cMWmPHq2+zRLQ21IavnzdLcK3X9ANSq/14ymK30L MeycMwP6XNdd1ZJiTEwnuAxdek8Qvdpnjwv3GJvJ4Cc622BUBeh7Srfbrw5KuRZZUupJ Lo/g== 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=v+lvM0oe2csxAdgkijCshZJQ9aSiN+9+WmHYhC9WJtA=; b=UvR0RiYL4idTITNoRw8oFf6Vi+aEQMEcHjizVDbwVzVfWhPXEXyQdVM/wl3Y0bfMuZ CjMKxrqKOg654ziZ2ZPocxKv/UocYl5tYhN9SAAnmbeT/aUbF/4Vpz1vQnNdH9uoh3Cx W81vXIod+QdQdpEn5LukoLHdu1tOTK88d5GrSZ/SGxYttwz8oQCd6lYQEa1xulwgJjsx c2brzmXuopfQhZbmjHHUwNgkWrSinB+2CvDiTpNN25UPDNmeY4oAuKVCAyeJixUKdqJ9 JqX2XgOzhMZumyGaNUaf2Q3wnq9RDlSVy+J1JXXzAhXhy7aO7T8g1fWTnkVpGqnhfYXu Pgvg== X-Gm-Message-State: AOAM533zMWc7vC3KHNi6wL0Dqp/n45SG7u4WwIePE0pbzfYXw9hCn8wQ LukoY/DDdIHMfGEQ8Hm7R115vXr1BBdOFOboipc= X-Received: by 2002:a2e:54e:: with SMTP id 75mr7390121ljf.381.1605865835824; Fri, 20 Nov 2020 01:50:35 -0800 (PST) MIME-Version: 1.0 References: <298485e2-01de-048d-5515-44ac254167e4@oracle.com> In-Reply-To: <298485e2-01de-048d-5515-44ac254167e4@oracle.com> From: butt3rflyh4ck Date: Fri, 20 Nov 2020 17:50:24 +0800 Message-ID: Subject: Re: UBSAN: array-index-out-of-bounds in dbAdjTree To: Dave Kleikamp Cc: jfs-discussion@lists.sourceforge.net, linux-kernel@vger.kernel.org, syzkaller-bugs Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org You are welcome and have you submitted the patch to linux upstream ? If you have no time do that and I can do it. On Sun, Nov 15, 2020 at 12:17 AM Dave Kleikamp wrote: > > Thanks for reporting and testing this! > > Shaggy > > On 11/14/20 7:55 AM, butt3rflyh4ck wrote: > > Yes, I have tested the patch, it seem to fix the problem. > > > > Regard, > > butt3rflyh4ck. > > > > On Sat, Nov 14, 2020 at 5:16 AM Dave Kleikamp wrote: > >> > >> On 10/8/20 12:00 PM, butt3rflyh4ck wrote: > >>> I report a array-index-out-of-bounds bug (in linux-5.9.0-rc6) found by > >>> kernel fuzz. > >>> > >>> kernel config: https://github.com/butterflyhack/syzkaller-fuzz/blob/master/v5.9.0-rc6-config > >>> > >>> and can reproduce. > >>> > >>> the dmtree_t is that > >>> typedef union dmtree { > >>> struct dmaptree t1; > >>> struct dmapctl t2; > >>> } dmtree_t; > >>> > >>> the dmaptree is that > >>> struct dmaptree { > >>> __le32 nleafs; /* 4: number of tree leafs */ > >>> __le32 l2nleafs; /* 4: l2 number of tree leafs */ > >>> __le32 leafidx; /* 4: index of first tree leaf */ > >>> __le32 height; /* 4: height of the tree */ > >>> s8 budmin; /* 1: min l2 tree leaf value to combine */ > >>> s8 stree[TREESIZE]; /* TREESIZE: tree */ > >>> u8 pad[2]; /* 2: pad to word boundary */ > >>> }; > >>> the TREESIZE is totally 341, but the leafidx type is __le32. > >> > >> Does this patch fix the problem? > >> > >> jfs: Fix array index bounds check in dbAdjTree > >> > >> Bounds checking tools can flag a bug in dbAdjTree() for an array index > >> out of bounds in dmt_stree. Since dmt_stree can refer to the stree in > >> both structures dmaptree and dmapctl, use the larger array to eliminate > >> the false positive. > >> > >> Signed-off-by: Dave Kleikamp > >> --- > >> fs/jfs/jfs_dmap.h | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> > >> diff --git a/fs/jfs/jfs_dmap.h b/fs/jfs/jfs_dmap.h > >> index 29891fad3f09..aa03a904d5ab 100644 > >> --- a/fs/jfs/jfs_dmap.h > >> +++ b/fs/jfs/jfs_dmap.h > >> @@ -183,7 +183,7 @@ typedef union dmtree { > >> #define dmt_leafidx t1.leafidx > >> #define dmt_height t1.height > >> #define dmt_budmin t1.budmin > >> -#define dmt_stree t1.stree > >> +#define dmt_stree t2.stree > >> > >> /* > >> * on-disk aggregate disk allocation map descriptor. > >> -- > >> 2.29.2 > >>