Skip to content

Commit d569854

Browse files
committed
kernel: add section about /proc/version
Customize user, host and date
1 parent 4f115bb commit d569854

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

README.adoc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5283,6 +5283,26 @@ Sources:
52835283

52845284
Bibliography: https://stackoverflow.com/questions/8516021/proc-create-example-for-kernel-module/18924359#18924359
52855285

5286+
===== /proc/version
5287+
5288+
Its data is shared with `uname()`, which is a POSIX C function and has a Linux syscall to back it up.
5289+
5290+
Where the data comes from and how to modify it:
5291+
5292+
* https://unix.stackexchange.com/questions/136959/where-does-uname-get-its-information-from/485962#485962
5293+
* https://stackoverflow.com/questions/23424174/how-to-customize-or-remove-extra-linux-kernel-version-details-shown-at-boot
5294+
5295+
In this repo, leaking host information, and to make builds more reproducible, we are setting:
5296+
5297+
- user and date to dummy values
5298+
- hostname to the kernel git commit
5299+
5300+
So the file contains something like:
5301+
5302+
....
5303+
Linux version 4.19.0-dirty (lkmc@84df9525b0c27f3ebc2ebb1864fa62a97fdedb7d) (gcc version 6.4.0 (Buildroot 2018.05-00002-gbc60382b8f)) #1 SMP Thu Jan 1 00:00:00 UTC 1970
5304+
....
5305+
52865306
==== sysfs
52875307

52885308
Sysfs is more restricted than <<procfs>>, as it does not take an arbitrary `file_operations`:

build-linux

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ Configure the kernel, but don't build it.
130130
common_make_args +
131131
common.add_newlines(args.extra_make_args)
132132
),
133+
extra_env={
134+
'KBUILD_BUILD_VERSION': '1',
135+
'KBUILD_BUILD_TIMESTAMP': 'Thu Jan 1 00:00:00 UTC 1970',
136+
'KBUILD_BUILD_USER': 'lkmc',
137+
'KBUILD_BUILD_HOST': common.git_sha(common.linux_source_dir),
138+
},
133139
**common_args
134140
)
135141
common.run_cmd(

common.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@
6666
arch_choices.append(common.arch_short_to_long_dict[key])
6767
default_arch = 'x86_64'
6868
gem5_cpt_prefix = '^cpt\.'
69-
sha = subprocess.check_output(['git', '-C', root_dir, 'log', '-1', '--format=%H']).decode().rstrip()
69+
def git_sha(repo_path):
70+
return subprocess.check_output(['git', '-C', repo_path, 'log', '-1', '--format=%H']).decode().rstrip()
71+
sha = common.git_sha(root_dir)
7072
release_dir = os.path.join(common.out_dir, 'release')
7173
release_zip_file = os.path.join(common.release_dir, 'lkmc-{}.zip'.format(common.sha))
7274
github_repo_id = 'cirosantilli/linux-kernel-module-cheat'

0 commit comments

Comments
 (0)