Received: by 2002:a05:6a10:87d6:0:0:0:0 with SMTP id g22csp511815pxr; Sun, 10 Apr 2022 23:13:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1vxs7mUeKkQX2V6pRPpwpA/hqN09oyFYiysBMxtsiUVb7Fuj2O83v2aWEo+bEWJgpGUr6 X-Received: by 2002:a17:902:d501:b0:158:5995:9f8c with SMTP id b1-20020a170902d50100b0015859959f8cmr4672923plg.100.1649657637987; Sun, 10 Apr 2022 23:13:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649657637; cv=none; d=google.com; s=arc-20160816; b=LyrpWFRWVifv5euusuQyNV6XE6mhZiGrmYTg2C7b7wTGpVt3PllN8jL89oALa+oZFA lPkwdZawG6WsUw+9dBvI8AYobNEKZZk6Ih1yfulMvAi0koSZtqhZTpEmT/yNDL+g78Kk nQp/jQgbjRinQmg58Z/EHxDgYlestgNVG1d5T108gSFQ/4TAOXXWDEImzjmLR3RsZ+eS 3hpkVZxK4WWG92Fva7Ua0H8eaMG9yyQJaAwrSi6rAbnMHRAknlfHJ8Fgh8BvlE613CjZ 8A/xDaUBV/KSOYOUvssTn+DL9TbLJCY6sDl7ZwnYoGvNqMcO/uLB0ZB/Tw3iCRyVuAki N42A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=W71Acp0PzqN+lgRMFEmZCI4/78Fn6di5IOC2UulD4H0=; b=zQI/Z2qrtAmAOmmM/ji3PjgQ3C6uCQuE8aeoEVCBnc+Ok3KeSJpoBmPexPF44WKAyY AkBtOq3Ch/fqvWSCOrQEIwbZdAVku360Bm3j2K7hFC4bigiN9mz7HM7KF5yfBl2bJjSb LGAhUB0UG0W1RgdNZ+aO6FVIKewFezrv05M2yI6w2iqnkIOqLZM7E+LQuSfFnVBpTZPW xNcGLJ1Wh7dWiPE4PF/k2ay4ZaVthuMNGueK0VRSDIOnHAltQkyYLU7MT677fm31ponE uiX2AToUniXsSHeNbTS7KC31auHGwCnylXgsnZzvF5V01IgaOjLvaPlwDUmaYaNX7IGm LtYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WoNz2bF6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a25-20020a634d19000000b003980aecb0d8si8246020pgb.556.2022.04.10.23.13.44; Sun, 10 Apr 2022 23:13:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WoNz2bF6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232744AbiDHQiR (ORCPT + 99 others); Fri, 8 Apr 2022 12:38:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232671AbiDHQiP (ORCPT ); Fri, 8 Apr 2022 12:38:15 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA9E0E886C; Fri, 8 Apr 2022 09:36:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6FDDDB82A1D; Fri, 8 Apr 2022 16:36:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 263C7C385A3; Fri, 8 Apr 2022 16:36:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649435766; bh=K5Kb3Xp0nCtSmnffNpkwtXLSVOyZuSrWwz3IcdaEMsg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=WoNz2bF6JO0f/m2ru+xTXSU2mwhtzBKkDAtQZn+Uaryd6WxxDeiYxn0a+MGIN4e+0 1F22ktcK6ICMlzaCXccBwbv79SK3QJdLiapBugH9E6tgGfD3EKmD+w5jqopJ73GCve EyMxOp0ckbP6T19dkF3aKe7HpIegg0x/+dFEi4PaZpi2gaQ9HdLNEg5fixdSNwam4T ddYGwQXQ5aHe9+BHkEjg/12Dw6YuZWerS9t0U23OsoDQarHu1pqd2FTzIz1gbhgl4C e0rR/O9ZRq9yUxODI2O1CZ+2NZhyp6UuP4mVmcziWVlvGnPWqnFQ181ih/jOXTSjJn TBt/gq1632CxQ== Received: by mail-yb1-f172.google.com with SMTP id w134so16029149ybe.10; Fri, 08 Apr 2022 09:36:06 -0700 (PDT) X-Gm-Message-State: AOAM531FUb+y9ivPz2iB9PXHfGgol2+GUNbHuzv8t3TtjKJ5KMI7VjEk FM1XZ7qkwLi/rYKBpX2TqnGJr6W1Uo3ped+/1H0= X-Received: by 2002:a25:6909:0:b0:63d:afc8:8b01 with SMTP id e9-20020a256909000000b0063dafc88b01mr14441952ybc.561.1649435765226; Fri, 08 Apr 2022 09:36:05 -0700 (PDT) MIME-Version: 1.0 References: <20220408083728.25701-1-xiam0nd.tong@gmail.com> <20220408122348.bt7lkaumwhv36a2q@fiona> In-Reply-To: <20220408122348.bt7lkaumwhv36a2q@fiona> From: Song Liu Date: Fri, 8 Apr 2022 09:35:54 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3] md: fix an incorrect NULL check in does_sb_need_changing To: Goldwyn Rodrigues Cc: Xiaomeng Tong , Guoqing Jiang , linux-raid , open list , stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 8, 2022 at 5:23 AM Goldwyn Rodrigues wrote: > > On 16:37 08/04, Xiaomeng Tong wrote: > > The bug is here: > > if (!rdev) > > > > The list iterator value 'rdev' will *always* be set and non-NULL > > by rdev_for_each(), so it is incorrect to assume that the iterator > > value will be NULL if the list is empty or no element found. > > Otherwise it will bypass the NULL check and lead to invalid memory > > access passing the check. > > > > To fix the bug, use a new variable 'iter' as the list iterator, > > while using the original variable 'rdev' as a dedicated pointer to > > point to the found element. > > > > Cc: stable@vger.kernel.org > > Fixes: 2aa82191ac36 ("md-cluster: Perform a lazy update") > > Acked-by: Guoqing Jiang > > Signed-off-by: Xiaomeng Tong > > Also safeguards from reading sb from a faulty device if all devices are > faulty. > > Acked-by: Goldwyn Rodrigues Applied to md-next. Thanks!