Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2438814rdb; Wed, 4 Oct 2023 00:41:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHr93EHKn5HtigC2FY2GQNK7tjOKDd9L2vrWGolMi54WC38/mvClz1+mxd/sifJhDGH9j2x X-Received: by 2002:a25:ac07:0:b0:d74:6163:db8c with SMTP id w7-20020a25ac07000000b00d746163db8cmr1365590ybi.41.1696405288254; Wed, 04 Oct 2023 00:41:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696405288; cv=none; d=google.com; s=arc-20160816; b=ln2yuWHWq2B+7Bn3uvrDbfu48MtXsONVX9sr9N5ZO/2arh7iknBCHkvD3Klh7BHO/v x50p4YgzBh9KNEcjwHZ1OAmpcU3KuYSMWNYA4brU8Qof3JcTRWKPfCROurFdPJqm7IoL MmKjGTickoM1YTcFAxgtvZ2HHSOWf4XNNilKqiW9tzgJTRTed6W4tjpAFSMk6Y6t6FK0 hCddi30Y2GHbw1IPx1b5srvRkXTXebgGsmo4xNodAncQundu1j5D7pnalS9gl6UlzTG0 u/CMQ38sXY5mT41+Xq6cF6K1QwQ0YMNJsVgJVTLW6Ikvjlk1vrBSqBFMdsZFe7BE2M99 HRjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=5fUH5S4uz1EWWFstq5oEXMZSXkqH1sqcQ+Nf7tmZbwI=; fh=aMQa3zSP9917aGzwLN4zk7oa4Vh3vPQ7sfb8k5YaWoo=; b=LSZyWm2Nw1jAabH0h31hQScI7sRGuX5F16+iIaVTOMFcgf+SPRajOiy9X1Kkz82t/d DKXDQoNImK4qcrdXbve9/mdOIpxWlRj7KpBpd+Nm/Yf5p1jsQ17RFxFRiHA9QaotTlvV QFJLa1jaR7tv8iu7u/RlCKMvMhrkglE83HE3UsTb7dP/wprDPytNULp/pFLQKrofHsgd TlHqcqa1+pM3nHrC4L+O61DsiZMkR1E4Z5edvMTKqFYAse2nb/01moXvPEAZ/hrxx7qA C0sFY0pi7JQlzCLjhT4EKmtW4BS4XEniaPMIf6JkmV7bf3x+wDdhsQxuZy975Hp1IH9j HpBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=lAsRhhXP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id v34-20020a634822000000b005789c7e9bf2si3267580pga.627.2023.10.04.00.41.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 00:41:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=lAsRhhXP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 635A48040EE6; Wed, 4 Oct 2023 00:41:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241529AbjJDHk4 (ORCPT + 99 others); Wed, 4 Oct 2023 03:40:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232766AbjJDHkz (ORCPT ); Wed, 4 Oct 2023 03:40:55 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 076FCA7 for ; Wed, 4 Oct 2023 00:40:53 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id 98e67ed59e1d1-27758c8f579so1211922a91.0 for ; Wed, 04 Oct 2023 00:40:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696405252; x=1697010052; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=5fUH5S4uz1EWWFstq5oEXMZSXkqH1sqcQ+Nf7tmZbwI=; b=lAsRhhXPnuCUvf+HYC2VvZYoaUGmP4X8KP1K3rZef7tfG0FQuAP896a+wpLLarZXLa v09Y9wPdj/Ap8I53bfoiPg1jzRv6m+zm6Y94SB3mVi1qxHi5xnz1Bv8O0pzSCvqyAyJk /ErdCKkp/IQlplqB8MX0dwBpVDv83imSo6cMKt8vyvR5fz8H85fcpd2ylCUmaz1JkYbD DARLrpqiQgvex5vPMDdWy9v6yYMUw6boBvtJvL8HLuYhSdKLtB9GJ3NXC5WMy64mJ9Os fpaObpXTXJ3VFLrjmR1FxdY79TZ3KqXE7CGK89Ej6xKPi1lQxqutrnVivkBVfk54+0VO YFNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696405252; x=1697010052; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5fUH5S4uz1EWWFstq5oEXMZSXkqH1sqcQ+Nf7tmZbwI=; b=iQHgzgeejD5UTXO3n3FkL6tcdjytoF4oEpHYYZYCXTOkieseWZL9JHXcuRkcCesCUs EIbx7tK75agGgaDz6OStj+tyCrmNm8jM8sPmvgIpffP7bre0ANMM4+t9SLEdTBbjVm87 uNwLRbUNsV22YD/6vnbFtc0iCTiMjqqrPPVWQiJZLPlOYk1u4cgXA+8NUGxFuYLw/HFe cwvP/3rmmXA3Q1Pqzae9JplgzmSGpY2tuMnB7oxEbHaed0sZPNJA6BWukwE4ztG9J2++ DX7iWwdo2ed2BylXUmbZBpgby2cfw3MY6KdtZV8T5WW0/trAEvnLNDt0HHKKI56E57AD nj4w== X-Gm-Message-State: AOJu0YzEzpuhnyGtAEfcSw8gjXsFCwAy2blb+YrsvEIqmtT1x8HJiPcq 41Nx4WLECWT2IhVCHhtn7B4= X-Received: by 2002:a17:90a:3f16:b0:279:1367:b9a3 with SMTP id l22-20020a17090a3f1600b002791367b9a3mr1447237pjc.4.1696405252410; Wed, 04 Oct 2023 00:40:52 -0700 (PDT) Received: from manas-VirtualBox.iitr.ac.in ([103.37.201.173]) by smtp.gmail.com with ESMTPSA id 20-20020a17090a199400b0026b12768e46sm894332pji.42.2023.10.04.00.40.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 00:40:51 -0700 (PDT) From: Manas Ghandat To: dave.kleikamp@oracle.com, shaggy@kernel.org Cc: Manas Ghandat , Linux-kernel-mentees@lists.linuxfoundation.org, jfs-discussion@lists.sourceforge.net, linux-kernel@vger.kernel.org, syzbot+79d792676d8ac050949f@syzkaller.appspotmail.com Subject: [PATCH v2] jfs: fix array-index-out-of-bounds in diAlloc Date: Wed, 4 Oct 2023 13:10:40 +0530 Message-Id: <20231004074040.12233-1-ghandatmanas@gmail.com> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 04 Oct 2023 00:41:17 -0700 (PDT) Currently there is not check against the agno of the iag while allocating new inodes to avoid fragmentation problem. Added the check which is required. Reported-by: syzbot+79d792676d8ac050949f@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=79d792676d8ac050949f Signed-off-by: Manas Ghandat --- V1 -> V2 : Added check for higher bound of agno fs/jfs/jfs_imap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c index 799d3837e7c2..c0cf74e7392b 100644 --- a/fs/jfs/jfs_imap.c +++ b/fs/jfs/jfs_imap.c @@ -1319,7 +1319,7 @@ diInitInode(struct inode *ip, int iagno, int ino, int extno, struct iag * iagp) int diAlloc(struct inode *pip, bool dir, struct inode *ip) { int rc, ino, iagno, addext, extno, bitno, sword; - int nwords, rem, i, agno; + int nwords, rem, i, agno, dn_numag; u32 mask, inosmap, extsmap; struct inode *ipimap; struct metapage *mp; @@ -1355,6 +1355,9 @@ int diAlloc(struct inode *pip, bool dir, struct inode *ip) /* get the ag number of this iag */ agno = BLKTOAG(JFS_IP(pip)->agstart, JFS_SBI(pip->i_sb)); + dn_numag = JFS_SBI(pip->i_sb)->bmap->db_numag; + if (agno < 0 || agno > dn_numag) + return -EIO; if (atomic_read(&JFS_SBI(pip->i_sb)->bmap->db_active[agno])) { /* -- 2.37.2