From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.71 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796407343; b=QnBLG9SiK6u/zVR2VzmlNa5IirXwbIZa6EuRpJe66mwy2bvQBYDhu/Eu6R9qMZSb6y40 SNpNkFdist79Y+YkB2MlDhbZ29ngZ5PvLeO4i/953miekiW12VMue15TEvQJn85nUGy0v nuzSWpSa6uyUYGsVGRlFcx3WLNM4IbOtuEz9Ziav5IP777gQQ6h0zhkqBaJL2KiH4aeJD ez54bUBE1PcEWkJXwKGPNtoExybO/SrvZ4/HvzqBAHcjZ9EOP5bigY6DrT3QPJqjinjkc tRD7C6qwC/vpQ1+Bbc9DZXKYr5wUqyWmUS2rzqt3jcPmU+piwYYp9MbgC43/B2Y7A4g== 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=XiiZW/PS77fuE4OttNIsddqH9DPHCpIdNmdPPU8f4Ve2g8wbiBtRHZV9cz/HXohauBb9 DIaUhMUXErJ9BUbKlEBf6YMu76Noxxb9U1TuMW/a8l8niYlxCBlrksf1ufsiKYGXAP1O4 Y/lQLZDC1snFQIbn/av9QkAGiDJuyvUivhaJLzzWQBACxj4BwWO6M9+Z0287ZCcA++ESf vRFskIBX9wccSdTm2W7aYGLLbHdiTwC6CgCIT9S0aqzT0TJzuhJ60iSVkgYm/p15TkHFe 3gEdlia2s6Lo96H0zYpbJzL96XFSwt1GXrfFp0C4P+By7mMz3EipRj2EhHMRk9L1JPg== 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.71 Received: from mail-dl1-f71.google.com (mail-dl1-f71.google.com [74.125.82.71]) (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 50FDC606A336 for ; Fri, 4 Dec 2026 18:02:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 50FDC606A336 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-f71.google.com with SMTP id a92af1059eb24-1b5d5e0a8cdso1641944c88.0 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=Ru07Cyq64U40HlIHuD0oN6lN3LuFCVJPiT9mltXceTJC61/3d32/UShjBxvEJteaTW L5nHFsU1ESdVDleeHuoMCFZGvLQC+XMuZw+XMwo7KOA/RaqyuprzAfrSlx57wO/VOoUU O+5zrTeoOMM3M5Mbsa/NkxpSu5iYbfuQjXrb4m/s7TbUxElFTivN5njqGcrxqxXcbMwu x/y9vLvsAKwO3HHS/VPX8vtZ57a5D8hNv6WJCDj4fluVxfIJFE4AF3Yy9H3UU05qk3z1 0zj2w1kYkpGGlrEIF60WdLo0hRC2KwkMLKHK7EZwQEarqsB/vpaToZ7jnIg0KAhA5Pwq diIA== X-Forwarded-Encrypted: i=1; AL+hErHGSUi1ZCCl/oFPtQDKCDvWkM24qdoMCSh9YvYugNGGP3l1q7ObCr7pa7kVA8YVbyoP7XBS/9E6OGdmAUPo@vger.kernel.org X-Gm-Message-State: APuU4Z8YhQzH93NdDDJ/m3pGFmj8ORSQJtTc4EVSH0njfiBdWfoUK8nD 3YX+EkK7kIgzZZM8UKSQYH/piwXeH0L/p8bJtdDFgPSLpV7UMgWiJoX5m5JSgZh+/WReKxrpTra JgPPDFg== 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: live-patching@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