From patchwork Tue May 16 00:05:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cengiz Can X-Patchwork-Id: 1781725 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=bmtYEiV3; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QKxMm4J1Tz20dg for ; Tue, 16 May 2023 10:05:40 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1pyiC5-00006F-Kc; Tue, 16 May 2023 00:05:33 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1pyiC4-00005Y-BP for kernel-team@lists.ubuntu.com; Tue, 16 May 2023 00:05:32 +0000 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id D4BB13F177 for ; Tue, 16 May 2023 00:05:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1684195531; bh=MxhE0agzwEdcSp9m5zmkq8iFJJjbztW9Ndnmwfyc0uU=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bmtYEiV3K7tadr9i5p5skmuRwBzf2mH28yjyfjmps/M1BMEN5JebloacAPQr7Xc+b zZHZHDsYYvKw2j5mAvF1X1ACg9XA/wcoyw4udHv5UUrI65Io13YQgeYxTd5awjevxz HyrdXFvGxsXFCQftMQsROcfaCucPy3qUx7RY1z+iO9/tp9eBbeW1oDlszR4UZlAsKH Zmv829KLp+0vWAGcDXAp/itkxmI0OHFpn+7m/yAu6Zj2FI1WBBoXsHJruPMSCh/PTS PrFDyt6XNAq0Zu05ViHi7gPDtaEmSGmxpsiTArpWCiNb20WLaanptk0PbjXRZMoFci FwbYbFInMtxzA== Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-3f453ff4cdfso25116135e9.2 for ; Mon, 15 May 2023 17:05:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684195531; x=1686787531; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MxhE0agzwEdcSp9m5zmkq8iFJJjbztW9Ndnmwfyc0uU=; b=LYgXP7zyI1v+verqmJVXAV5T+HdbhwCfaSVVODVmbIdQakcAFstfvB/upuei5KbRyM yCaXuP1ttF5wk+mfAd8AbyY0U96mH6AinJRsRcMZMLSFO1XePMnDO8fs24WPoViB4tTR nKc+4+MQaBYp6JWCGlKD2wllhICeohPSoK0U1u1YFjojKPgA/kSwt3/708oPxT8gFz5d OB3wRhqG4dxc36AM1SSFn1czG5rUat/qu6HyHo04+YOprjFHRsHWKKW364+oBEXuCh6R LMfXPEpQjne14BHqMUSEyXLJ8iRAOrCErmF+UYmJLGMH1IQMEqGMzvkO4SdOB33dDx8c izeQ== X-Gm-Message-State: AC+VfDwGBVQdD2H9cDXXMJ6gMDyhOcwEdEN8XqmbcHLRYBjdhS+a9I1g VuCd5gEC7nkp+3JNeod3JrR1xE02LIv05skgkh8k6plUjUuS/AV8DUdvvq9T8BelwXHcYsNlky1 9CR5uSC6FV9pMd5y8krCCpB0Ey/G+W4WfLNsh8dNXFkcLJPs4u3Qp X-Received: by 2002:a05:600c:3782:b0:3f4:5058:a033 with SMTP id o2-20020a05600c378200b003f45058a033mr14146366wmr.24.1684195531003; Mon, 15 May 2023 17:05:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5CIDOAw0UgNtQvDqKsyPHyV9HnId8Kq+Bkuql/GtvjIdWOOess4M8DkIS19jNoYGPk/3Aslg== X-Received: by 2002:a05:600c:3782:b0:3f4:5058:a033 with SMTP id o2-20020a05600c378200b003f45058a033mr14146361wmr.24.1684195530813; Mon, 15 May 2023 17:05:30 -0700 (PDT) Received: from localhost ([82.222.124.85]) by smtp.gmail.com with ESMTPSA id u15-20020a05600c00cf00b003f4f89bc48dsm425308wmm.15.2023.05.15.17.05.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 17:05:30 -0700 (PDT) From: Cengiz Can To: kernel-team@lists.ubuntu.com Subject: [SRU OEM-6.0 PATCH 1/1] fs/ntfs3: Fix slab-out-of-bounds read in ntfs_trim_fs Date: Tue, 16 May 2023 03:05:00 +0300 Message-Id: <20230516000458.254067-2-cengiz.can@canonical.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230516000458.254067-1-cengiz.can@canonical.com> References: <20230516000458.254067-1-cengiz.can@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Abdun Nihaal Syzbot reports an out of bound access in ntfs_trim_fs. The cause of this is using a loop termination condition that compares window index (iw) with wnd->nbits instead of wnd->nwnd, due to which the index used for wnd->free_bits exceeds the size of the array allocated. Fix the loop condition. Fixes: 3f3b442b5ad2 ("fs/ntfs3: Add bitmap") Link: https://syzkaller.appspot.com/bug?extid=b892240eac461e488d51 Reported-by: syzbot+b892240eac461e488d51@syzkaller.appspotmail.com Signed-off-by: Abdun Nihaal Signed-off-by: Konstantin Komarov CVE-2023-26606 (cherry picked from commit 557d19675a470bb0a98beccec38c5dc3735c20fa) Signed-off-by: Cengiz Can --- fs/ntfs3/bitmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ntfs3/bitmap.c b/fs/ntfs3/bitmap.c index 5d44ceac855b..087282cb130b 100644 --- a/fs/ntfs3/bitmap.c +++ b/fs/ntfs3/bitmap.c @@ -1424,7 +1424,7 @@ int ntfs_trim_fs(struct ntfs_sb_info *sbi, struct fstrim_range *range) down_read_nested(&wnd->rw_lock, BITMAP_MUTEX_CLUSTERS); - for (; iw < wnd->nbits; iw++, wbit = 0) { + for (; iw < wnd->nwnd; iw++, wbit = 0) { CLST lcn_wnd = iw * wbits; struct buffer_head *bh;