diff --git a/README.adoc b/README.adoc index 23cad78..3f2e51a 100644 --- a/README.adoc +++ b/README.adoc @@ -5283,6 +5283,26 @@ Sources: Bibliography: https://stackoverflow.com/questions/8516021/proc-create-example-for-kernel-module/18924359#18924359 +===== /proc/version + +Its data is shared with `uname()`, which is a POSIX C function and has a Linux syscall to back it up. + +Where the data comes from and how to modify it: + +* https://unix.stackexchange.com/questions/136959/where-does-uname-get-its-information-from/485962#485962 +* https://stackoverflow.com/questions/23424174/how-to-customize-or-remove-extra-linux-kernel-version-details-shown-at-boot + +In this repo, leaking host information, and to make builds more reproducible, we are setting: + +- user and date to dummy values +- hostname to the kernel git commit + +So the file contains something like: + +.... +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 +.... + ==== sysfs Sysfs is more restricted than <>, as it does not take an arbitrary `file_operations`: diff --git a/build-linux b/build-linux index aecceed..8545684 100755 --- a/build-linux +++ b/build-linux @@ -130,6 +130,12 @@ Configure the kernel, but don't build it. common_make_args + common.add_newlines(args.extra_make_args) ), + extra_env={ + 'KBUILD_BUILD_VERSION': '1', + 'KBUILD_BUILD_TIMESTAMP': 'Thu Jan 1 00:00:00 UTC 1970', + 'KBUILD_BUILD_USER': 'lkmc', + 'KBUILD_BUILD_HOST': common.git_sha(common.linux_source_dir), + }, **common_args ) common.run_cmd( diff --git a/common.py b/common.py index b758bee..db9f702 100644 --- a/common.py +++ b/common.py @@ -66,7 +66,9 @@ for key in common.arch_short_to_long_dict: arch_choices.append(common.arch_short_to_long_dict[key]) default_arch = 'x86_64' gem5_cpt_prefix = '^cpt\.' -sha = subprocess.check_output(['git', '-C', root_dir, 'log', '-1', '--format=%H']).decode().rstrip() +def git_sha(repo_path): + return subprocess.check_output(['git', '-C', repo_path, 'log', '-1', '--format=%H']).decode().rstrip() +sha = common.git_sha(root_dir) release_dir = os.path.join(common.out_dir, 'release') release_zip_file = os.path.join(common.release_dir, 'lkmc-{}.zip'.format(common.sha)) github_repo_id = 'cirosantilli/linux-kernel-module-cheat'