From patchwork Tue May 23 01:57:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cengiz Can X-Patchwork-Id: 1784736 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=v6HpO9mK; 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 4QQHXX5Qk2z2020 for ; Tue, 23 May 2023 11:58:20 +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 1q1HHy-00005v-5G; Tue, 23 May 2023 01:58:14 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1q1HHw-0008WC-Ez for kernel-team@lists.ubuntu.com; Tue, 23 May 2023 01:58:12 +0000 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (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-1.canonical.com (Postfix) with ESMTPS id 1D84E41A39 for ; Tue, 23 May 2023 01:58:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1684807092; bh=gDfxnqevu6Sbgotwy6umAIQ3plPXYtcku45QBnhXW9w=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=v6HpO9mKRG+ny+3MHTOVFy7wqJC1J4s/fSCno/5C/Pj3D0CifYuBoBy2lmroR4nk0 VgZUFNIgARvR4ErMh7I2BJPn33OrxzfbrU7Oy0WDQn0V1009sMqXiP2velVzV6Rih7 mPK4fiIjZHZJstWtQbKz5aeTLvOv0c96h7Z1tUetRYaTDDxxn3q4TBtBNMSn0nQfPn 5OSjhV2xO7dDMgqiWc1QWphofKQt8jtTunigtIPNQCKbxdypym6miqzznvNY3jZ/wr 0SpdMICRmd8vvuJc2tMQTgfdgNZJPqDxiD60zxFuePQbzhDc5SyNRo0DslVG4H79QI aSTQiGrMTrZqg== Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-5118fc8abd0so316622a12.1 for ; Mon, 22 May 2023 18:58:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684807090; x=1687399090; 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=gDfxnqevu6Sbgotwy6umAIQ3plPXYtcku45QBnhXW9w=; b=D6bSK/112VbkU3T8RGeIT/zsRb6EEZj3tmpRzK9RnZ1fyD92WQbG50gQaIQG68hIWv AwY+e62zFyuufRxt5GuJcl9RzHEzy2eh+SPNOz4VpiAqwK4+SSg5m67ZtavqVPAiyw5i 6FDldVlZ5lS0XbPdwFDMVSEngVpRmF6EzWYnxm8s4pnGeQmIWRJNRBl9KHd2mmdahaPY nhMVzFUmFrKgkOAxjaG7vGMjW0z5Qb/QhWJG9O8GoERWJkjMl8zs7NSZr6p6GzbYu1ZZ YociWPdrIevMKeP3h9CY587vfH2jwksLFhQNwhpVd/itJRzhYi3+SEZ4N7Ho+qwMSVYa ANDQ== X-Gm-Message-State: AC+VfDydXFUIrK7eab7ySkmGEd2gH1JvUkgZ003an+csFrwODVzgWS/K jDs+aFKo+u1akXyhlYt1nPLooJAD0ylxKRCf2U7J/gmPJt1JRnsfapN4mewXLNgElJspUCGiv8A R6wI7aFv6gVHXJtgq3dnD+FmDAvDcKJzC4eCv+PmGKZgcFB0aMNlWQHY= X-Received: by 2002:a17:907:7e9c:b0:96f:7483:529c with SMTP id qb28-20020a1709077e9c00b0096f7483529cmr12276230ejc.30.1684807090474; Mon, 22 May 2023 18:58:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5kOWbjIN7WOFLsg5RMvxfh1d7DAJvCvB0JFb0K08Qi2Aps8xRFJCpblxF1qZ3SaAfY3fBMFg== X-Received: by 2002:a17:907:7e9c:b0:96f:7483:529c with SMTP id qb28-20020a1709077e9c00b0096f7483529cmr12276221ejc.30.1684807090174; Mon, 22 May 2023 18:58:10 -0700 (PDT) Received: from localhost ([82.222.124.85]) by smtp.gmail.com with ESMTPSA id n22-20020a170906689600b0096a5eb2836asm3714577ejr.203.2023.05.22.18.58.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 May 2023 18:58:09 -0700 (PDT) From: Cengiz Can To: kernel-team@lists.ubuntu.com Subject: [SRU OEM-5.17 PATCH 1/1] fs/ntfs3: Fix slab-out-of-bounds read in ntfs_trim_fs Date: Tue, 23 May 2023 04:57:55 +0300 Message-Id: <20230523015753.43167-2-cengiz.can@canonical.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230523015753.43167-1-cengiz.can@canonical.com> References: <20230523015753.43167-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 aa184407520f..7f2055b7427a 100644 --- a/fs/ntfs3/bitmap.c +++ b/fs/ntfs3/bitmap.c @@ -1432,7 +1432,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;