2

The file /proc/config.gz isn't updated when I rebuild kernel with changed configuration (from make menuconfig). For instance, I have rebuilt kernel with BLK_DEV_IO_TRACE which works fine but config.gz is still showing # CONFIG_BLK_DEV_IO_TRACE is not set. Isn't the .config file in the root directory of kernel source which is included in kernel binary when we enable CONFIG_IKCONFIG?

And BTW config.gz shows CONFIG_IKCONFIG=y while in actual it is CONFIG_IKCONFIG=m.

I'm using Android NDK standalone GCC toolchain to build this kernel (3.18 arm64).

NOTE:

Just to clarify, as it's causing confusion, I'm sure my new kernel is running with new configuration. I've enabled a long list of changes to my default configuration which are working now, a number of userspace programs depend on these configurations:

CONFIG_IKCONFIG=m
CONFIG_IKCONFIG_PROC=y
CONFIG_VETH=y
CONFIG_MODULES=y
CONFIG_MODULE_UNLOAD=y
CONFIG_NFS_FS=m
CONFIG_NFS_V2=m
CONFIG_NFS_V3=m
CONFIG_NFS_V4=m
CONFIG_NFS_V4_1=y
CONFIG_NFS_V4_2=y
CONFIG_NFSD=m
CONFIG_NFSD_V3=y
CONFIG_NFSD_V4=y
CONFIG_NFSD_V4_SECURITY_LABEL=y
CONFIG_KEYS_DEBUG_PROC_KEYS=y
CONFIG_OVERLAY_FS=m
CONFIG_UTS_NS=y
CONFIG_USER_NS=y
CONFIG_PID_NS=y
CONFIG_NET_CLS_CGROUP=m
CONFIG_CGROUP_NET_CLASSID=y
CONFIG_NETFILTER_XT_MATCH_CGROUP=m
CONFIG_NETFILTER_NETLINK=m
CONFIG_ISO9660_FS=m
CONFIG_SQUASHFS=m
CONFIG_UDF_FS=m
CONFIG_UNIX_DIAG=m
CONFIG_PSTORE=y
CONFIG_FANOTIFY=y
CONFIG_FANOTIFY_ACCESS_PERMISSIONS=y
CONFIG_DEBUG_FS=y
CONFIG_FTRACE=y
CONFIG_BLK_DEV_IO_TRACE=y

config.gz shows Linux/arm64 3.18.71 Kernel Configuration while the current is Linux/arm64 3.18.140 Kernel Configuration. Also it doesn't matches with any of the 16 *defconfig files in arch/arm64/configs/. There are 185 differences (88 additions, 97 drops) between actual config and config.gz. Initially I used arch/arm64/configs/franco_mido_defconfig; the one provided by custom kernel developer.

  • 2
    Have you rebooted and verified that the new kernel you just compiled is actually running? – telcoM Jun 28 at 7:15
  • 1
    @telcoM it's an Android phone, can't have multiple kernels. As I mentioned, BLK_DEV_IO_TRACE is working fine, I can trace I/O operations. Also the problem persists for over a year almost, not occuring first time. – Irfan Latif Jun 28 at 7:44
  • 1
    /proc/config.gz is the currently running kernel's configuration. It isn't going to be affected by whatever random kernel you build. – muru Jun 28 at 7:49
  • 2
    @muru I cross-compiled the kernel on Ubuntu PC. Transfered new kernel image to phone. Rebooted my phone to recovery mode. Flashed the kernel to boot.img. Restarted phone. And I'm dead sure new kernel is running. I have been doing this for years. – Irfan Latif Jun 28 at 7:57
  • 1
    I see, sorry I misunderstood. Do you have a diff of the config from what you had built? – muru Jun 28 at 8:10
1

The kernel option that produces /proc/config.gz is IKCONFIG_PROC, not just IKCONFIG. And IKCONFIG_PROC cannot be a module.

Also, note that there are kernel/configs/android-base.config and kernel/configs/android-recommended.config. These may be used to override some kernel configuration settings, see https://lore.kernel.org/linux-arm-kernel/1466708235-28593-1-git-send-email-robh@kernel.org/

If your kernel compilation procedure uses a command like this (an example mentioned in the Linux-ARM-Kernel list post linked above)

make ARCH=arm multi_v7_defconfig android-base.config android-recommended.config

then those files are indeed being used. And android-base.config includes setting both CONFIG_IKCONFIG and CONFIG_IKCONFIG_PROC to y.

Are you sure your toolchain is not doing something like

make ARCH=arm <oldconfig or some other config target> android-base.config 

before actually starting to build your kernel?

  • IKCONFIG enables the complete Linux kernel ".config" file contents to be saved in the kernel. This information can be extracted from the kernel image file with the script scripts/extract-ikconfig. IKCONFIG_PROC just enables access to the kernel configuration file through /proc/config.gz, it doesn't affect the contents of .config file, which my actual point of question is. I'm dead sure my new kernel is running with new configuration. See the edit to OP. I have only one file kernel/configs/tiny.config with a total 4 configurations. So it's definitely not being used. – Irfan Latif Jun 28 at 10:42
  • I'm sure that you're sure you've done everything correctly. That does not remove the possibility of, for example, your toolchain or perhaps buggy bootloader or rootkitted firmware playing tricks on you. Also, since you have CONFIG_IKCONFIG=m, does the ikconfig.ko module actually exist? Does cat /proc/version show the right or the wrong version? You may have just uncovered signs of a possible factory-installed rootkit on your Xiaomi Redmi Note 4. – telcoM Jun 28 at 11:05
  • It's not ikconfig.ko but configs.ko, and yes it exists. cat /proc/version shows exactly what I expect: Linux version 3.18.140-FrancoKernel (irfan@irfan-Inspiron-5521) (gcc version 4.9.x 20150123 (prerelease) (GCC) ) #1 SMP PREEMPT Fri Jun 28 00:02:54 PKT 2019 – Irfan Latif Jun 28 at 11:10
  • I think I have found the culprit code. I'll have to undo this commit: github.com/franciscofranco/mido/commit/… – Irfan Latif Jun 28 at 11:28
  • Note that the commit text says: "Userspace reads /proc/config.gz and spits out an error message after boot finishes when it doesn't like the kernel's configuration. " Unless you're customizing the userspace too (or further updates to the userspace code have removed the checks), it looks like you might have to make /proc/config.gz tell lies in order to keep the userspace parts of your phone's software happy. – telcoM Jun 28 at 19:06
0

I should have done more research prior to posting this question, but I thought might be I was missing something. For reference, the problem reveals to be specific to my kernel source. Custom kernel developer applied a patch to always include an older configuration in kernel binary. So this should be undone (considering the risks, if any):

ifeq ($(CONFIG_MACH_XIAOMI_MIDO),y)
    $(obj)/config_data.gz: arch/arm64/configs/mido_defconfig FORCE
else ifeq ($(CONFIG_MACH_XIAOMI_TISSOT),y)
    $(obj)/config_data.gz: arch/arm64/configs/tissot_defconfig FORCE
else
    $(obj)/config_data.gz: $(KCONFIG_CONFIG) FORCE
endif

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.