Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
ea5377ec
Commit
ea5377ec
authored
Jul 23, 2024
by
Petr Mladek
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'for-6.11/sysfs-patch-replace' into for-linus
parents
61894818
92052692
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
3 deletions
+70
-3
Documentation/ABI/testing/sysfs-kernel-livepatch
Documentation/ABI/testing/sysfs-kernel-livepatch
+8
-0
kernel/livepatch/core.c
kernel/livepatch/core.c
+14
-3
tools/testing/selftests/livepatch/test-sysfs.sh
tools/testing/selftests/livepatch/test-sysfs.sh
+48
-0
No files found.
Documentation/ABI/testing/sysfs-kernel-livepatch
View file @
ea5377ec
...
...
@@ -47,6 +47,14 @@ Description:
disabled when the feature is used. See
Documentation/livepatch/livepatch.rst for more information.
What: /sys/kernel/livepatch/<patch>/replace
Date: Jun 2024
KernelVersion: 6.11.0
Contact: live-patching@vger.kernel.org
Description:
An attribute which indicates whether the patch supports
atomic-replace.
What: /sys/kernel/livepatch/<patch>/<object>
Date: Nov 2014
KernelVersion: 3.19.0
...
...
kernel/livepatch/core.c
View file @
ea5377ec
...
...
@@ -346,6 +346,7 @@ int klp_apply_section_relocs(struct module *pmod, Elf_Shdr *sechdrs,
* /sys/kernel/livepatch/<patch>/enabled
* /sys/kernel/livepatch/<patch>/transition
* /sys/kernel/livepatch/<patch>/force
* /sys/kernel/livepatch/<patch>/replace
* /sys/kernel/livepatch/<patch>/<object>
* /sys/kernel/livepatch/<patch>/<object>/patched
* /sys/kernel/livepatch/<patch>/<object>/<function,sympos>
...
...
@@ -401,7 +402,7 @@ static ssize_t enabled_show(struct kobject *kobj,
struct
klp_patch
*
patch
;
patch
=
container_of
(
kobj
,
struct
klp_patch
,
kobj
);
return
s
nprintf
(
buf
,
PAGE_SIZE
-
1
,
"%d
\n
"
,
patch
->
enabled
);
return
s
ysfs_emit
(
buf
,
"%d
\n
"
,
patch
->
enabled
);
}
static
ssize_t
transition_show
(
struct
kobject
*
kobj
,
...
...
@@ -410,8 +411,7 @@ static ssize_t transition_show(struct kobject *kobj,
struct
klp_patch
*
patch
;
patch
=
container_of
(
kobj
,
struct
klp_patch
,
kobj
);
return
snprintf
(
buf
,
PAGE_SIZE
-
1
,
"%d
\n
"
,
patch
==
klp_transition_patch
);
return
sysfs_emit
(
buf
,
"%d
\n
"
,
patch
==
klp_transition_patch
);
}
static
ssize_t
force_store
(
struct
kobject
*
kobj
,
struct
kobj_attribute
*
attr
,
...
...
@@ -443,13 +443,24 @@ static ssize_t force_store(struct kobject *kobj, struct kobj_attribute *attr,
return
count
;
}
static
ssize_t
replace_show
(
struct
kobject
*
kobj
,
struct
kobj_attribute
*
attr
,
char
*
buf
)
{
struct
klp_patch
*
patch
;
patch
=
container_of
(
kobj
,
struct
klp_patch
,
kobj
);
return
sysfs_emit
(
buf
,
"%d
\n
"
,
patch
->
replace
);
}
static
struct
kobj_attribute
enabled_kobj_attr
=
__ATTR_RW
(
enabled
);
static
struct
kobj_attribute
transition_kobj_attr
=
__ATTR_RO
(
transition
);
static
struct
kobj_attribute
force_kobj_attr
=
__ATTR_WO
(
force
);
static
struct
kobj_attribute
replace_kobj_attr
=
__ATTR_RO
(
replace
);
static
struct
attribute
*
klp_patch_attrs
[]
=
{
&
enabled_kobj_attr
.
attr
,
&
transition_kobj_attr
.
attr
,
&
force_kobj_attr
.
attr
,
&
replace_kobj_attr
.
attr
,
NULL
};
ATTRIBUTE_GROUPS
(
klp_patch
);
...
...
tools/testing/selftests/livepatch/test-sysfs.sh
View file @
ea5377ec
...
...
@@ -18,6 +18,7 @@ check_sysfs_rights "$MOD_LIVEPATCH" "" "drwxr-xr-x"
check_sysfs_rights
"
$MOD_LIVEPATCH
"
"enabled"
"-rw-r--r--"
check_sysfs_value
"
$MOD_LIVEPATCH
"
"enabled"
"1"
check_sysfs_rights
"
$MOD_LIVEPATCH
"
"force"
"--w-------"
check_sysfs_rights
"
$MOD_LIVEPATCH
"
"replace"
"-r--r--r--"
check_sysfs_rights
"
$MOD_LIVEPATCH
"
"transition"
"-r--r--r--"
check_sysfs_value
"
$MOD_LIVEPATCH
"
"transition"
"0"
check_sysfs_rights
"
$MOD_LIVEPATCH
"
"vmlinux/patched"
"-r--r--r--"
...
...
@@ -83,4 +84,51 @@ test_klp_callbacks_demo: post_unpatch_callback: vmlinux
livepatch: 'test_klp_callbacks_demo': unpatching complete
% rmmod test_klp_callbacks_demo"
start_test
"sysfs test replace enabled"
MOD_LIVEPATCH
=
test_klp_atomic_replace
load_lp
$MOD_LIVEPATCH
replace
=
1
check_sysfs_rights
"
$MOD_LIVEPATCH
"
"replace"
"-r--r--r--"
check_sysfs_value
"
$MOD_LIVEPATCH
"
"replace"
"1"
disable_lp
$MOD_LIVEPATCH
unload_lp
$MOD_LIVEPATCH
check_result
"% insmod test_modules/
$MOD_LIVEPATCH
.ko replace=1
livepatch: enabling patch '
$MOD_LIVEPATCH
'
livepatch: '
$MOD_LIVEPATCH
': initializing patching transition
livepatch: '
$MOD_LIVEPATCH
': starting patching transition
livepatch: '
$MOD_LIVEPATCH
': completing patching transition
livepatch: '
$MOD_LIVEPATCH
': patching complete
% echo 0 > /sys/kernel/livepatch/
$MOD_LIVEPATCH
/enabled
livepatch: '
$MOD_LIVEPATCH
': initializing unpatching transition
livepatch: '
$MOD_LIVEPATCH
': starting unpatching transition
livepatch: '
$MOD_LIVEPATCH
': completing unpatching transition
livepatch: '
$MOD_LIVEPATCH
': unpatching complete
% rmmod
$MOD_LIVEPATCH
"
start_test
"sysfs test replace disabled"
load_lp
$MOD_LIVEPATCH
replace
=
0
check_sysfs_rights
"
$MOD_LIVEPATCH
"
"replace"
"-r--r--r--"
check_sysfs_value
"
$MOD_LIVEPATCH
"
"replace"
"0"
disable_lp
$MOD_LIVEPATCH
unload_lp
$MOD_LIVEPATCH
check_result
"% insmod test_modules/
$MOD_LIVEPATCH
.ko replace=0
livepatch: enabling patch '
$MOD_LIVEPATCH
'
livepatch: '
$MOD_LIVEPATCH
': initializing patching transition
livepatch: '
$MOD_LIVEPATCH
': starting patching transition
livepatch: '
$MOD_LIVEPATCH
': completing patching transition
livepatch: '
$MOD_LIVEPATCH
': patching complete
% echo 0 > /sys/kernel/livepatch/
$MOD_LIVEPATCH
/enabled
livepatch: '
$MOD_LIVEPATCH
': initializing unpatching transition
livepatch: '
$MOD_LIVEPATCH
': starting unpatching transition
livepatch: '
$MOD_LIVEPATCH
': completing unpatching transition
livepatch: '
$MOD_LIVEPATCH
': unpatching complete
% rmmod
$MOD_LIVEPATCH
"
exit
0
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment