From patchwork Tue Jun 25 20:57:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bethany Jamison X-Patchwork-Id: 1952258 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 4W7xx14WCdz20Z9 for ; Wed, 26 Jun 2024 06:57:40 +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 1sMDEB-0003TG-RB; Tue, 25 Jun 2024 20:57:23 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sMDEA-0003St-8l for kernel-team@lists.ubuntu.com; Tue, 25 Jun 2024 20:57:22 +0000 Received: from mail-io1-f71.google.com (mail-io1-f71.google.com [209.85.166.71]) (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 EBA523FA91 for ; Tue, 25 Jun 2024 20:57:21 +0000 (UTC) Received: by mail-io1-f71.google.com with SMTP id ca18e2360f4ac-7eb7e13522bso912710339f.1 for ; Tue, 25 Jun 2024 13:57:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719349040; x=1719953840; 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=8uuoAI8kDrx0Eq7xkdEu4I2lL5nqBFtiRI/ySfZgiXo=; b=b1gJnCwVJVTiahsj1uEWuXaSxs3qQUEY7W0S5eZX+7VnZRZzqlZF+wGLQwKaveSqZa Q4wcMhnqQ6Hf3JImMaHecmlOb84zEzFzCty7LmOJGJnE7FZss3IUNFWwtFe26OjDvsIt uIUIIIBPMeKeq5XH+AkiRMEz5klyazCOyNenbbYMnzigj4w7QQrerA1rljo/qQQEQfwF iwu+kgWbwm8DWg8xAbwBArZ6cAJKZw5peNjrkbqlmn3bxkoX0+53WXxoJnwcGFrEQXly gHbH4deZl2KDF4HCcNd4FXqC1Iqu/fZsqiGPku4iMBaRkqlvoF3/Y5UnYw4Ty6ZFyU0v k06g== X-Gm-Message-State: AOJu0YwnXPUkoQtYrLjP+XHpXmEgnK8uMu3M4naeNbgQhR3By4ZpT34f adBgfYZerOfjBRsYRNRYh+7gq9BFaZU+ZgL+Y0FmMzdbo3f4Klb29xobX25KFNnoOnw36MpvdiH 9H/4NBHQI1/fU9e58H32pTPj7HNd9svtM+/6N+5mIJ2eYliFBxRQH9oMXUHK5ZGopbL/HWMa9qN Lijld7sXkpQw== X-Received: by 2002:a05:6602:1655:b0:7eb:f3c8:c59b with SMTP id ca18e2360f4ac-7f3a7592b5amr1263113239f.2.1719349040485; Tue, 25 Jun 2024 13:57:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEEbR18h5ZaK7aiIoKdUmR3m3ARtmzTOnTI0wJZBjEW/k9wBxV8wutXoFd213rGlo50NacDtw== X-Received: by 2002:a05:6602:1655:b0:7eb:f3c8:c59b with SMTP id ca18e2360f4ac-7f3a7592b5amr1263111939f.2.1719349040139; Tue, 25 Jun 2024 13:57:20 -0700 (PDT) Received: from smtp.gmail.com (167-248-51-36.oa02.lnk04.ne.dynamic.allophone.net. [167.248.51.36]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4ba0824fe1esm847985173.18.2024.06.25.13.57.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jun 2024 13:57:19 -0700 (PDT) From: Bethany Jamison To: kernel-team@lists.ubuntu.com Subject: [SRU][N][PATCH 1/1] i2c: smbus: fix NULL function pointer dereference Date: Tue, 25 Jun 2024 15:57:18 -0500 Message-Id: <20240625205718.26479-2-bethany.jamison@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240625205718.26479-1-bethany.jamison@canonical.com> References: <20240625205718.26479-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: Wolfram Sang [ Upstream commit 91811a31b68d3765b3065f4bb6d7d6d84a7cfc9f ] Baruch reported an OOPS when using the designware controller as target only. Target-only modes break the assumption of one transfer function always being available. Fix this by always checking the pointer in __i2c_transfer. Reported-by: Baruch Siach Closes: https://lore.kernel.org/r/4269631780e5ba789cf1ae391eec1b959def7d99.1712761976.git.baruch@tkos.co.il Fixes: 4b1acc43331d ("i2c: core changes for slave support") [wsa: dropped the simplification in core-smbus to avoid theoretical regressions] Signed-off-by: Wolfram Sang Tested-by: Baruch Siach Signed-off-by: Sasha Levin (cherry picked from commit 357c64ef1ef39b1e7cd91ab6bdd304d043702c83 linux-6.8.y) CVE-2024-35984 Signed-off-by: Bethany Jamison --- drivers/i2c/i2c-core-base.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 3bd48d4b6318f..5e2cefb37e1a4 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -2200,13 +2200,18 @@ static int i2c_check_for_quirks(struct i2c_adapter *adap, struct i2c_msg *msgs, * Returns negative errno, else the number of messages executed. * * Adapter lock must be held when calling this function. No debug logging - * takes place. adap->algo->master_xfer existence isn't checked. + * takes place. */ int __i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) { unsigned long orig_jiffies; int ret, try; + if (!adap->algo->master_xfer) { + dev_dbg(&adap->dev, "I2C level transfers not supported\n"); + return -EOPNOTSUPP; + } + if (WARN_ON(!msgs || num < 1)) return -EINVAL; @@ -2273,11 +2278,6 @@ int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) { int ret; - if (!adap->algo->master_xfer) { - dev_dbg(&adap->dev, "I2C level transfers not supported\n"); - return -EOPNOTSUPP; - } - /* REVISIT the fault reporting model here is weak: * * - When we get an error after receiving N bytes from a slave,