From patchwork Fri Jun 7 19:41:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bethany Jamison X-Patchwork-Id: 1945245 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=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (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 4Vws6G2XLbz20QJ for ; Sat, 8 Jun 2024 05:42:13 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1sFfTT-0004mD-4R; Fri, 07 Jun 2024 19:42:07 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sFfTO-0004lg-OB for kernel-team@lists.ubuntu.com; Fri, 07 Jun 2024 19:42:02 +0000 Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) (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 581803F283 for ; Fri, 7 Jun 2024 19:42:02 +0000 (UTC) Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-43fb0603968so32138981cf.3 for ; Fri, 07 Jun 2024 12:42:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717789321; x=1718394121; 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=LaoegbrvwMEm0MfcgdDGfC5y1ehYHUJgdhWx1Z9Qai8=; b=fD8ONqI1jTVDcq1Tmiiud8iIgbQ6kl5SV10tSxU/3Py9n3HJ2JcwgPye7Jdj75knTN w5l62TIie31lgoC2VPyYqIjBIjAEWHk2CqGXNc79GeANhx4hidrmnuNr8cA+sxybhIfO yUFS3n+mg9Z01eu+sObTMdPvUJ8s33CR2F1EpO6DLWD29VdGZCcn2qe8EEBf6l0JO3Ey duGLXs44/C/1eQLdTux4s2wBuEVoPMxvEiUdX+CvTMYcmxo0NBTwSsob3ue0fgnAd2Fz Qao28AQPBAdssHQIza9BbLtNfKZeAED7jscOaR2ftHiFYNIZ7LnGiMH5gje3+KeqnwcT PRFg== X-Gm-Message-State: AOJu0YxxPjfcDrXgDQdflD0Ko+b1andw3vNDCk/EnIzvjCbsBN+yNSzA 1nvand/6c0+sJf4crn+IZooLBoaPHaIe8Rg/vEUfghZoCF4nJdi+RSTusX6bJRA3hi56XuxzUZL UbXh5TbbmYeiKpJaK9U/R7Aq76yFMGo+aCKcRZrElDtVtllWmiEV+6xYIM64kNqoQHb8+YRVehk BfTZscG9D9ZO0T X-Received: by 2002:a05:622a:1b8b:b0:43f:febc:45c with SMTP id d75a77b69052e-44041ce6b41mr36636431cf.68.1717789320921; Fri, 07 Jun 2024 12:42:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEKYHUUzKx2JAsAarhl1gtEsfLfbmtAyxftGDagh03EUgTb1Ryw0KVYZ4TBpFVcwPfb/zXHeA== X-Received: by 2002:a05:622a:1b8b:b0:43f:febc:45c with SMTP id d75a77b69052e-44041ce6b41mr36636321cf.68.1717789320476; Fri, 07 Jun 2024 12:42:00 -0700 (PDT) Received: from smtp.gmail.com ([2001:67c:1562:8007::aac:48f9]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-44038a690efsm14917511cf.22.2024.06.07.12.41.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 12:42:00 -0700 (PDT) From: Bethany Jamison To: kernel-team@lists.ubuntu.com Subject: [SRU][M][PATCH 1/1] ubi: Check for too small LEB size in VTBL code Date: Fri, 7 Jun 2024 14:41:57 -0500 Message-Id: <20240607194157.18188-2-bethany.jamison@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240607194157.18188-1-bethany.jamison@canonical.com> References: <20240607194157.18188-1-bethany.jamison@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: Richard Weinberger [ Upstream commit 68a24aba7c593eafa8fd00f2f76407b9b32b47a9 ] If the LEB size is smaller than a volume table record we cannot have volumes. In this case abort attaching. Cc: Chenyuan Yang Cc: stable@vger.kernel.org Fixes: 801c135ce73d ("UBI: Unsorted Block Images") Reported-by: Chenyuan Yang Closes: https://lore.kernel.org/linux-mtd/1433EB7A-FC89-47D6-8F47-23BE41B263B3@illinois.edu/ Signed-off-by: Richard Weinberger Reviewed-by: Zhihao Cheng Signed-off-by: Sasha Levin (cherry picked from commit d1b505c988b711673d6a2de35222028be081d0d1 linux-6.6.y) CVE-2024-25739 Signed-off-by: Bethany Jamison Acked-by: Andrei Gherzan --- drivers/mtd/ubi/vtbl.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index f700f0e4f2ec4..6e5489e233dd2 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -791,6 +791,12 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *ai) * The number of supported volumes is limited by the eraseblock size * and by the UBI_MAX_VOLUMES constant. */ + + if (ubi->leb_size < UBI_VTBL_RECORD_SIZE) { + ubi_err(ubi, "LEB size too small for a volume record"); + return -EINVAL; + } + ubi->vtbl_slots = ubi->leb_size / UBI_VTBL_RECORD_SIZE; if (ubi->vtbl_slots > UBI_MAX_VOLUMES) ubi->vtbl_slots = UBI_MAX_VOLUMES;