All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: kbuild-all@lists.01.org
Subject: [deller-parisc:for-next-maybe 1/1] mm/usercopy.c:134:2: warning: this 'if' clause does not guard...
Date: Wed, 01 Dec 2021 11:11:46 +0800	[thread overview]
Message-ID: <202112011144.adv9Pf3v-lkp@intel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 5062 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux.git for-next-maybe
head:   4d7b3620412d727e09bf0eef942be42da363260d
commit: 4d7b3620412d727e09bf0eef942be42da363260d [1/1] usercopy: Do not fail if memory is from the init section
config: i386-randconfig-r033-20211129 (https://download.01.org/0day-ci/archive/20211201/202112011144.adv9Pf3v-lkp(a)intel.com/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
        # https://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux.git/commit/?id=4d7b3620412d727e09bf0eef942be42da363260d
        git remote add deller-parisc https://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux.git
        git fetch --no-tags deller-parisc for-next-maybe
        git checkout 4d7b3620412d727e09bf0eef942be42da363260d
        # save the config file to linux build tree
        mkdir build_dir
        make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   mm/usercopy.c: In function 'check_kernel_text_object':
   mm/usercopy.c:134:56: error: expected ')' before 'return'
     134 |  if (inside_init_area(ptr, n, __init_begin, __init_end)
         |     ~                                                  ^
         |                                                        )
     135 |   return;
         |   ~~~~~~                                                
>> mm/usercopy.c:134:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     134 |  if (inside_init_area(ptr, n, __init_begin, __init_end)
         |  ^~
   mm/usercopy.c:324: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
     324 | late_initcall(set_hardened_usercopy);
         | 
   mm/usercopy.c:324:1: error: expected declaration or statement at end of input
     324 | late_initcall(set_hardened_usercopy);
         | ^~~~~~~~~~~~~
   mm/usercopy.c:131:32: warning: unused variable 'texthigh_linear' [-Wunused-variable]
     131 |  unsigned long textlow_linear, texthigh_linear;
         |                                ^~~~~~~~~~~~~~~
   mm/usercopy.c:131:16: warning: unused variable 'textlow_linear' [-Wunused-variable]
     131 |  unsigned long textlow_linear, texthigh_linear;
         |                ^~~~~~~~~~~~~~
   mm/usercopy.c:130:16: warning: unused variable 'texthigh' [-Wunused-variable]
     130 |  unsigned long texthigh = (unsigned long)_etext;
         |                ^~~~~~~~
   mm/usercopy.c:129:16: warning: unused variable 'textlow' [-Wunused-variable]
     129 |  unsigned long textlow = (unsigned long)_stext;
         |                ^~~~~~~
   At top level:
   mm/usercopy.c:103:13: warning: 'overlaps' defined but not used [-Wunused-function]
     103 | static bool overlaps(const unsigned long ptr, unsigned long n,
         |             ^~~~~~~~
   mm/usercopy.c:34:21: warning: 'check_stack_object' defined but not used [-Wunused-function]
      34 | static noinline int check_stack_object(const void *obj, unsigned long len)
         |                     ^~~~~~~~~~~~~~~~~~


vim +/if +134 mm/usercopy.c

   124	
   125	/* Is this address range in the kernel text area? */
   126	static inline void check_kernel_text_object(const unsigned long ptr,
   127						    unsigned long n, bool to_user)
   128	{
   129		unsigned long textlow = (unsigned long)_stext;
   130		unsigned long texthigh = (unsigned long)_etext;
   131		unsigned long textlow_linear, texthigh_linear;
   132	
   133		/* Ok if inside the former init sections */
 > 134		if (inside_init_area(ptr, n, __init_begin, __init_end)
   135			return;
   136		if (inside_init_area(ptr, n, _sinittext, _einittext)
   137			return;
   138	
   139		if (overlaps(ptr, n, textlow, texthigh))
   140			usercopy_abort("kernel text", NULL, to_user, ptr - textlow, n);
   141	
   142		/*
   143		 * Some architectures have virtual memory mappings with a secondary
   144		 * mapping of the kernel text, i.e. there is more than one virtual
   145		 * kernel address that points to the kernel image. It is usually
   146		 * when there is a separate linear physical memory mapping, in that
   147		 * __pa() is not just the reverse of __va(). This can be detected
   148		 * and checked:
   149		 */
   150		textlow_linear = (unsigned long)lm_alias(textlow);
   151		/* No different mapping: we're done. */
   152		if (textlow_linear == textlow)
   153			return;
   154	
   155		/* Check the secondary mapping... */
   156		texthigh_linear = (unsigned long)lm_alias(texthigh);
   157		if (overlaps(ptr, n, textlow_linear, texthigh_linear))
   158			usercopy_abort("linear kernel text", NULL, to_user,
   159				       ptr - textlow_linear, n);
   160	}
   161	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

WARNING: multiple messages have this Message-ID (diff)
From: kernel test robot <lkp@intel.com>
To: Helge Deller <deller@gmx.de>
Cc: kbuild-all@lists.01.org, linux-kernel@vger.kernel.org
Subject: [deller-parisc:for-next-maybe 1/1] mm/usercopy.c:134:2: warning: this 'if' clause does not guard...
Date: Wed, 1 Dec 2021 11:11:46 +0800	[thread overview]
Message-ID: <202112011144.adv9Pf3v-lkp@intel.com> (raw)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux.git for-next-maybe
head:   4d7b3620412d727e09bf0eef942be42da363260d
commit: 4d7b3620412d727e09bf0eef942be42da363260d [1/1] usercopy: Do not fail if memory is from the init section
config: i386-randconfig-r033-20211129 (https://download.01.org/0day-ci/archive/20211201/202112011144.adv9Pf3v-lkp@intel.com/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
        # https://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux.git/commit/?id=4d7b3620412d727e09bf0eef942be42da363260d
        git remote add deller-parisc https://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux.git
        git fetch --no-tags deller-parisc for-next-maybe
        git checkout 4d7b3620412d727e09bf0eef942be42da363260d
        # save the config file to linux build tree
        mkdir build_dir
        make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   mm/usercopy.c: In function 'check_kernel_text_object':
   mm/usercopy.c:134:56: error: expected ')' before 'return'
     134 |  if (inside_init_area(ptr, n, __init_begin, __init_end)
         |     ~                                                  ^
         |                                                        )
     135 |   return;
         |   ~~~~~~                                                
>> mm/usercopy.c:134:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     134 |  if (inside_init_area(ptr, n, __init_begin, __init_end)
         |  ^~
   mm/usercopy.c:324: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
     324 | late_initcall(set_hardened_usercopy);
         | 
   mm/usercopy.c:324:1: error: expected declaration or statement at end of input
     324 | late_initcall(set_hardened_usercopy);
         | ^~~~~~~~~~~~~
   mm/usercopy.c:131:32: warning: unused variable 'texthigh_linear' [-Wunused-variable]
     131 |  unsigned long textlow_linear, texthigh_linear;
         |                                ^~~~~~~~~~~~~~~
   mm/usercopy.c:131:16: warning: unused variable 'textlow_linear' [-Wunused-variable]
     131 |  unsigned long textlow_linear, texthigh_linear;
         |                ^~~~~~~~~~~~~~
   mm/usercopy.c:130:16: warning: unused variable 'texthigh' [-Wunused-variable]
     130 |  unsigned long texthigh = (unsigned long)_etext;
         |                ^~~~~~~~
   mm/usercopy.c:129:16: warning: unused variable 'textlow' [-Wunused-variable]
     129 |  unsigned long textlow = (unsigned long)_stext;
         |                ^~~~~~~
   At top level:
   mm/usercopy.c:103:13: warning: 'overlaps' defined but not used [-Wunused-function]
     103 | static bool overlaps(const unsigned long ptr, unsigned long n,
         |             ^~~~~~~~
   mm/usercopy.c:34:21: warning: 'check_stack_object' defined but not used [-Wunused-function]
      34 | static noinline int check_stack_object(const void *obj, unsigned long len)
         |                     ^~~~~~~~~~~~~~~~~~


vim +/if +134 mm/usercopy.c

   124	
   125	/* Is this address range in the kernel text area? */
   126	static inline void check_kernel_text_object(const unsigned long ptr,
   127						    unsigned long n, bool to_user)
   128	{
   129		unsigned long textlow = (unsigned long)_stext;
   130		unsigned long texthigh = (unsigned long)_etext;
   131		unsigned long textlow_linear, texthigh_linear;
   132	
   133		/* Ok if inside the former init sections */
 > 134		if (inside_init_area(ptr, n, __init_begin, __init_end)
   135			return;
   136		if (inside_init_area(ptr, n, _sinittext, _einittext)
   137			return;
   138	
   139		if (overlaps(ptr, n, textlow, texthigh))
   140			usercopy_abort("kernel text", NULL, to_user, ptr - textlow, n);
   141	
   142		/*
   143		 * Some architectures have virtual memory mappings with a secondary
   144		 * mapping of the kernel text, i.e. there is more than one virtual
   145		 * kernel address that points to the kernel image. It is usually
   146		 * when there is a separate linear physical memory mapping, in that
   147		 * __pa() is not just the reverse of __va(). This can be detected
   148		 * and checked:
   149		 */
   150		textlow_linear = (unsigned long)lm_alias(textlow);
   151		/* No different mapping: we're done. */
   152		if (textlow_linear == textlow)
   153			return;
   154	
   155		/* Check the secondary mapping... */
   156		texthigh_linear = (unsigned long)lm_alias(texthigh);
   157		if (overlaps(ptr, n, textlow_linear, texthigh_linear))
   158			usercopy_abort("linear kernel text", NULL, to_user,
   159				       ptr - textlow_linear, n);
   160	}
   161	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

             reply	other threads:[~2021-12-01  3:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-01  3:11 kernel test robot [this message]
2021-12-01  3:11 ` [deller-parisc:for-next-maybe 1/1] mm/usercopy.c:134:2: warning: this 'if' clause does not guard kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202112011144.adv9Pf3v-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=kbuild-all@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.