paulgazz / kmax

A collection of analysis tools for Kconfig and Kbuild constraints.
42 stars 21 forks source link

kismet generates invalid value for CONFIG_ARCH_MMAP_RND_BITS #239

Closed Yujie-Liu closed 1 year ago

Yujie-Liu commented 1 year ago

Kernel developers reported that there are suspicious info in the reports from kernel test robot: https://lore.kernel.org/oe-kbuild-all/756c9659-5c7d-4e29-b5d1-76b26dd3e0c8@infradead.org/

>>> kismet warnings: (new ones prefixed by >>)
>>>>> kismet: WARNING: unmet direct dependencies detected for SM_GCC_8550 when selected by SM_CAMCC_8550
>>>    .config:7280:warning: symbol value 'ONFIG_ARCH_MMAP_RND_BITS_MI' invalid for ARCH_MMAP_RND_BITS
>>                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
>> Where is this coming from? I have seen this warning in several build
>> reports (earliest 2023-01-31), but cannot reproduce it with the provided
>> commit and config.
> 

I'm pretty sure that what Geert is asking about here is the warning (".config:7280:...") with
the truncated kconfig symbol 'ONFIG_ARCH_MMAP_RND_BITS_MI'.  I have also seen several of these.
Is this a bug in kismet or a bug in the robot or something else?

This can be reproduced by the following steps:

$ git checkout ccc4e6a061a21d75b96d82fc4b084a8d96df6eb4  (this is an upstream commit)
$ kismet --selectees CONFIG_SM_GCC_8550 --selectors CONFIG_SM_CAMCC_8550 -a arm
$ cd kismet-test-cases
$ grep ARCH_MMAP_RND_BITS udd-arm-CONFIG_SM_GCC_8550-CONFIG_SM_CAMCC_8550-0-0.config
CONFIG_HAVE_ARCH_MMAP_RND_BITS=y
CONFIG_ARCH_MMAP_RND_BITS=ONFIG_ARCH_MMAP_RND_BITS_MI   <--

$ cd ..
$ cp kismet-test-cases/udd-arm-CONFIG_SM_GCC_8550-CONFIG_SM_CAMCC_8550-0-0.config .config
$ make ARCH=arm olddefconfig
.config:7113:warning: symbol value 'ONFIG_ARCH_MMAP_RND_BITS_MI' invalid for ARCH_MMAP_RND_BITS  <--

WARNING: unmet direct dependencies detected for SM_GCC_8550
  Depends on [n]: COMMON_CLK [=y] && COMMON_CLK_QCOM [=y] && (ARM64 || COMPILE_TEST [=n])
  Selected by [y]:
  - SM_CAMCC_8550 [=y] && COMMON_CLK [=y] && COMMON_CLK_QCOM [=y]
#
# configuration written to .config
#

We can see that the config file generated in kismet-test-cases dir has an invalid value for CONFIG_ARCH_MMAP_RND_BITS.

paulgazz commented 1 year ago

Thanks for the heads up will take a look more closely.

Yujie-Liu commented 1 year ago

Is the issue the missing "C" in "CONFIG..." in the message, leading to "ONFIG..."?

Hi @paulgazz, it is not exactly missing the "C" character, actually CONFIG_ARCH_MMAP_RND_BITS should be an integer value, but here it is assigned as a truncated string "ONFIG_ARCH_MMAP_RND_BITS_MI"

config ARCH_MMAP_RND_BITS
        int "Number of bits to use for ASLR of mmap base address" if EXPERT
        range ARCH_MMAP_RND_BITS_MIN ARCH_MMAP_RND_BITS_MAX
        default ARCH_MMAP_RND_BITS_DEFAULT if ARCH_MMAP_RND_BITS_DEFAULT
        default ARCH_MMAP_RND_BITS_MIN
        depends on HAVE_ARCH_MMAP_RND_BITS
        help
          This value can be used to select the number of bits to use to
          determine the random offset to the base address of vma regions
          resulting from mmap allocations. This value will be bounded
          by the architecture's minimum and maximum supported values.

          This value can be changed after boot using the
          /proc/sys/vm/mmap_rnd_bits tunable
paulgazz commented 1 year ago

Looks like I introduced a bug in v4.5 when using non-Boolean configuration option default values (to avoid the need for a user to set them). I will work on a patch and new release.

Yujie-Liu commented 1 year ago

Thanks a lot for the quick fix. We've updated to v4.5.1 in the kernel test robot

$kismet --version
kmax 4.5.1
paulgazz commented 1 year ago

No problem @Yujie-Liu and thank you for reporting it!