mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nick Desaulniers <ndesaulniers@google.com>
To: jpoimboe@redhat.com, peterz@infradead.org
Cc: Nick Desaulniers <ndesaulniers@google.com>,
	Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>,
	Matt Helsley <mhelsley@vmware.com>,
	Randy Dunlap <rdunlap@infradead.org>,
	Jonathan Corbet <corbet@lwn.net>,
	Mauro Carvalho Chehab <mchehab+samsung@kernel.org>,
	Petr Mladek <pmladek@suse.com>,
	Raphael Gault <raphael.gault@arm.com>,
	linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com
Subject: [PATCH v2] objtool: Documentation: document UACCESS warnings
Date: Thu, 26 Mar 2020 11:37:06 -0700	[thread overview]
Message-ID: <20200326183707.238474-1-ndesaulniers@google.com> (raw)
In-Reply-To: <20200326134701.GA118458@rlwimi.vmware.com>

Compiling with Clang and CONFIG_KASAN=y was exposing a few warnings:
  call to memset() with UACCESS enabled

Document how to fix these for future travelers.

Link: https://github.com/ClangBuiltLinux/linux/issues/876
Suggested-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
Suggested-by: Matt Helsley <mhelsley@vmware.com>
Suggested-by: Peter Zijlstra <peterz@infradead.org>
Suggested-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
---
Changes V1 -> V2:
* fix typo of listing uaccess_enable() twice rather than
  uaccess_disable() as per Matt and Kamalesh.
* fix type of "should called" to "should be called" as per Randy.
* Mention non-obvious compiler instrumentation ie. -pg/mcount
  -mfentry/fentry via tracing as per Peter.
* Add sentence "It also helps verify..."
* Add potential fix "1) remove explicit..."


 .../Documentation/stack-validation.txt        | 26 +++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/tools/objtool/Documentation/stack-validation.txt b/tools/objtool/Documentation/stack-validation.txt
index de094670050b..faa47c3aafae 100644
--- a/tools/objtool/Documentation/stack-validation.txt
+++ b/tools/objtool/Documentation/stack-validation.txt
@@ -289,6 +289,32 @@ they mean, and suggestions for how to fix them.
       might be corrupt due to a gcc bug.  For more details, see:
       https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70646
 
+9. file.o: warning: objtool: funcA() call to funcB() with UACCESS enabled
+
+   This means that an unexpected call to a non-whitelisted function exists
+   outside of arch-specific guards.
+   X86: SMAP (stac/clac): __uaccess_begin()/__uaccess_end()
+   ARM: PAN: uaccess_enable()/uaccess_disable()
+
+   These functions should be called to denote a minimal critical section around
+   access to __user variables. See also: https://lwn.net/Articles/517475/
+
+   The intention of the warning is to prevent calls to funcB() from eventually
+   calling schedule(), potentially leaking the AC flags state, and not
+   restoring them correctly.
+
+   It also helps verify that there are no unexpected calls to funcB() which may
+   access user space pages with protections against doing so disabled.
+
+   To fix, either:
+   1) remove explicit calls to funcB() from funcA().
+   2) add the correct guards before and after calls to low level functions like
+      __get_user_size()/__put_user_size().
+   3) add funcB to uaccess_safe_builtin whitelist in tools/objtool/check.c, if
+      funcB obviously does not call schedule(), and is marked notrace (since
+      function tracing inserts additional calls, which is not obvious from the
+      sources).
+
 
 If the error doesn't seem to make sense, it could be a bug in objtool.
 Feel free to ask the objtool maintainer for help.
-- 
2.26.0.rc2.310.g2932bb562d-goog


  reply	other threads:[~2020-03-26 18:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200323212538.GN2452@worktop.programming.kicks-ass.net>
2020-03-24  0:13 ` [PATCH] " Nick Desaulniers
2020-03-24  1:12   ` Randy Dunlap
2020-03-24  8:41   ` Kamalesh Babulal
2020-03-24 12:52   ` Peter Zijlstra
2020-03-26 13:47   ` Matt Helsley
2020-03-26 18:37     ` Nick Desaulniers [this message]
2020-04-03 16:20       ` [PATCH v2] " Josh Poimboeuf

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=20200326183707.238474-1-ndesaulniers@google.com \
    --to=ndesaulniers@google.com \
    --cc=clang-built-linux@googlegroups.com \
    --cc=corbet@lwn.net \
    --cc=jpoimboe@redhat.com \
    --cc=kamalesh@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab+samsung@kernel.org \
    --cc=mhelsley@vmware.com \
    --cc=peterz@infradead.org \
    --cc=pmladek@suse.com \
    --cc=raphael.gault@arm.com \
    --cc=rdunlap@infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®