Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp284754rwb; Fri, 2 Sep 2022 14:12:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR4NQWNfBdc7URqmGkQvprDmX+cXL0036bkfxYbVJ86Ktv1hOzFseKQazLrtacxmntrwozvH X-Received: by 2002:a17:906:8a68:b0:741:56b2:af42 with SMTP id hy8-20020a1709068a6800b0074156b2af42mr21138190ejc.488.1662153141540; Fri, 02 Sep 2022 14:12:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662153141; cv=none; d=google.com; s=arc-20160816; b=gM7l8EPemh4+FozpeWIpFcJJjtf6ttPrk7vi3QkniJEXlXeBdK9vG9Cgw+xFyxBJeL 2Dzizw0aDRSgYWhCRt7Ism1TfRSx5KT+2Zv2BfMLxRKhKmpyseUlShD8z1TzN8uFmq+7 Xh/ocW2Qv8CvTzUgla4KlZWJl2zR2Cga9BoFyhCQFWhdGSsoYq31xOICuNHiceLNOhJ6 fQrQ5VesgQuLYkIiCu8WG4z4ym1dN41YQ/bZuNw9cJ+fDo8fcEhSaRO1Xc39zIlUm47E rBSJikphpCnIIS9hXX8g2GyZjzp9FDAfxw3YbxSYGdChkpwK1J1m313zuTteUwCpESNT ivaQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=FZ6MCCbbjxaweMwUvqd56vSGOr3rqTUXglOvBWMr9Yo=; b=T57GLUgx/IqpedWvro7boAVZ+hpYVuVR7tHnxPlBUTijEY/FPFersRp+MZM/flUj1Y bAAxSEQLYDcHLbrPmTsblBqWXU6WhUKcO7fo2w/QmL/dtcQrJISv6Bn8StExGDmMkfzC fhYmrcLADkHtD5AwLCUdBVqTVvWaR9LdSXqoICSUCTwgUGSwg59DCO6AVldlKQMV7SOP ZzKeGlr93dkW1BnBZ6KokKgW7cw8V1xCT+GAYjrGumN5/QfzLs1AAQbesKJvl13UgCVu x0S7lNjJsfjjdidVwmm7Ktzgj0a5AL4dftxMXXrefixv4cZt1dI7ADrAj2P+cuvn5slR XCwg== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i24-20020a508718000000b00448cade4d27si2535606edb.566.2022.09.02.14.11.56; Fri, 02 Sep 2022 14:12:21 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230339AbiIBUwd convert rfc822-to-8bit (ORCPT + 99 others); Fri, 2 Sep 2022 16:52:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229904AbiIBUwa (ORCPT ); Fri, 2 Sep 2022 16:52:30 -0400 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 145C4D4BD4 for ; Fri, 2 Sep 2022 13:52:30 -0700 (PDT) Received: from pps.filterd (m0109334.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 282JNa70017149 for ; Fri, 2 Sep 2022 13:52:29 -0700 Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3jbcj7v4a2-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Fri, 02 Sep 2022 13:52:29 -0700 Received: from twshared29104.24.frc3.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 2 Sep 2022 13:52:27 -0700 Received: by devbig932.frc1.facebook.com (Postfix, from userid 4523) id 0BAC5C63D6A5; Fri, 2 Sep 2022 13:52:16 -0700 (PDT) From: Song Liu To: , CC: , , , , , Song Liu Subject: [PATCH v3 1/2] livepatch: add sysfs entry "patched" for each klp_object Date: Fri, 2 Sep 2022 13:52:07 -0700 Message-ID: <20220902205208.3117798-2-song@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220902205208.3117798-1-song@kernel.org> References: <20220902205208.3117798-1-song@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT X-FB-Internal: Safe Content-Type: text/plain X-Proofpoint-ORIG-GUID: WvR1whe8TnHpJcfWzQVdj3tAasS4UKmL X-Proofpoint-GUID: WvR1whe8TnHpJcfWzQVdj3tAasS4UKmL X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-09-02_05,2022-08-31_03,2022-06-22_01 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Add per klp_object sysfs entry "patched". It makes it easier to debug typos in the module name. Reviewed-by: Joe Lawrence Signed-off-by: Song Liu --- I was debugging an issue that a livepatch appears to be attached, but actually not. It turns out that there is a mismatch in module name (abc-xyz vs. abc_xyz), klp_find_object_module failed to find the module. --- .../ABI/testing/sysfs-kernel-livepatch | 8 ++++++++ kernel/livepatch/core.c | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-kernel-livepatch b/Documentation/ABI/testing/sysfs-kernel-livepatch index bea7bd5a1d5f..ebe39a3cea39 100644 --- a/Documentation/ABI/testing/sysfs-kernel-livepatch +++ b/Documentation/ABI/testing/sysfs-kernel-livepatch @@ -55,6 +55,14 @@ Description: The object directory contains subdirectories for each function that is patched within the object. +What: /sys/kernel/livepatch///patched +Date: August 2022 +KernelVersion: 6.0.0 +Contact: live-patching@vger.kernel.org +Description: + An attribute which indicates whether the object is currently + patched. + What: /sys/kernel/livepatch/// Date: Nov 2014 KernelVersion: 3.19.0 diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c index bc475e62279d..67eb9f9168f3 100644 --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c @@ -325,6 +325,7 @@ int klp_apply_section_relocs(struct module *pmod, Elf_Shdr *sechdrs, * /sys/kernel/livepatch//transition * /sys/kernel/livepatch//force * /sys/kernel/livepatch// + * /sys/kernel/livepatch///patched * /sys/kernel/livepatch/// */ static int __klp_disable_patch(struct klp_patch *patch); @@ -431,6 +432,22 @@ static struct attribute *klp_patch_attrs[] = { }; ATTRIBUTE_GROUPS(klp_patch); +static ssize_t patched_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + struct klp_object *obj; + + obj = container_of(kobj, struct klp_object, kobj); + return sysfs_emit(buf, "%d\n", obj->patched); +} + +static struct kobj_attribute patched_kobj_attr = __ATTR_RO(patched); +static struct attribute *klp_object_attrs[] = { + &patched_kobj_attr.attr, + NULL, +}; +ATTRIBUTE_GROUPS(klp_object); + static void klp_free_object_dynamic(struct klp_object *obj) { kfree(obj->name); @@ -576,6 +593,7 @@ static void klp_kobj_release_object(struct kobject *kobj) static struct kobj_type klp_ktype_object = { .release = klp_kobj_release_object, .sysfs_ops = &kobj_sysfs_ops, + .default_groups = klp_object_groups, }; static void klp_kobj_release_func(struct kobject *kobj) -- 2.30.2