From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752653AbdI1DmN (ORCPT ); Wed, 27 Sep 2017 23:42:13 -0400 Received: from mx0a-00190b01.pphosted.com ([67.231.149.131]:40240 "EHLO mx0a-00190b01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752545AbdI1DmG (ORCPT ); Wed, 27 Sep 2017 23:42:06 -0400 From: Jason Baron To: linux-kernel@vger.kernel.org, live-patching@vger.kernel.org Cc: jpoimboe@redhat.com, jeyu@kernel.org, jikos@kernel.org, mbenes@suse.cz, pmladek@suse.com Subject: [PATCH v3 0/2] livepatch: introduce atomic replace Date: Wed, 27 Sep 2017 23:41:28 -0400 Message-Id: X-Mailer: git-send-email 1.9.1 X-Proofpoint-Virus-Version: vendor=nai engine=5600 definitions=5800 signatures=585085 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1709250277 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-09-28_02:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1709280058 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, In testing livepatch, I found that when doing cumulative patches, if a patched function is completed reverted by a subsequent patch (back to its original state) livepatch does not revert the funtion to its original state. Specifically, if patch A introduces a change to function 1, and patch B reverts the change to function 1 and introduces changes to say function 2 and 3 as well, the change that patch A introduced to function 1 is still present. This could be addressed by first completely removing patch A (disable and then rmmod) and then inserting patch B (insmod and enable), but this leaves an unpatched window. In discussing this issue with Josh on the kpatch mailing list, he mentioned that we could get 'atomic replace working properly', and that is the direction of this patchset: https://www.redhat.com/archives/kpatch/2017-June/msg00005.html Patches: 1) livepatch: Add klp_object and klp_func dynamic iterators A prep patch for the 'atomic replace' feature such that dynamic objects and functions can be allocated. 2) livepatch: add atomic replace Core feature. Note that __klp_enable_patch() calls klp_add_nops(), which necessitated moving a bunch of existing functions before __klp_enable_patch(). So there is a bit of churn in moving functions that are not modified. Thanks, -Jason v2-v3: -refactor how the dynamic nops are calculated (Petr Mladek) -move the creation of dynamic nops to enable/disable paths -add klp_replaced_patches list to indicate patches that can be re-enabled -dropped 'replaced' field -renamed dynamic fields in klp_func, object and patch -moved iterator implementation to kernel/livepatch/core.c -'inherit' nop immediate flag -update kobject_put free'ing logic (Petr Mladek) v1-v2: -removed the func_iter and obj_iter (Petr Mladek) -initialiing kobject structure for no_op functions using: klp_init_object() and klp_init_func() -added a 'replace' field to klp_patch, similar to the immediate field -a 'replace' patch now disables all previous patches -tried to shorten klp_init_patch_no_ops()... -Simplified logic klp_complete_transition (Petr Mladek) Jason Baron (2): livepatch: Add dynamic klp_object and klp_func iterators livepatch: add atomic replace include/linux/livepatch.h | 85 +++-- kernel/livepatch/core.c | 738 ++++++++++++++++++++++++++++++++---------- kernel/livepatch/core.h | 6 + kernel/livepatch/patch.c | 22 +- kernel/livepatch/patch.h | 4 +- kernel/livepatch/transition.c | 50 ++- 6 files changed, 685 insertions(+), 220 deletions(-) -- 2.6.1