Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1881785rdh; Tue, 26 Sep 2023 06:27:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGDJx5LWRRrxv+E05/+hQX3p/xRYvA6jRvercTTuAaNOJKCUUgozn+7UH02rvhjOxttIckQ X-Received: by 2002:a17:902:7798:b0:1c0:d5b1:2de8 with SMTP id o24-20020a170902779800b001c0d5b12de8mr6873155pll.9.1695734868796; Tue, 26 Sep 2023 06:27:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695734868; cv=none; d=google.com; s=arc-20160816; b=lRW8cJNqQK4C6j4XVNbr04lVT4lOn3yXB8OS/3mfA3+aqhs4SI9gED8vEgll2EYWU4 0xFuqbPuNwjDgl0rBna3DInpoqjV+Hk4suoHyO0dyIKZl/q3iU1MF1RB9QAnXoAFMrJZ +/ea7eP8fqdJz61k7XPpaXaouwQiRINFtU56o5P6mz+AEX+24uqw/3JiNGtVKfEPYDyh oi/Su7wPdJfdeXvEX8YSadkNyFr2aIdEX2WypLGjUPSE38eOq2R0aPGKbX5waGdahxLy Rjey4y7Rgxtq1yZ5G7zTRDrMLZTFGewmrJ9VYhMLmzYPGLFmixAS9enkmdmsI1X+0rqy EvWQ== 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=87h+GCoyZ7JZR2wvMjstdo1iWnzZgP8yLm+iAVVZmYo=; fh=XeIv02Kwcso7WnaZucsuVNsu0P09eccfo8ZhoiRtnxg=; b=Gksee6AppZpWsm1C7Ngk8fdM2KctUMhmch+aJnW8RD70q0AnXVbPBlVtGEhllLlsq5 e5kR7vmTHgNPwm4M4CddO0qgU7hOYr6HYPdOn/Xi689JBum7CfZLFsHMtUcOEGTSRtX8 n0Pp07dpp45Zb1CBrrRkbUcFwbJ/Nr+YfI8spS1DwoD0qDgsFF/XQqk5FTjd7eArlmuz oAY5gJsazDgaITzNGtY9UfhZPEvRUrMYbz/LSHrqMB/mGfFh/iIbIsUip9FJyP5HTyUQ qFm69mFgA/55Ejlc5aeSUuTSBh5OJjuswOMh0iYEZ5OwaL5V9Ej40BtUDOV/Nf0LQzBU KJ/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=cWzCCnmo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id kf15-20020a17090305cf00b001b9fb999147si11584166plb.89.2023.09.26.06.27.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 06:27:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=cWzCCnmo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 9226280ECFB2; Tue, 26 Sep 2023 00:13:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231224AbjIZHNa (ORCPT + 99 others); Tue, 26 Sep 2023 03:13:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229585AbjIZHN2 (ORCPT ); Tue, 26 Sep 2023 03:13:28 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C71F3DE for ; Tue, 26 Sep 2023 00:13:22 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-690d9cda925so6124181b3a.3 for ; Tue, 26 Sep 2023 00:13:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695712402; x=1696317202; 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=87h+GCoyZ7JZR2wvMjstdo1iWnzZgP8yLm+iAVVZmYo=; b=cWzCCnmo+ApEgtgfHTs49L2+MDjJ5gnSSf/HuQyv4iDQ6RuLEfeXsCAPvRQai5EgKT Tu1cI3tc8Fsuo1DJfz/kChS2Oa14UJr5RvCui4V5DIy66AnLwTZ12oqpfO2ddrq9dld0 F2akXfmBznBSuGQv6Wu3djmFdhuGhdwQfhuNXTVnymeyR1J4/lJJfDw0OCX1BuSP49AX wzbrdckrubbX7nyZqN2xai3QRZLfFgxLQDt4kZnbZBKmLgUCcxyl77j99iUCOC19E7P/ kBxcDtTBGZ/vrRnO/O6s2JuBXC/wYzxAiJTbnr+j5+DWxgTNsSRKWoHAnZQLukm7uSMH yZ+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695712402; x=1696317202; 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=87h+GCoyZ7JZR2wvMjstdo1iWnzZgP8yLm+iAVVZmYo=; b=TrzzE4zEaqFpryw180HjBFUz5tWz0Vdc9ws2kyfIAD4tM3V2uXVFj1OXQhyGapj6ep atAE4PacpL6vk+b/Ul63HX5dgwmu3+15kcb/JrUUs1FPwMcKRIjMij9cXBNGb7JcyLM0 WRELSy56CTvOzRVIZOH9rMNw2YNSTfvoGI6XVT9RbsHm7ed8KZZFCHFvB/S64Ym6EoLX lJOT1+6JOxwsg5iFLkMAeou1zX31h++DJjTTCNb4x+ZCCwJKpgKwlFz5VgtMEuguYCFf QPUUDEo/RdP0BoPjr+8bpYCU+kQ964zswonTrZy7hUkMpMTVjdtAzQebK06KojOv6wGk fYkA== X-Gm-Message-State: AOJu0YyDJMoVE/5732x5VlR9nt9op1RYV1Qjt9yV78vqGpiM+1kHqOtT hTYXu+mnC5c2i5t09FG94ao= X-Received: by 2002:a05:6a00:24cf:b0:68f:e810:e86f with SMTP id d15-20020a056a0024cf00b0068fe810e86fmr7799333pfv.28.1695712402114; Tue, 26 Sep 2023 00:13:22 -0700 (PDT) Received: from manas-VirtualBox.iitr.ac.in ([103.37.201.178]) by smtp.gmail.com with ESMTPSA id t12-20020aa7938c000000b00686236718d8sm9177662pfe.41.2023.09.26.00.13.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 00:13:21 -0700 (PDT) From: Manas Ghandat To: shaggy@kernel.org Cc: Manas Ghandat , jfs-discussion@lists.sourceforge.net, linux-kernel@vger.kernel.org, Linux-kernel-mentees@lists.linuxfoundation.org Subject: [PATCH] jfs: fix array-index-out-of-bounds in diAlloc Date: Tue, 26 Sep 2023 12:43:12 +0530 Message-Id: <20230926071312.14086-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=1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * 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 (howler.vger.email [0.0.0.0]); Tue, 26 Sep 2023 00:13:27 -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. Signed-off-by: Manas Ghandat --- fs/jfs/jfs_imap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c index 799d3837e7c2..ace8a1506380 100644 --- a/fs/jfs/jfs_imap.c +++ b/fs/jfs/jfs_imap.c @@ -1355,6 +1355,8 @@ 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)); + if (agno < 0) + return -EIO; if (atomic_read(&JFS_SBI(pip->i_sb)->bmap->db_active[agno])) { /* -- 2.37.2