From patchwork Thu Feb 22 17:45:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bethany Jamison X-Patchwork-Id: 1902904 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 4TggYN61wcz23hY for ; Fri, 23 Feb 2024 04:46:16 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1rdD90-0002ws-O9; Thu, 22 Feb 2024 17:46:02 +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 1rdD8u-0002wV-95 for kernel-team@lists.ubuntu.com; Thu, 22 Feb 2024 17:45:56 +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 02FCA3F516 for ; Thu, 22 Feb 2024 17:45:56 +0000 (UTC) Received: by mail-io1-f71.google.com with SMTP id ca18e2360f4ac-7c76a65a4aaso4716039f.0 for ; Thu, 22 Feb 2024 09:45:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708623954; x=1709228754; 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=DQTwiMJuBACVBIC14y0fs3ZHi9dbH45l71X505d5VO0=; b=Sqf1DFQVP5CMaFRhMhA/xeWrNbwxtGTP3HNUSUHsHyF5Ns1drekLBudSyJKDnPImv2 nISo01QzPYcafuGYOyeqhtR0Ayshc3LUaHlrMlI3oi9tWGjp14Q4Qd03GukWYauaNdCP 7zO1PYOXosbtthFdvBWY3l+5U2hxJ5ObQChaP3bB01rtBylGrIvXcjW9tkaMfcB0KL/9 YwezFUJkiOECT9BF9jqQARYJnckb4Rc+LMniDyHJY4lvlQsbqU16ZMl+NlOIDIYt5Kn/ MnuL73f9OXcJ8mEch5Bz6+AkAjFhuqkWzDMTeIu3oWKv4eev5ZsPHX8tOzgX8wekRuDs 3CBA== X-Gm-Message-State: AOJu0YydhQbsHCbHlHoU+UIRuiR4QpqaX13b2f3KVb1kzL3LBwq2QAI0 9d4qY2WIYh6/id2X5Y7K2fi1CN8KvIZuejtriIFS1/ZQnrf4M0mqewJ25uvrOGMbUr4gvdwrYQA CxBgeQElBuimIhkmRLXaeG7GJHml0h53J5nvlwxIBGdgkmJXzd1h2HpJTq02apbeTwO8Hr1QZxg 1EyQMr+6Cacg== X-Received: by 2002:a05:6602:f10:b0:7c4:831d:32e with SMTP id hl16-20020a0566020f1000b007c4831d032emr2586461iob.0.1708623954056; Thu, 22 Feb 2024 09:45:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IEowarSSGCFBewY7GT698UsokHQFCCjHcZ/iT83xPYQYk+hCo2u8l4ik7czwr/fqThoLO+ylg== X-Received: by 2002:a05:6602:f10:b0:7c4:831d:32e with SMTP id hl16-20020a0566020f1000b007c4831d032emr2586446iob.0.1708623953781; Thu, 22 Feb 2024 09:45:53 -0800 (PST) Received: from smtp.gmail.com (104-218-69-129.dynamic.lnk.ne.allofiber.net. [104.218.69.129]) by smtp.gmail.com with ESMTPSA id 19-20020a5ea513000000b007c77ccee7f8sm640422iog.38.2024.02.22.09.45.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 09:45:53 -0800 (PST) From: Bethany Jamison To: kernel-team@lists.ubuntu.com Subject: [SRU][Jammy][Focal][PATCH 1/1] scsi: lpfc: Fix a possible data race in lpfc_unregister_fcf_rescan() Date: Thu, 22 Feb 2024 11:45:51 -0600 Message-Id: <20240222174551.54413-2-bethany.jamison@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240222174551.54413-1-bethany.jamison@canonical.com> References: <20240222174551.54413-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: Tuo Li The variable phba->fcf.fcf_flag is often protected by the lock phba->hbalock() when is accessed. Here is an example in lpfc_unregister_fcf_rescan(): spin_lock_irq(&phba->hbalock); phba->fcf.fcf_flag |= FCF_INIT_DISC; spin_unlock_irq(&phba->hbalock); However, in the same function, phba->fcf.fcf_flag is assigned with 0 without holding the lock, and thus can cause a data race: phba->fcf.fcf_flag = 0; To fix this possible data race, a lock and unlock pair is added when accessing the variable phba->fcf.fcf_flag. Reported-by: BassCheck Signed-off-by: Tuo Li Link: https://lore.kernel.org/r/20230630024748.1035993-1-islituo@gmail.com Reviewed-by: Justin Tee Reviewed-by: Laurence Oberman Signed-off-by: Martin K. Petersen (cherry picked from commit 0e881c0a4b6146b7e856735226208f48251facd8) CVE-2024-24855 Signed-off-by: Bethany Jamison --- drivers/scsi/lpfc/lpfc_hbadisc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c index 816fc406135b3..e01a5f30e4e5c 100644 --- a/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c @@ -6967,7 +6967,9 @@ lpfc_unregister_fcf_rescan(struct lpfc_hba *phba) if (rc) return; /* Reset HBA FCF states after successful unregister FCF */ + spin_lock_irq(&phba->hbalock); phba->fcf.fcf_flag = 0; + spin_unlock_irq(&phba->hbalock); phba->fcf.current_rec.flag = 0; /*