Message ID | 20220510235412.3627034-1-keescook@chromium.org (mailing list archive) |
---|---|
State | Mainlined |
Commit | 61f60bac8c05f8ecd2ae2a6360520b91a45be9a2 |
Headers | show |
Series | gcc-plugins: Change all version strings match kernel | expand |
Hi Kees, I love your patch! Yet something to improve: [auto build test ERROR on kees/for-next/pstore] [also build test ERROR on linux/master linus/master v5.18-rc6 next-20220510] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/intel-lab-lkp/linux/commits/Kees-Cook/gcc-plugins-Change-all-version-strings-match-kernel/20220511-075434 base: https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/pstore config: i386-randconfig-m021-20220509 (https://download.01.org/0day-ci/archive/20220511/202205111547.BDAL0Z0h-lkp@intel.com/config) compiler: gcc-11 (Debian 11.2.0-20) 11.2.0 reproduce (this is a W=1 build): # https://github.com/intel-lab-lkp/linux/commit/020fffc667a0f0414fc7f807e6a5f565444eb5e4 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Kees-Cook/gcc-plugins-Change-all-version-strings-match-kernel/20220511-075434 git checkout 020fffc667a0f0414fc7f807e6a5f565444eb5e4 # save the config file mkdir build_dir && cp config build_dir/.config make W=1 O=build_dir ARCH=i386 prepare If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): >> <command-line>: fatal error: ./include/generated/utsrelease.h: No such file or directory compilation terminated. make[3]: *** [scripts/gcc-plugins/Makefile:49: scripts/gcc-plugins/latent_entropy_plugin.so] Error 1 >> <command-line>: fatal error: ./include/generated/utsrelease.h: No such file or directory compilation terminated. make[3]: *** [scripts/gcc-plugins/Makefile:49: scripts/gcc-plugins/structleak_plugin.so] Error 1 make[3]: Target '__build' not remade because of errors. make[2]: *** [scripts/Makefile.build:550: scripts/gcc-plugins] Error 2 make[2]: Target '__build' not remade because of errors. make[1]: *** [Makefile:1175: scripts] Error 2 make[1]: Target 'prepare' not remade because of errors. make: *** [Makefile:219: __sub-make] Error 2 make: Target 'prepare' not remade because of errors.
On Tue, May 10, 2022 at 04:54:12PM -0700, Kees Cook wrote: > It's not meaningful for the GCC plugins to track their versions separately > from the rest of the kernel. Switch all versions to the kernel version. > > Fix mismatched indenting while we're at it. > > Cc: linux-hardening@vger.kernel.org > Signed-off-by: Kees Cook <keescook@chromium.org> I see random build failures with this patch in linux-next. Error log: cc1plus: fatal error: ./include/generated/utsrelease.h: No such file or directory The problem doesn't happen all the time. Is there some missing dependency ? Guenter > --- > scripts/gcc-plugins/Makefile | 9 +++++---- > scripts/gcc-plugins/latent_entropy_plugin.c | 2 +- > scripts/gcc-plugins/randomize_layout_plugin.c | 2 +- > scripts/gcc-plugins/sancov_plugin.c | 2 +- > scripts/gcc-plugins/stackleak_plugin.c | 2 +- > scripts/gcc-plugins/structleak_plugin.c | 2 +- > 6 files changed, 10 insertions(+), 9 deletions(-) > > diff --git a/scripts/gcc-plugins/Makefile b/scripts/gcc-plugins/Makefile > index 148f4639cf09..6f0aecad5d67 100644 > --- a/scripts/gcc-plugins/Makefile > +++ b/scripts/gcc-plugins/Makefile > @@ -28,10 +28,11 @@ GCC_PLUGINS_DIR = $(shell $(CC) -print-file-name=plugin) > > plugin_cxxflags = -Wp,-MMD,$(depfile) $(KBUILD_HOSTCXXFLAGS) -fPIC \ > -include $(srctree)/include/linux/compiler-version.h \ > - -I $(GCC_PLUGINS_DIR)/include -I $(obj) -std=gnu++11 \ > - -fno-rtti -fno-exceptions -fasynchronous-unwind-tables \ > - -ggdb -Wno-narrowing -Wno-unused-variable \ > - -Wno-format-diag > + -include $(objtree)/include/generated/utsrelease.h \ > + -I $(GCC_PLUGINS_DIR)/include -I $(obj) -std=gnu++11 \ > + -fno-rtti -fno-exceptions -fasynchronous-unwind-tables \ > + -ggdb -Wno-narrowing -Wno-unused-variable \ > + -Wno-format-diag > > plugin_ldflags = -shared > > diff --git a/scripts/gcc-plugins/latent_entropy_plugin.c b/scripts/gcc-plugins/latent_entropy_plugin.c > index 8425da41de0d..5d415b2572a8 100644 > --- a/scripts/gcc-plugins/latent_entropy_plugin.c > +++ b/scripts/gcc-plugins/latent_entropy_plugin.c > @@ -82,7 +82,7 @@ __visible int plugin_is_GPL_compatible; > static GTY(()) tree latent_entropy_decl; > > static struct plugin_info latent_entropy_plugin_info = { > - .version = "201606141920vanilla", > + .version = UTS_RELEASE, > .help = "disable\tturn off latent entropy instrumentation\n", > }; > > diff --git a/scripts/gcc-plugins/randomize_layout_plugin.c b/scripts/gcc-plugins/randomize_layout_plugin.c > index 65aee5d6d91e..ea2aea570404 100644 > --- a/scripts/gcc-plugins/randomize_layout_plugin.c > +++ b/scripts/gcc-plugins/randomize_layout_plugin.c > @@ -34,7 +34,7 @@ __visible int plugin_is_GPL_compatible; > static int performance_mode; > > static struct plugin_info randomize_layout_plugin_info = { > - .version = "201402201816vanilla", > + .version = UTS_RELEASE, > .help = "disable\t\t\tdo not activate plugin\n" > "performance-mode\tenable cacheline-aware layout randomization\n" > }; > diff --git a/scripts/gcc-plugins/sancov_plugin.c b/scripts/gcc-plugins/sancov_plugin.c > index 23bd023a283b..f3d629555b84 100644 > --- a/scripts/gcc-plugins/sancov_plugin.c > +++ b/scripts/gcc-plugins/sancov_plugin.c > @@ -26,7 +26,7 @@ __visible int plugin_is_GPL_compatible; > tree sancov_fndecl; > > static struct plugin_info sancov_plugin_info = { > - .version = "20160402", > + .version = UTS_RELEASE, > .help = "sancov plugin\n", > }; > > diff --git a/scripts/gcc-plugins/stackleak_plugin.c b/scripts/gcc-plugins/stackleak_plugin.c > index 42f0252ee2a4..de817d54b8af 100644 > --- a/scripts/gcc-plugins/stackleak_plugin.c > +++ b/scripts/gcc-plugins/stackleak_plugin.c > @@ -44,7 +44,7 @@ static bool verbose = false; > static GTY(()) tree track_function_decl; > > static struct plugin_info stackleak_plugin_info = { > - .version = "201707101337", > + .version = UTS_RELEASE, > .help = "track-min-size=nn\ttrack stack for functions with a stack frame size >= nn bytes\n" > "arch=target_arch\tspecify target build arch\n" > "disable\t\tdo not activate the plugin\n" > diff --git a/scripts/gcc-plugins/structleak_plugin.c b/scripts/gcc-plugins/structleak_plugin.c > index 74e319288389..86b608a24ec0 100644 > --- a/scripts/gcc-plugins/structleak_plugin.c > +++ b/scripts/gcc-plugins/structleak_plugin.c > @@ -37,7 +37,7 @@ > __visible int plugin_is_GPL_compatible; > > static struct plugin_info structleak_plugin_info = { > - .version = "20190125vanilla", > + .version = UTS_RELEASE, > .help = "disable\tdo not activate plugin\n" > "byref\tinit structs passed by reference\n" > "byref-all\tinit anything passed by reference\n" > -- > 2.32.0 >
On Mon, May 23, 2022 at 07:30:54AM -0700, Guenter Roeck wrote: > On Tue, May 10, 2022 at 04:54:12PM -0700, Kees Cook wrote: > > It's not meaningful for the GCC plugins to track their versions separately > > from the rest of the kernel. Switch all versions to the kernel version. > > > > Fix mismatched indenting while we're at it. > > > > Cc: linux-hardening@vger.kernel.org > > Signed-off-by: Kees Cook <keescook@chromium.org> > > I see random build failures with this patch in linux-next. > > Error log: > cc1plus: fatal error: ./include/generated/utsrelease.h: No such file or directory > > The problem doesn't happen all the time. Is there some missing dependency ? I've seen 0-day reports on this too and but I haven't been able to reproduce it. AFAICT, utsrelease.h should be generated before the gcc plugins are built, but clearly something is wrong. > > plugin_cxxflags = -Wp,-MMD,$(depfile) $(KBUILD_HOSTCXXFLAGS) -fPIC \ > > -include $(srctree)/include/linux/compiler-version.h \ > > + -include $(objtree)/include/generated/utsrelease.h \ I wonder if include/generated/utsrelease.h needs to be explicitly added as a build dep to the plugin logic?
On Mon, May 23, 2022 at 07:30:54AM -0700, Guenter Roeck wrote: > On Tue, May 10, 2022 at 04:54:12PM -0700, Kees Cook wrote: > > It's not meaningful for the GCC plugins to track their versions separately > > from the rest of the kernel. Switch all versions to the kernel version. > > > > Fix mismatched indenting while we're at it. > > > > Cc: linux-hardening@vger.kernel.org > > Signed-off-by: Kees Cook <keescook@chromium.org> > > I see random build failures with this patch in linux-next. > > Error log: > cc1plus: fatal error: ./include/generated/utsrelease.h: No such file or directory > > The problem doesn't happen all the time. Is there some missing dependency ? Here's a prior report I hadn't been able to repro: https://lore.kernel.org/linux-mm/202205230239.EZxeZ3Fv-lkp@intel.com But now I can: I see it with a -j1 build. This fixes it for me: diff --git a/Makefile b/Makefile index 91c91fcf3c24..c04420d5aa3d 100644 --- a/Makefile +++ b/Makefile @@ -1175,7 +1175,7 @@ include/config/kernel.release: FORCE # Carefully list dependencies so we do not try to build scripts twice # in parallel PHONY += scripts -scripts: scripts_basic scripts_dtc +scripts: include/generated/utsrelease.h scripts_basic scripts_dtc $(Q)$(MAKE) $(build)=$(@) # Things we need to do before we recursively start building the kernel diff --git a/scripts/gcc-plugins/Makefile b/scripts/gcc-plugins/Makefile index 6f0aecad5d67..c29334669a16 100644 --- a/scripts/gcc-plugins/Makefile +++ b/scripts/gcc-plugins/Makefile @@ -64,5 +64,5 @@ $(foreach m, $(notdir $(plugin-multi)), $(eval $(obj)/$m: $(addprefix $(obj)/, $ quiet_cmd_plugin_cxx_o_c = HOSTCXX $@ cmd_plugin_cxx_o_c = $(HOSTCXX) $(plugin_cxxflags) -c -o $@ $< -$(plugin-objs): $(obj)/%.o: $(src)/%.c FORCE +$(plugin-objs): $(obj)/%.o: $(src)/%.c $(objdir)/include/generated/utsrelease.h FORCE $(call if_changed_dep,plugin_cxx_o_c) Both "include/generated/utsrelease.h" and "scripts" were same-level deps, so they were racing.
On Mon, May 23, 2022 at 12:28:20PM -0700, Kees Cook wrote: > On Mon, May 23, 2022 at 07:30:54AM -0700, Guenter Roeck wrote: > > On Tue, May 10, 2022 at 04:54:12PM -0700, Kees Cook wrote: > > > It's not meaningful for the GCC plugins to track their versions separately > > > from the rest of the kernel. Switch all versions to the kernel version. > > > > > > Fix mismatched indenting while we're at it. > > > > > > Cc: linux-hardening@vger.kernel.org > > > Signed-off-by: Kees Cook <keescook@chromium.org> > > > > I see random build failures with this patch in linux-next. > > > > Error log: > > cc1plus: fatal error: ./include/generated/utsrelease.h: No such file or directory > > > > The problem doesn't happen all the time. Is there some missing dependency ? > > I've seen 0-day reports on this too and but I haven't been able to reproduce > it. AFAICT, utsrelease.h should be generated before the gcc plugins are > built, but clearly something is wrong. > I have seen it only in my test builds, only on arm targets so far, and I have been unable to reproduce it manually. > > > plugin_cxxflags = -Wp,-MMD,$(depfile) $(KBUILD_HOSTCXXFLAGS) -fPIC \ > > > -include $(srctree)/include/linux/compiler-version.h \ > > > + -include $(objtree)/include/generated/utsrelease.h \ > > I wonder if include/generated/utsrelease.h needs to be explicitly added > as a build dep to the plugin logic? > Looks like it, but I have no idea how to set that up or test/confirm it. Guenter
On 2022-05-23 12:54, Kees Cook wrote: > On Mon, May 23, 2022 at 07:30:54AM -0700, Guenter Roeck wrote: > > On Tue, May 10, 2022 at 04:54:12PM -0700, Kees Cook wrote: > > > It's not meaningful for the GCC plugins to track their versions separately > > > from the rest of the kernel. Switch all versions to the kernel version. > > > > > > Fix mismatched indenting while we're at it. > > > > > > Cc: linux-hardening@vger.kernel.org > > > Signed-off-by: Kees Cook <keescook@chromium.org> > > > > I see random build failures with this patch in linux-next. > > > > Error log: > > cc1plus: fatal error: ./include/generated/utsrelease.h: No such file or directory > > > > The problem doesn't happen all the time. Is there some missing dependency ? > > Here's a prior report I hadn't been able to repro: > https://lore.kernel.org/linux-mm/202205230239.EZxeZ3Fv-lkp@intel.com > > But now I can: I see it with a -j1 build. This fixes it for me: I could see this issue when I built an arm64 allmodconfig mainline [1] kernel, on sha 7e062cda7d90 ("Merge tag 'net-next-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next") To reproduce what I built tuxmake [2] can be used: $ tuxmake --runtime podman --target-arch arm64 --toolchain gcc-11 --kconfig http://ix.io/3YBi kernel > > diff --git a/Makefile b/Makefile > index 91c91fcf3c24..c04420d5aa3d 100644 > --- a/Makefile > +++ b/Makefile > @@ -1175,7 +1175,7 @@ include/config/kernel.release: FORCE > # Carefully list dependencies so we do not try to build scripts twice > # in parallel > PHONY += scripts > -scripts: scripts_basic scripts_dtc > +scripts: include/generated/utsrelease.h scripts_basic scripts_dtc > $(Q)$(MAKE) $(build)=$(@) > > # Things we need to do before we recursively start building the kernel > diff --git a/scripts/gcc-plugins/Makefile b/scripts/gcc-plugins/Makefile > index 6f0aecad5d67..c29334669a16 100644 > --- a/scripts/gcc-plugins/Makefile > +++ b/scripts/gcc-plugins/Makefile > @@ -64,5 +64,5 @@ $(foreach m, $(notdir $(plugin-multi)), $(eval $(obj)/$m: $(addprefix $(obj)/, $ > quiet_cmd_plugin_cxx_o_c = HOSTCXX $@ > cmd_plugin_cxx_o_c = $(HOSTCXX) $(plugin_cxxflags) -c -o $@ $< > > -$(plugin-objs): $(obj)/%.o: $(src)/%.c FORCE > +$(plugin-objs): $(obj)/%.o: $(src)/%.c $(objdir)/include/generated/utsrelease.h FORCE > $(call if_changed_dep,plugin_cxx_o_c) > > Both "include/generated/utsrelease.h" and "scripts" were same-level > deps, so they were racing. This patch patch solved the build error. Cheers, Anders [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/ [2] https://tuxmake.org/install-pypi/
diff --git a/scripts/gcc-plugins/Makefile b/scripts/gcc-plugins/Makefile index 148f4639cf09..6f0aecad5d67 100644 --- a/scripts/gcc-plugins/Makefile +++ b/scripts/gcc-plugins/Makefile @@ -28,10 +28,11 @@ GCC_PLUGINS_DIR = $(shell $(CC) -print-file-name=plugin) plugin_cxxflags = -Wp,-MMD,$(depfile) $(KBUILD_HOSTCXXFLAGS) -fPIC \ -include $(srctree)/include/linux/compiler-version.h \ - -I $(GCC_PLUGINS_DIR)/include -I $(obj) -std=gnu++11 \ - -fno-rtti -fno-exceptions -fasynchronous-unwind-tables \ - -ggdb -Wno-narrowing -Wno-unused-variable \ - -Wno-format-diag + -include $(objtree)/include/generated/utsrelease.h \ + -I $(GCC_PLUGINS_DIR)/include -I $(obj) -std=gnu++11 \ + -fno-rtti -fno-exceptions -fasynchronous-unwind-tables \ + -ggdb -Wno-narrowing -Wno-unused-variable \ + -Wno-format-diag plugin_ldflags = -shared diff --git a/scripts/gcc-plugins/latent_entropy_plugin.c b/scripts/gcc-plugins/latent_entropy_plugin.c index 8425da41de0d..5d415b2572a8 100644 --- a/scripts/gcc-plugins/latent_entropy_plugin.c +++ b/scripts/gcc-plugins/latent_entropy_plugin.c @@ -82,7 +82,7 @@ __visible int plugin_is_GPL_compatible; static GTY(()) tree latent_entropy_decl; static struct plugin_info latent_entropy_plugin_info = { - .version = "201606141920vanilla", + .version = UTS_RELEASE, .help = "disable\tturn off latent entropy instrumentation\n", }; diff --git a/scripts/gcc-plugins/randomize_layout_plugin.c b/scripts/gcc-plugins/randomize_layout_plugin.c index 65aee5d6d91e..ea2aea570404 100644 --- a/scripts/gcc-plugins/randomize_layout_plugin.c +++ b/scripts/gcc-plugins/randomize_layout_plugin.c @@ -34,7 +34,7 @@ __visible int plugin_is_GPL_compatible; static int performance_mode; static struct plugin_info randomize_layout_plugin_info = { - .version = "201402201816vanilla", + .version = UTS_RELEASE, .help = "disable\t\t\tdo not activate plugin\n" "performance-mode\tenable cacheline-aware layout randomization\n" }; diff --git a/scripts/gcc-plugins/sancov_plugin.c b/scripts/gcc-plugins/sancov_plugin.c index 23bd023a283b..f3d629555b84 100644 --- a/scripts/gcc-plugins/sancov_plugin.c +++ b/scripts/gcc-plugins/sancov_plugin.c @@ -26,7 +26,7 @@ __visible int plugin_is_GPL_compatible; tree sancov_fndecl; static struct plugin_info sancov_plugin_info = { - .version = "20160402", + .version = UTS_RELEASE, .help = "sancov plugin\n", }; diff --git a/scripts/gcc-plugins/stackleak_plugin.c b/scripts/gcc-plugins/stackleak_plugin.c index 42f0252ee2a4..de817d54b8af 100644 --- a/scripts/gcc-plugins/stackleak_plugin.c +++ b/scripts/gcc-plugins/stackleak_plugin.c @@ -44,7 +44,7 @@ static bool verbose = false; static GTY(()) tree track_function_decl; static struct plugin_info stackleak_plugin_info = { - .version = "201707101337", + .version = UTS_RELEASE, .help = "track-min-size=nn\ttrack stack for functions with a stack frame size >= nn bytes\n" "arch=target_arch\tspecify target build arch\n" "disable\t\tdo not activate the plugin\n" diff --git a/scripts/gcc-plugins/structleak_plugin.c b/scripts/gcc-plugins/structleak_plugin.c index 74e319288389..86b608a24ec0 100644 --- a/scripts/gcc-plugins/structleak_plugin.c +++ b/scripts/gcc-plugins/structleak_plugin.c @@ -37,7 +37,7 @@ __visible int plugin_is_GPL_compatible; static struct plugin_info structleak_plugin_info = { - .version = "20190125vanilla", + .version = UTS_RELEASE, .help = "disable\tdo not activate plugin\n" "byref\tinit structs passed by reference\n" "byref-all\tinit anything passed by reference\n"
It's not meaningful for the GCC plugins to track their versions separately from the rest of the kernel. Switch all versions to the kernel version. Fix mismatched indenting while we're at it. Cc: linux-hardening@vger.kernel.org Signed-off-by: Kees Cook <keescook@chromium.org> --- scripts/gcc-plugins/Makefile | 9 +++++---- scripts/gcc-plugins/latent_entropy_plugin.c | 2 +- scripts/gcc-plugins/randomize_layout_plugin.c | 2 +- scripts/gcc-plugins/sancov_plugin.c | 2 +- scripts/gcc-plugins/stackleak_plugin.c | 2 +- scripts/gcc-plugins/structleak_plugin.c | 2 +- 6 files changed, 10 insertions(+), 9 deletions(-)