From nobody Sun Feb 8 09:37:14 2026 Received: from mail-ot1-f54.google.com (mail-ot1-f54.google.com [209.85.210.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2252523EA86 for ; Fri, 16 Jan 2026 17:21:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768584078; cv=none; b=pEaSITrzQIFOEMnyE+xzWUPP9fZrA6HFabJ3z0crvhrmC9U2WdEoimbpykUL2Yip6a6Znu1UxjdkuKczBBlo0ZX3VNtO5GLHsCoepc3W1gEYUoT6lXbJto8UQqrQIYyBmuM6ObiYVZJyNQxy7/ep5CwUB8E1c/IYa08hREB5hXc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768584078; c=relaxed/simple; bh=Xf4JjRB+mAxAAVdinN9sGty1wOzBtYvIa/X7J1pOO8U=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=jJgb/T6gw0ONvYAxlU6fyRogeLojnEnUT6oGCuXpAOFBS4vM6oI9So0xbObT7tor1ZiV3rKPtRLpEO3PMdu7Hk42X43MZgtFGoPL+Hecxsy89+crlOq458BRo21i9WTUVoVJxeEhRU4WiztP9v0ifMBtFifKP6UjRtZ2VR0FsNw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=nBt/9IjO; arc=none smtp.client-ip=209.85.210.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nBt/9IjO" Received: by mail-ot1-f54.google.com with SMTP id 46e09a7af769-7cfcb46ffc9so1949232a34.0 for ; Fri, 16 Jan 2026 09:21:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768584076; x=1769188876; 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=Zf9dSIrVB8N6LEydMPNXWv5oWKXC/LlZlb8Q7vsNEbc=; b=nBt/9IjOUyeFHbDgdHtXW8O1bVqDmTRbbfta2s7VkfMWPHhLkqoT2Cr+CND5MV4JgC L+xNzeK74CLXb5D3nORwMZeryQJf7OOwSip/YF6v1CuE7Bb1/CIX6UbIwO4VpmpuyLWU IvpiGVkqbqNG7WpoSKd+Z7s3xCqorWE/uHAXndWk/jNrFGN+ZpGsy3zDL+ltK4KvZ+lD 2JovZmZrwsHiMEVxFK5GjzY9IHHVWSDkBG5UY5+4DRm0F47X8MM5TPEIAV1CsaVYFM3w YVM+gxg2Tm3t//7jqtx4rziazED10/eM9fGj9JnYbM9C1fn5hC7c/gXXvnOTcnN77QqO UxWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768584076; x=1769188876; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Zf9dSIrVB8N6LEydMPNXWv5oWKXC/LlZlb8Q7vsNEbc=; b=M6Nr0owE10a/5tw2FahkawbaUthijLbb0IHiRu26egVAHZeLIedplKN8ky5AifyIGK s98JpJ3GgwrT3UI51g3o/uDV6uume/+/qpdxdozhQ2c9qKO2hzaE06XQoPkaFPRp0/NJ DiH9g2cVVCYPbhaVMCyyNBhhzwS0bEHFlvlx2bA4MMgkNRVIxRwma7iL5ggg1bi5DdX3 OmbcxUWwhBCLkxDRUpxrhCsFt8pwNphghrTilV0UE+2fpv32TNu9Vg2YXCIB/JUxJHgE RMfLI08pO3NDwpqFOOMGG0SSzcNxgDOdfYhXtCM3Lj667zxcOwnw0rHY7kVqt2PnUQVF dALA== X-Forwarded-Encrypted: i=1; AJvYcCW1eq+K/qZpK/Gxm1dno/Y5E34Dl+V+W5eJ7/1MWb3J7ksEQFhdzeULY9s1QEvICBjvwc1oK8pRP9elSOQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxN5XmSXy6FIWT+6zqsc/ljX2kWeU6w+nBHWZ15nkLO5AQYZbZ7 RGnmTN3RwIuqr6XnOsTE+2BP/AwK7wunxuzipbTu1hILy4+REZcZ4Rto X-Gm-Gg: AY/fxX5O8o3KUQdGbhDVdS1zEHOCqA6ITaWUvhlNvs9hqo8E2IcmHsSuhKkU1N+7tV6 eDziSEmkb++uim6b8hNfDEsH4zUEq0eJV7/vSOn8tHmYqW/SNdNod9AxF9npjMcoIWsrcsY+wzi 1u70jZMK4isCRVtGQZgk+nBPZJW5sLe8cGVuiVN00BeLWCA74JWH8m/HTCFoCNC4qgoURgzi5hF NoPZTNuyXWeJlpU3Oo9uyydRi8OrYKxXTDR3PfNCOaRLiUY0rLnYPVQV2sSHEFJTdFO/N7Vp9ek 4dP1ynIvf4eZQVhTNwYPpyztCnM498FqlCfp2q1fPRP1iZ5WKzo/+DepKkRjlL7pKFmWA1Wqanr cZaJNS7Ywy6SUMi7TPdJTe4GYAJbRFp372hniB2Myck1N2IZmEMf6noG9gVjHCzog+anqc/tIiH DOndhPt0R6mC+Phywuuyu73M47vrQQ5bEXvbOyEMz4xCU= X-Received: by 2002:a05:6820:458b:b0:65c:714e:efc7 with SMTP id 006d021491bc7-661181255ffmr1332935eaf.33.1768584075980; Fri, 16 Jan 2026 09:21:15 -0800 (PST) Received: from newman.cs.purdue.edu ([128.10.127.250]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-4044bda443asm2027980fac.22.2026.01.16.09.21.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jan 2026 09:21:15 -0800 (PST) From: Jiasheng Jiang To: Mark Fasheh , Joel Becker , Joseph Qi , linux-kernel@vger.kernel.org Cc: ocfs2-devel@lists.linux.dev, Jiasheng Jiang Subject: [PATCH] ocfs2: fix slab-out-of-bounds in ocfs2_rotate_requires_path_adjustment Date: Fri, 16 Jan 2026 17:21:13 +0000 Message-Id: <20260116172113.22143-1-jiashengjiangcool@gmail.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In ocfs2_rotate_requires_path_adjustment(), the variable 'next_free' is assigned the value of 'left_el->l_next_free_rec'. This value is then used to index the 'l_recs' array as 'next_free - 1'. If the filesystem is corrupted or in an unexpected state such that 'l_next_free_rec' is 0, this leads to an array index of -1, triggering a slab-out-of-bounds access. Other functions in alloc.c, such as ocfs2_rotate_leaf() and ocfs2_update_edge_lengths(), effectively guard against this condition. This patch adds a similar check to return 0 immediately if 'next_free' is 0, preventing the out-of-bounds access. Signed-off-by: Jiasheng Jiang --- fs/ocfs2/alloc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index 58bf58b68955..b15c6f751d99 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c @@ -2327,6 +2327,10 @@ static int ocfs2_rotate_requires_path_adjustment(str= uct ocfs2_path *left_path, =20 left_el =3D path_leaf_el(left_path); next_free =3D le16_to_cpu(left_el->l_next_free_rec); + + if (unlikely(next_free =3D=3D 0)) + return 0; + rec =3D &left_el->l_recs[next_free - 1]; =20 if (insert_cpos > le32_to_cpu(rec->e_cpos)) --=20 2.25.1