linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nick Desaulniers <ndesaulniers@google.com>
To: jpoimboe@redhat.com, peterz@infradead.org
Cc: Nick Desaulniers <ndesaulniers@google.com>,
	Mauro Carvalho Chehab <mchehab+samsung@kernel.org>,
	Jonathan Corbet <corbet@lwn.net>,
	Wolfram Sang <wsa@the-dreams.de>,
	Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>,
	Raphael Gault <raphael.gault@arm.com>,
	linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com
Subject: [PATCH] objtool: Documentation: document UACCESS warnings
Date: Mon, 23 Mar 2020 17:13:20 -0700	[thread overview]
Message-ID: <20200324001321.39562-1-ndesaulniers@google.com> (raw)
In-Reply-To: <20200323212538.GN2452@worktop.programming.kicks-ass.net>

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: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
---
 .../Documentation/stack-validation.txt        | 20 +++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/tools/objtool/Documentation/stack-validation.txt b/tools/objtool/Documentation/stack-validation.txt
index de094670050b..156fee13ba02 100644
--- a/tools/objtool/Documentation/stack-validation.txt
+++ b/tools/objtool/Documentation/stack-validation.txt
@@ -289,6 +289,26 @@ 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_enable()
+
+   These functions should 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.
+
+   To fix, either:
+   1) add the correct guards before and after calls to low level functions like
+      __get_user_size()/__put_user_size().
+   2) add funcB to uaccess_safe_builtin whitelist in tools/objtool/check.c, if
+      funcB obviously does not call schedule().
+
 
 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.25.1.696.g5e7596f4ac-goog


       reply	other threads:[~2020-03-24  0:13 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 ` Nick Desaulniers [this message]
2020-03-24  1:12   ` [PATCH] objtool: Documentation: document UACCESS warnings 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     ` [PATCH v2] " Nick Desaulniers
2020-04-03 16:20       ` 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=20200324001321.39562-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=peterz@infradead.org \
    --cc=raphael.gault@arm.com \
    --cc=wsa@the-dreams.de \
    /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;
as well as URLs for NNTP newsgroup(s).