Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2237612iof; Wed, 8 Jun 2022 00:06:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmTfrYdtdLVelgkQ2O5zAEsVZwiRA5EGrt7Kq6SMe1iAji9yCDeE7LovKLembHMEmHJy6F X-Received: by 2002:a05:6a00:248b:b0:51c:4f53:a932 with SMTP id c11-20020a056a00248b00b0051c4f53a932mr3327648pfv.51.1654671996910; Wed, 08 Jun 2022 00:06:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654671996; cv=none; d=google.com; s=arc-20160816; b=iSWGMHSSqNTl4HAoDJWahFCDV9bAMFwtylCsQ1nELdZ7xA6Dy+c02GaOtq9/L6gte4 4/oSwnVl9lvb4RUmmqZltttz8EHkfKvPIpx8h1y9TYQbpmRevKcqbPayUWXsW2u+zwWn nuvTIM7yYGfp+PxNkSDAB6Ls5x0I8y1dBcwfYpcc7AvYiGqU1w3HyLcw3qWpjdEsLNmK I7VUAg8UUYWEDo28eZmoJEXJHsPrXtpGbO8kpNGM1fU5liZFTK8yQBSfRTmQrOwx8BCO dZ+q611WG/sXLeHwXnOChjwV/4S8UN4YAyJ3Cn9Re4lkrwafC4s2w25u+hX4Iuwxqnig fAUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/FPO8jQG372iLSV5nuaoiLw6AN9RwFisKPDtVnPZyqI=; b=EYDgKruRmbOmtZ9KpqWiKzJ/wxWFkf4um/j3hppVwbh1VHWxk5xxRT3x4BVcV7eunJ mLrN8i9ZdNhvcUnm1+z5N+n1jMN2TjqzCW7SsiSsLNfsG+MUtxrl8CQRPOc7JPodrQ+X ZsWIJholpd3v5C3lsJVCvQ6v9cMl5o1f5lf/P8RPWLNVj5z64mzyAtVO0imsX0SyGmHT 9WfuZRnvS5mKUe+htKx1rnkJ11tHUit9qqM0g/1zEqCT65R40ItWynPkzsaxvWadxsja prUz9ni7hMvJHc7As7bSoaxOgDi38RvKjU/25FakH2fGz5fWl6rxnQtWj6MzDqG8Vyxc rnzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1EoONYz1; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w133-20020a627b8b000000b0051896b51021si26325802pfc.299.2022.06.08.00.06.24; Wed, 08 Jun 2022 00:06:36 -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=@linuxfoundation.org header.s=korg header.b=1EoONYz1; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388902AbiFHB2B (ORCPT + 99 others); Tue, 7 Jun 2022 21:28:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385479AbiFGWbc (ORCPT ); Tue, 7 Jun 2022 18:31:32 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78E1527935A; Tue, 7 Jun 2022 12:24:42 -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 E50D3B823D0; Tue, 7 Jun 2022 19:24:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43C49C385A5; Tue, 7 Jun 2022 19:24:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629879; bh=M/NcB8WX6Wqp97huGdzefR0XgbpT9OSioDVVk20zTLM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1EoONYz1InAWVdFCJKaW10+PmiQ6H/ngSn3pczAOpxBCgYySqBLaFybotLfvdR8/R xnKjMOndDOdNzrJmelTJGPf+RTO04Eq9VhkrrxK2K6OIhhrzFrjNjZZzQ14F7zKkFj P0vQB/rRtQ0IKsfPUh24/YN9naf3C7R5RzAbxL7Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guo Ren , Guo Ren , Masami Hiramatsu Subject: [PATCH 5.18 809/879] csky: patch_text: Fixup last cpu should be master Date: Tue, 7 Jun 2022 19:05:27 +0200 Message-Id: <20220607165026.339144983@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 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 From: Guo Ren commit 8c4d16471e2babe9bdfe41d6ef724526629696cb upstream. These patch_text implementations are using stop_machine_cpuslocked infrastructure with atomic cpu_count. The original idea: When the master CPU patch_text, the others should wait for it. But current implementation is using the first CPU as master, which couldn't guarantee the remaining CPUs are waiting. This patch changes the last CPU as the master to solve the potential risk. Fixes: 33e53ae1ce41 ("csky: Add kprobes supported") Signed-off-by: Guo Ren Signed-off-by: Guo Ren Reviewed-by: Masami Hiramatsu Cc: Signed-off-by: Greg Kroah-Hartman --- arch/csky/kernel/probes/kprobes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/csky/kernel/probes/kprobes.c +++ b/arch/csky/kernel/probes/kprobes.c @@ -30,7 +30,7 @@ static int __kprobes patch_text_cb(void struct csky_insn_patch *param = priv; unsigned int addr = (unsigned int)param->addr; - if (atomic_inc_return(¶m->cpu_count) == 1) { + if (atomic_inc_return(¶m->cpu_count) == num_online_cpus()) { *(u16 *) addr = cpu_to_le16(param->opcode); dcache_wb_range(addr, addr + 2); atomic_inc(¶m->cpu_count);