From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.72 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796407343; b=mweghMVE18BLrfrkzU5gqugCdN2KqpqZR6ra0iDD5m+OPm7jNUV/25HWZf5J5pwfLb4b +c/PUvYN8X3gS0iJ/btASk2J+lkqFNp/suuMpEU1euyEdRCn8Z7sT1nSW/xWqSjfRvxUa nxpzVg21iVvD9qVH8pKbFpLeNvqxj/S8BMTl2lm3DOg1YFTu5NmOqaVaUGQ3aOglURf2N k18zxAtn+dV/qHp8sKi9jhOw1qx7XN6FzSzdT6Y1nu0qGaDWlUftnOeEHLVrJPZA7cymS B1JrsraB6RRJ3Yub3MuovYjzMvlA/UluHrwF8+pO7hHvFVybC60a3hjo+qhZzykOqog== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796407343; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:X-Mailer:Message-ID:Subject:From:To:Cc: Content-Type; bh=yMf/SnZybGHUx54zVpw61vn9afMssTN6/20iKgIOxGM=; b=phJRMG6h+dA0AznI3TstdffFsh2HFStsu9ou4l1aiKcLLo8xhqPKNtmVZZKX6XPBTsNB DjdJ3F4HGCrW/PsRynamkzc4cwmumdEIXyDx3obdXJBw3wN/btV4xornFv/7zyrZbW9RV L5+are5y8UpoGrHXxP7ByikfzGzHYo+SQdoRblhDk04dzxYzF+Oy1ECf/DSGWAw6QcUNS zX80+SIlBIalnzbswnwCi4PcbmjNmtWPbmc59nlXGm6hm22LDOpHHhogmtIMEnVTyVqPO GIbpsjWuDjwGSKPG83nuxGZFgT+/mnEayV1hSo7E3IMmGaUaKBUcz13q1cWa9v6yGxQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--chuyee.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b="K/wyLJRe"; arc=none smtp.remote-ip=74.125.82.72 Received: from mail-dl1-f72.google.com (mail-dl1-f72.google.com [74.125.82.72]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5C612606A33D for ; Fri, 4 Dec 2026 18:02:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5C612606A33D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--chuyee.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=K/wyLJRe Received: by mail-dl1-f72.google.com with SMTP id a92af1059eb24-1b5d5f27b91so1890517c88.1 for ; Fri, 04 Dec 2026 10:02:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796407342; x=1797012142; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=yMf/SnZybGHUx54zVpw61vn9afMssTN6/20iKgIOxGM=; b=K/wyLJRe5vm6SK6TgQwYWdWjrDr7g6zbkGtJohBCs4Vcl3NASuipyw1mXsv4Wx1KCi fNV89oCNtEqGhwzTC7LMzISyuF+oyH18gINXx2Ufq2xX+iRwLrnjyv/UNK8fyg8SSbJJ GlusVlU+09DNxOaU+2rx87N3M5O6NJn3O3uKQjpYlxoq1qE4fYpoeJ/RsT9ivn+gB8FR O67HMHx7a5u4HjoioeSlu5COTKo9MRdWCvzIPasNbwcImvnpIzFXLUBdySA7cqO+0R+D YXHCzKUPOrkIyZCaZRng8vADYqdcbgQxDNpk9oGFbexrEcb8PlJquM5X1CRH+Yo4dauy WjLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796407342; x=1797012142; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=yMf/SnZybGHUx54zVpw61vn9afMssTN6/20iKgIOxGM=; b=jMa9RCmRmwkM8kcjfuoIPBslUfFcmKPXrg+RvIrGYGmDR9W0zeqGP6wuDxu+YEXItv vpJ52+fq9q+E4AuF6kKN4o4TVYIc9Onwf/uhhw08JUjRcEaM4yJM6GI5Ajpu4TMcmAKW XKRLbEV6DW+/1uvmp6YGyXSOYlE+idd5cs6GZhu64WFQ1rXj/bL21oLmPPY16lbw29W2 G4V16K6ufTTOxf7wgM1sul/EMApGMR023U9B+pHfgGh0lwFMUFv7fJG1oJtReo8DBZFh Uv4cMU8qOM1fD+VRKwscJmarpcekCqWw8FuM2IC7Dxs2qDBs26eBkavXGl5vb6sOVAV2 S9qQ== X-Forwarded-Encrypted: i=1; AL+hErE1AVAPewg6GIwwga2UYygpal/pjE08SkvsjAJpveXJjtDivWh5dFxR3DhpuUBXH1BX2UKlJ060Y9xAa4s=@vger.kernel.org X-Gm-Message-State: APuU4Z86CvjZbta6IqwCIpEh1D1LhFP4pB99hqsXiFsk+7D5q68bLfM6 quMrwvVoGCQI8HcwMduQjY/lscv5AxKLmb9/7XzuTv+DjDXemBqysb39ARKPMjSs0Wa9jPUmE5z 0PZPNgQ== X-Received: from dlbps10.prod.google.com ([2002:a05:7023:88a:b0:1a4:c892:b166]) (user=chuyee job=prod-delivery.src-stubby-dispatcher) by 2002:a05:701b:270e:b0:1b3:b53e:b4cd with SMTP id a92af1059eb24-1b5d70f488bmr2617202c88.21.1796407342159; Fri, 04 Dec 2026 10:02:22 -0800 (PST) Date: Fri, 4 Dec 2026 18:02:21 +0000 In-Reply-To: X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <370addaa39777621da6828eea8e1d0b17bc26b2e.1796357900.git.chuyee@google.com> X-Mailer: git-send-email 2.56.1.987.g2ec0ab4260-goog Message-ID: <20261204180221.1862093-1-chuyee@google.com> Subject: Re: [PATCH v2 3/3] livepatch: check task stacks against a sorted range table From: "Zhu, Yi" To: sashiko-bot@kernel.org Cc: Josh Poimboeuf , Miroslav Benes , Petr Mladek , Joe Lawrence , Song Liu , Wilson Felipe Pereira , Dylan Hatch , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" On Fri, Dec 04, 2026 at 05:25:38AM +0000, sashiko-bot@kernel.org wrote: > [Severity: Medium] > Can range->name become a dangling pointer to a freed func->old_name while a > reader still uses an older klp_stack_ranges table? > > For a dynamic NOP in a replacing patch, func->old_name is freed synchronously > with kfree() in klp_free_func_nop(), whereas klp_stack_ranges is freed with > kvfree_rcu(). In klp_complete_transition(), klp_discard_nops() runs before > klp_synchronize_transition() and before clearing klp_stack_ranges. [ ... ] > Because obj->patched is already false and klp_resched_disable() does not wait > for preemption-disabled readers already in __klp_sched_try_switch(), > klp_discard_nops() can free func->old_name with no RCU grace period. If > CPU1's stack matches the stale range, pr_debug() reads freed memory. This can only happen with a forced transition, and it isn't new with this patch. Without force, the transition can't complete while a task is still failing its own check in __klp_sched_try_switch(): it hasn't switched, and other CPUs get -EBUSY trying to switch it while it runs. With klp_force_transition(), the existing per-function check has the same window and is worse off: it walks the NOP funcs that klp_discard_nops() frees, not just their names. Like the race fixed by patch 1, this dates from e3ff7c609f39 ("livepatch,sched: Add livepatch task switching to cond_resched()"). A klp_synchronize_transition() before klp_discard_nops() in klp_complete_transition() would fix both. I can send that as a separate fix. Thanks, -yi