From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796494954; b=ujT1LxzITsQg30F85QHv5zE5JKZSrgyYcZctAuripohb7VLN2SPGzmjrQ9ZjdjWL1W+2 gmTtFuDQ0GAriZKyz27Tt19qyetXAOZzCYroZWVrqsBunPTHdoeSpSfJlo0/Rb1ZHKdhV kH2/C7D9wMSYMZyvS3rHNYoxsS8QzM5kMkTWOGkvu++0tVRIarcZlE0AFmnL5ubDzfBBe hyK9PZd6mcIQ0/l+dAAnbIuOU8bT6Aqqs7NRw7QhUm+Fb9M2Y9Zn7S/KPGPEyWrdOcdCq laOBfDn/EuengqY2CbeMwA27paY0dSulUNnAYK4DoGARmwMHLiZtwZXWiwNoxm3oAjQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796494954; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=oed2STwg7cOhiTviDLj0WzEYc/LnQlM4zqTwfDTAUMo=; b=pAMQOI03k0/uPWsuJtr8BgYRN3PaaIaI9haYoRiClxqxmxBu+86wsWXF0sCnjVah6vbW P9mILR+oJ4LHODbp66c5CUqsyMMxc5lZZF5mXfj+Oxt4TmJlMCEAypa0+mLrxPkKvtjpW W7z6FkIlyQtnZ0xySpS5NHHEp2SwSEs+o0ZGWQEdS2cjvv17EDP/uG1BRQiMYafyqB8vn yNu2LNYNdhoy5o7kAtKD6SfATGmFLXv8pLoSOeSFIiFYt0HKHIQPTAW+mZMWjAdi5wULc YuHo3+9Nev3A4HZCQMIhrC0/8SMe+ys5wSGyOoCB+iER7S2BVTT11M1u1S8wX1T9p+g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=bL4lCULr; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B96E7606A31F for ; Sat, 5 Dec 2026 18:22:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=bL4lCULr Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C2D41F00936; Sat, 5 Dec 2026 18:22:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796494954; bh=oed2STwg7cOhiTviDLj0WzEYc/LnQlM4zqTwfDTAUMo=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=bL4lCULr9XnzR1tfqtV1l/RCzzNamQ4rz0GvAHa/u1596CqPQidpMthlWFHS299IU i8qAK6h3beniZIPS5m1TmfY6vjr8y+b2p++WhTxBLez/MUGuttXH5kd7yQ+ujJWeVA ZM8XB2NrJrGDcQ1FwQFJFTnQgHfSOgSyueOq/evMfUDQxD6rm6i/fYd4P3SW6jkICm W1b1t96rLVydLrNuGqbny+uM/5rxTrmitgdctbjPA+af9yu6SwXeYhO6vLjyX16eRE XbwguBFaxzKM0J1ViBxU2aClBEmd5BB0fb41YMJV15gab0fSU8M6h1LF1iBhiBL6Yn hSszbNkS8Z52g== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v5 2/4] livepatch: Retry klp_synchronize_transition() if it fails Reply-To: sashiko-reviews@lists.linux.dev To: "Binoy Ravindran" , "Paul E. McKenney" , "Frederic Weisbecker" , "Neeraj Upadhyay" , "Joel Fernandes" , "Josh Triplett" , "Boqun Feng" , "Uladzislau Rezki" , "Steven Rostedt" , "Mathieu Desnoyers" , "Lai Jiangshan" , Zqiang , "Josh Poimboeuf" , "Miroslav Benes" , "Petr Mladek" , "Joe Lawrence" , "Song Liu" , "Ingo Molnar" , "Jiri Kosina" , "Ingo Molnar" , "Peter Zijlstra" , "Juri Lelli" , "Vincent Guittot" , "Dietmar Eggemann" , "Ben Segall" , "Mel Gorman" , "Valentin Schneider" , "K Prateek Nayak" Cc: live-patching@vger.kernel.org, "Yafang Shao" , "Jaidev Shastri" In-Reply-To: <20261205-klp-series-v3-v5-2-3d60c8ea9316@vt.edu> References: <20261205-klp-series-v3-v5-0-3d60c8ea9316@vt.edu> <20261205-klp-series-v3-v5-2-3d60c8ea9316@vt.edu> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 18:22:31 +0000 X-Mailing-List: live-patching@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] livepatch: unbounded uninterruptible retry in klp_synchronize_transition() - [Low] livepatch: missing Fixes tag for klp_synchronize_transition() bug fix -- commit f48adcf8ba6e941661b90ee57576b67c0772ba78 Author: Binoy Ravindran > livepatch: Retry klp_synchronize_transition() if it fails > > schedule_on_each_cpu() returns -ENOMEM when it cannot allocate its work > items, before it queues any of them. klp_synchronize_transition() ignores > the error, so it can return without waiting. The transition relies on the > wait in several places, including the two that the following patches add > before func->transition is set and before the transition completes. > > Retry until the wait succeeds. The callers can sleep, since > schedule_on_each_cpu() itself sleeps. > > Assisted-by: Claude:claude-opus-5-5 > Signed-off-by: Binoy Ravindran [Severity: Low] This fixes the unchecked schedule_on_each_cpu() call introduced in klp_synchronize_transition(). Should this include: Fixes: 842c08846420 ("livepatch: Fix stacking of patches with respect to = RCU") > diff --git a/kernel/livepatch/transition.c b/kernel/livepatch/transition.c > index 2351a19ac2a9e..33095e888e10c 100644 > --- a/kernel/livepatch/transition.c > +++ b/kernel/livepatch/transition.c [ ... ] > @@ -71,7 +72,13 @@ static void klp_sync(struct work_struct *work) > */ > static void klp_synchronize_transition(void) > { > - schedule_on_each_cpu(klp_sync); > + /* > + * schedule_on_each_cpu() fails only when it cannot allocate its work > + * items, before it queues any of them. The callers rely on the wait, > + * so retry until it succeeds. > + */ > + while (schedule_on_each_cpu(klp_sync)) > + msleep(20); > } [Severity: Medium] Can this loop livelock forever while holding klp_mutex? schedule_on_each_cpu() calls alloc_percpu(), which takes pcpu_alloc_mutex with mutex_lock_killable(). Under OOM, another caller holding pcpu_alloc_mutex can loop in GFP_NOIO page allocation, while a killed livepatch caller gets -ENOMEM from alloc_percpu() on every retry. Even without contention, an OOM victim that cannot satisfy pcpu_alloc_pages() from OOM reserves fails with -ENOMEM and loops forever. Because msleep(20) is uninterruptible, the task cannot exit to free memory and holds klp_mutex indefinitely, stalling module loading. Since every caller of klp_synchronize_transition() already holds klp_mutex, a static DEFINE_PER_CPU(struct work_struct, ...) driven with cpus_read_lock(), schedule_work_on(), and flush_work() would avoid dynamic allocation and the retry loop altogether. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205-klp-series= -v3-v5-0-3d60c8ea9316@vt.edu?part=3D2