Skip to content
Snippets Groups Projects
  1. Aug 03, 2022
    • Florian Fainelli's avatar
      tools/thermal: Fix possible path truncations · 6c58cf40
      Florian Fainelli authored
      
      A build with -D_FORTIFY_SOURCE=2 enabled will produce the following warnings:
      
      sysfs.c:63:30: warning: '%s' directive output may be truncated writing up to 255 bytes into a region of size between 0 and 255 [-Wformat-truncation=]
        snprintf(filepath, 256, "%s/%s", path, filename);
                                    ^~
      Bump up the buffer to PATH_MAX which is the limit and account for all of
      the possible NUL and separators that could lead to exceeding the
      allocated buffer sizes.
      
      Fixes: 94f69966 ("tools/thermal: Introduce tmon, a tool for thermal subsystem")
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      6c58cf40
  2. Jul 28, 2022
  3. May 19, 2022
  4. Nov 24, 2021
  5. Aug 14, 2021
  6. Apr 24, 2021
    • Masahiro Yamada's avatar
      tools: do not include scripts/Kbuild.include · b61442df
      Masahiro Yamada authored
      Since commit 57fd251c ("kbuild: split cc-option and friends to
      scripts/Makefile.compiler"), some kselftests fail to build.
      
      The tools/ directory opted out Kbuild, and went in a different
      direction. People copied scripts and Makefiles to the tools/ directory
      to create their own build system.
      
      tools/build/Build.include mimics scripts/Kbuild.include, but some
      tool Makefiles include the Kbuild one to import a feature that is
      missing in tools/build/Build.include:
      
       - Commit ec04aa3a ("tools/thermal: tmon: use "-fstack-protector"
         only if supported") included scripts/Kbuild.include from
         tools/thermal/tmon/Makefile to import the cc-option macro.
      
       - Commit c2390f16 ("selftests: kvm: fix for compilers that do
         not support -no-pie") included scripts/Kbuild.include from
         tools/testing/selftests/kvm/Makefile to import the try-run macro.
      
       - Commit 9cae4ace ("selftests/bpf: do not ignore clang
         failures") included scripts/Kbuild.include from
         tools/testing/selftests/bpf/Makefile to import the .DELETE_ON_ERROR
         target.
      
       - Commit 0695f8bc ("selftests/powerpc: Handle Makefile for
         unrecognized option") included scripts/Kbuild.include from
         tools/testing/selftests/powerpc/pmu/ebb/Makefile to import the
         try-run macro.
      
      Copy what they need into tools/build/Build.include, and make them
      include it instead of scripts/Kbuild.include.
      
      Link: https://lore.kernel.org/lkml/86dadf33-70f7-a5ac-cb8c-64966d2f45a1@linux.ibm.com/
      
      
      Fixes: 57fd251c ("kbuild: split cc-option and friends to scripts/Makefile.compiler")
      Reported-by: default avatarJanosch Frank <frankja@linux.ibm.com>
      Reported-by: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Tested-by: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
      Acked-by: default avatarYonghong Song <yhs@fb.com>
      b61442df
  7. Mar 25, 2020
  8. Mar 23, 2020
  9. May 24, 2019
  10. Jan 04, 2019
  11. Dec 28, 2018
  12. Mar 27, 2018
    • Frank Asseg's avatar
      tools/thermal: tmon: fix for segfault · 6c59f64b
      Frank Asseg authored
      
      Fixes a segfault occurring when e.g. <TAB> is pressed multiple times in the
      ncurses tmon application. The segfault is caused by incrementing
      cur_thermal_record in the main function without checking if it's value reached
      NR_THERMAL_RECORD immediately. Since the boundary check only occurred in
      update_thermal_data a race condition existed, which lead to an attempted read
      beyond the last element of the trec array.
      
      The fix was implemented by moving the cur_thermal_record incrementation to the
      update_thermal_data function using a temporary variable on which the boundary
      condition is checked before updating cur_thread_record, so that the variable is
      never incremented beyond the trec array's boundary.
      
      It seems the segfault does not occur on every machine: On a HP EliteBook G4 the
      segfault happens, while it does not happen on a Thinkpad T540p.
      
      Signed-off-by: default avatarFrank Asseg <frank.asseg@objecthunter.net>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      6c59f64b
  13. Nov 02, 2017
    • Greg Kroah-Hartman's avatar
      License cleanup: add SPDX GPL-2.0 license identifier to files with no license · b2441318
      Greg Kroah-Hartman authored
      
      Many source files in the tree are missing licensing information, which
      makes it harder for compliance tools to determine the correct license.
      
      By default all files without license information are under the default
      license of the kernel, which is GPL version 2.
      
      Update the files which contain no license information with the 'GPL-2.0'
      SPDX license identifier.  The SPDX identifier is a legally binding
      shorthand, which can be used instead of the full boiler plate text.
      
      This patch is based on work done by Thomas Gleixner and Kate Stewart and
      Philippe Ombredanne.
      
      How this work was done:
      
      Patches were generated and checked against linux-4.14-rc6 for a subset of
      the use cases:
       - file had no licensing information it it.
       - file was a */uapi/* one with no licensing information in it,
       - file was a */uapi/* one with existing licensing information,
      
      Further patches will be generated in subsequent months to fix up cases
      where non-standard license headers were used, and references to license
      had to be inferred by heuristics based on keywords.
      
      The analysis to determine which SPDX License Identifier to be applied to
      a file was done in a spreadsheet of side by side results from of the
      output of two independent scanners (ScanCode & Windriver) producing SPDX
      tag:value files created by Philippe Ombredanne.  Philippe prepared the
      base worksheet, and did an initial spot review of a few 1000 files.
      
      The 4.13 kernel was the starting point of the analysis with 60,537 files
      assessed.  Kate Stewart did a file by file comparison of the scanner
      results in the spreadsheet to determine which SPDX license identifier(s)
      to be applied to the file. She confirmed any determination that was not
      immediately clear with lawyers working with the Linux Foundation.
      
      Criteria used to select files for SPDX license identifier tagging was:
       - Files considered eligible had to be source code files.
       - Make and config files were included as candidates if they contained >5
         lines of source
       - File already had some variant of a license header in it (even if <5
         lines).
      
      All documentation files were explicitly excluded.
      
      The following heuristics were used to determine which SPDX license
      identifiers to apply.
      
       - when both scanners couldn't find any license traces, file was
         considered to have no license information in it, and the top level
         COPYING file license applied.
      
         For non */uapi/* files that summary was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0                                              11139
      
         and resulted in the first patch in this series.
      
         If that file was a */uapi/* path one, it was "GPL-2.0 WITH
         Linux-syscall-note" otherwise it was "GPL-2.0".  Results of that was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0 WITH Linux-syscall-note                        930
      
         and resulted in the second patch in this series.
      
       - if a file had some form of licensing information in it, and was one
         of the */uapi/* ones, it was denoted with the Linux-syscall-note if
         any GPL family license was found in the file or had no licensing in
         it (per prior point).  Results summary:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|------
         GPL-2.0 WITH Linux-syscall-note                       270
         GPL-2.0+ WITH Linux-syscall-note                      169
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause)    21
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)    17
         LGPL-2.1+ WITH Linux-syscall-note                      15
         GPL-1.0+ WITH Linux-syscall-note                       14
         ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause)    5
         LGPL-2.0+ WITH Linux-syscall-note                       4
         LGPL-2.1 WITH Linux-syscall-note                        3
         ((GPL-2.0 WITH Linux-syscall-note) OR MIT)              3
         ((GPL-2.0 WITH Linux-syscall-note) AND MIT)             1
      
         and that resulted in the third patch in this series.
      
       - when the two scanners agreed on the detected license(s), that became
         the concluded license(s).
      
       - when there was disagreement between the two scanners (one detected a
         license but the other didn't, or they both detected different
         licenses) a manual inspection of the file occurred.
      
       - In most cases a manual inspection of the information in the file
         resulted in a clear resolution of the license that should apply (and
         which scanner probably needed to revisit its heuristics).
      
       - When it was not immediately clear, the license identifier was
         confirmed with lawyers working with the Linux Foundation.
      
       - If there was any question as to the appropriate license identifier,
         the file was flagged for further research and to be revisited later
         in time.
      
      In total, over 70 hours of logged manual review was done on the
      spreadsheet to determine the SPDX license identifiers to apply to the
      source files by Kate, Philippe, Thomas and, in some cases, confirmation
      by lawyers working with the Linux Foundation.
      
      Kate also obtained a third independent scan of the 4.13 code base from
      FOSSology, and compared selected files where the other two scanners
      disagreed against that SPDX file, to see if there was new insights.  The
      Windriver scanner is based on an older version of FOSSology in part, so
      they are related.
      
      Thomas did random spot checks in about 500 files from the spreadsheets
      for the uapi headers and agreed with SPDX license identifier in the
      files he inspected. For the non-uapi files Thomas did random spot checks
      in about 15000 files.
      
      In initial set of patches against 4.14-rc6, 3 files were found to have
      copy/paste license identifier errors, and have been fixed to reflect the
      correct identifier.
      
      Additionally Philippe spent 10 hours this week doing a detailed manual
      inspection and review of the 12,461 patched files from the initial patch
      version early this week with:
       - a full scancode scan run, collecting the matched texts, detected
         license ids and scores
       - reviewing anything where there was a license detected (about 500+
         files) to ensure that the applied SPDX license was correct
       - reviewing anything where there was no detection but the patch license
         was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
         SPDX license was correct
      
      This produced a worksheet with 20 files needing minor correction.  This
      worksheet was then exported into 3 different .csv files for the
      different types of files to be modified.
      
      These .csv files were then reviewed by Greg.  Thomas wrote a script to
      parse the csv files and add the proper SPDX tag to the file, in the
      format that the file expected.  This script was further refined by Greg
      based on the output to detect more types of files automatically and to
      distinguish between header and source .c files (which need different
      comment types.)  Finally Greg ran the script using the .csv files to
      generate the patches.
      
      Reviewed-by: default avatarKate Stewart <kstewart@linuxfoundation.org>
      Reviewed-by: default avatarPhilippe Ombredanne <pombredanne@nexb.com>
      Reviewed-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b2441318
  14. Oct 18, 2017
  15. Oct 10, 2015
  16. May 09, 2015
  17. Feb 28, 2015
  18. Dec 09, 2014
  19. Jul 01, 2014
    • Neil Horman's avatar
      tmon: set umask to a reasonable value · 4adccf9f
      Neil Horman authored
      
      Currently, the tmon umask value is set to 0, which means whatever the permission
      mask in the shell are when starting tmon in daemon mode are what the permissions
      of any created files will be.  We should likely set something more explicit, so
      lets go with the usual 022
      
      Signed-off-by: default avatarNeil Horman <nhorman@tuxdriver.com>
      Acked-by: default avatarJacob Pan <jacob.jun.pan@linux.intel.com>
      Signed-off-by: default avatarZhang Rui <rui.zhang@intel.com>
      4adccf9f
    • Neil Horman's avatar
      tmon: Check log file for common secuirty issues · 951fda3d
      Neil Horman authored
      
      The tmon logging system blindly opens its log file on a static path, making it
      very easy for someone to redirect that log information to inappropriate places
      or overwrite other users data.  Do some easy checking to make sure we're not
      logging to a symlink or a file owned by another user.
      
      Signed-off-by: default avatarNeil Horman <nhorman@tuxdriver.com>
      Acked-by: default avatarJacob Pan <jacob.jun.pan@linux.intel.com>
      Signed-off-by: default avatarZhang Rui <rui.zhang@intel.com>
      951fda3d
    • Javi Merino's avatar
      tools/thermal: tmon: fix compilation errors when building statically · 6b533269
      Javi Merino authored
      
      tmon fails to build statically with the following error:
      
      $ make LDFLAGS=-static
      gcc -O1 -Wall -Wshadow -W -Wformat -Wimplicit-function-declaration -Wimplicit-int -fstack-protector -D VERSION=\"1.0\" -static tmon.o tui.o sysfs.o pid.o   -o tmon -lm -lpanel -lncursesw  -lpthread
      tmon.o: In function `tmon_sig_handler':
      tmon.c:(.text+0x21): undefined reference to `stdscr'
      tmon.o: In function `tmon_cleanup':
      tmon.c:(.text+0xb9): undefined reference to `stdscr'
      tmon.c:(.text+0x11e): undefined reference to `stdscr'
      tmon.c:(.text+0x123): undefined reference to `keypad'
      tmon.c:(.text+0x12d): undefined reference to `nocbreak'
      tmon.o: In function `main':
      tmon.c:(.text+0x785): undefined reference to `stdscr'
      tmon.c:(.text+0x78a): undefined reference to `nodelay'
      tui.o: In function `setup_windows':
      tui.c:(.text+0x131): undefined reference to `stdscr'
      tui.c:(.text+0x176): undefined reference to `stdscr'
      tui.c:(.text+0x19f): undefined reference to `stdscr'
      tui.c:(.text+0x1cc): undefined reference to `stdscr'
      tui.c:(.text+0x1ff): undefined reference to `stdscr'
      tui.o:tui.c:(.text+0x229): more undefined references to `stdscr' follow
      tui.o: In function `show_cooling_device':
      [...]
      
      stdscr() and friends are in libtinfo (part of ncurses) so add it to
      the libraries that are linked in when compiling tmon to fix it.
      
      Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
      Cc: Zhang Rui <rui.zhang@intel.com>
      Signed-off-by: default avatarJavi Merino <javi.merino@arm.com>
      Acked-by: default avatarJacob Pan <jacob.jun.pan@linux.intel.com>
      6b533269
  20. Nov 07, 2013
    • Jacob Pan's avatar
      tools/thermal: Introduce tmon, a tool for thermal subsystem · 94f69966
      Jacob Pan authored
      
      Increasingly, Linux is running on thermally constrained devices. The simple
      thermal relationship between processor and fan has become past for modern
      computers.
      
      As hardware vendors cope with the thermal constraints on their products,
      more sensors are added, new cooling capabilities are introduced. The
      complexity of the thermal relationship can grow exponentially among cooling
      devices, zones, sensors, and trip points. They can also change dynamically.
      
      To expose such relationship to the userspace, Linux generic thermal layer
      introduced sysfs entry at /sys/class/thermal with a matrix of symbolic
      links, trip point bindings, and device instances. To traverse such
      matrix by hand is not a trivial task. Testing is also difficult in that
      thermal conditions are often exception cases that hard to reach in
      normal operations.
      
      TMON is conceived as a tool to help visualize, tune, and test the
      complex thermal subsystem.
      
      Signed-off-by: default avatarJacob Pan <jacob.jun.pan@linux.intel.com>
      Signed-off-by: default avatarZhang Rui <rui.zhang@intel.com>
      94f69966
Loading