gentree: create Kconfig.local, use it to restrict compat
authorJohannes Berg <johannes.berg@intel.com>
Mon, 29 Aug 2016 17:32:39 +0000 (19:32 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 6 Feb 2017 14:00:43 +0000 (15:00 +0100)
Not all the compat code is always necessary, for example code
enabled by BPAUTO_CRYPTO_SKCIPHER and by BPAUTO_RHASHTABLE is
gated on other symbols being selected. Checking against the
Kconfig symbols as it's done right now is wrong though, since
the base kernel's Kconfig symbols would be used, selecting,
for example, BPAUTO_CRYPTO_SKCIPHER when the base kernel has
CONFIG_BT set, but doing that when BT isn't even part of the
backport, or when it's disabled in the backport.

To fix this, keep track of all the local Kconfig symbols,
similar to the .local-symbols files but as a Kconfig.local,
and add for each local symbol a symbol that just mirrors the
state of the symbol as selected by the user. This effectively
allows checking the source of the symbol.

Make the relevant backported items use the new BACKPORTED_*
symbols for dependencies, instead of the original ones, thus
avoiding the above-mentioned "leakage" of kernel symbols.
When the symbol isn't even present in the backport, it'll be
simply regarded as false by the kconfig system.

Reported-by: Jouni Malinen <j@w1.fi>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
backport/Kconfig.integrate
backport/Kconfig.package
backport/compat/Kconfig
gentree.py

index f64a3f6eb2353650ecfc02f2cfd159c52817ca90..45ab3ecd4d57f928cabf7ca1a83a686a82b2359a 100644 (file)
@@ -32,5 +32,6 @@ if BACKPORT_LINUX
 
 source "$BACKPORT_DIR/Kconfig.versions"
 source "$BACKPORT_DIR/Kconfig.sources"
+source "$BACKPORT_DIR/Kconfig.local"
 
 endif # BACKPORT_LINUX
index 96845740a42afaa084051715dac9e1cb91f87f27..250cdf3e42784feec7a2834a8b84ffd6f3362827 100644 (file)
@@ -22,3 +22,4 @@ source "$BACKPORT_DIR/Kconfig.sources"
 # these will be generated
 source "$BACKPORT_DIR/Kconfig.kernel"
 source "$BACKPORT_DIR/Kconfig.versions"
+source "$BACKPORT_DIR/Kconfig.local"
index 710f626a5dbcb678fe8506a8ba597b8644050096..ffa8cea842956665aad1ff47fd8f1acaea1098c0 100644 (file)
@@ -116,10 +116,10 @@ config BPAUTO_BUILD_CRYPTO_CCM
 config BPAUTO_CRYPTO_SKCIPHER
        tristate
        depends on KERNEL_4_3
-       default y if MAC802154
-       default y if LIB80211_CRYPT_WEP
-       default y if LIB80211_CRYPT_TKIP
-       default y if BT
+       default y if BACKPORTED_MAC802154
+       default y if BACKPORTED_LIB80211_CRYPT_WEP
+       default y if BACKPORTED_LIB80211_CRYPT_TKIP
+       default y if BACKPORTED_BT
        #c-file crypto/skcipher.c
        #module-name skcipher
 
@@ -139,7 +139,7 @@ config BPAUTO_RHASHTABLE
        # current API of rhashtable was introduced in version 4.1
        depends on KERNEL_4_1
        # not very nice - but better than always having it
-       default y if MAC80211
+       default y if BACKPORTED_MAC80211
        #h-file linux/rhashtable.h
        #c-file lib/rhashtable.c
 
@@ -155,9 +155,9 @@ config BPAUTO_HDMI
        bool
        select BPAUTO_BUILD_HDMI if KERNEL_4_0
        # these drivers are using the new features of the hdmi driver.
-       default y if VIDEO_ADV7511
-       default y if VIDEO_ADV7604
-       default y if VIDEO_ADV7842
+       default y if BACKPORTED_VIDEO_ADV7511
+       default y if BACKPORTED_VIDEO_ADV7604
+       default y if BACKPORTED_VIDEO_ADV7842
 
 config BPAUTO_FRAME_VECTOR
        bool
index f2d98cf199a26f6792771c1aa0700e102403a9d7..026afdc2e02d1d871130f6ffb8147b6cd6f006b5 100755 (executable)
@@ -924,7 +924,7 @@ def process(kerneldir, copy_list_file, git_revision=None,
 
     # some post-processing is required
     configtree = kconfig.ConfigTree(os.path.join(bpid.target_dir, 'Kconfig'), bpid)
-    ignore=['Kconfig.kernel', 'Kconfig.versions']
+    ignore=['Kconfig.kernel', 'Kconfig.versions', 'Kconfig.local']
 
     configtree.verify_sources(ignore=ignore)
     git_debug_snapshot(args, "verify sources on top level backports Kconfig")
@@ -942,6 +942,7 @@ def process(kerneldir, copy_list_file, git_revision=None,
     ignore = [os.path.join(bpid.target_dir, x) for x in [
                 'Kconfig.package.hacks',
                 'Kconfig.versions',
+                'Kconfig.local',
                 'Kconfig',
                 ]
             ]
@@ -960,6 +961,15 @@ def process(kerneldir, copy_list_file, git_revision=None,
             f.write('%s=\n' % sym)
         f.close()
         git_debug_snapshot(args, "add symbols files")
+    # also write Kconfig.local, representing all local symbols
+    # with a BACKPORTED_ prefix
+    f = open(os.path.join(bpid.target_dir, 'Kconfig.local'), 'w')
+    for sym in symbols:
+        f.write('config BACKPORTED_%s\n' % sym)
+        f.write('\ttristate\n')
+        f.write('\tdefault %s\n' % sym)
+    f.close()
+    git_debug_snapshot(args, "add Kconfig.local")
 
     # add defconfigs that we want
     defconfigs_dir = os.path.join(source_dir, 'backport', 'defconfigs')