Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp930531img; Thu, 28 Feb 2019 10:05:58 -0800 (PST) X-Google-Smtp-Source: APXvYqzb54lJshn+uluKdqOzjLZ3d4ktRjoF8wdv85a+GNMu5kHwkXqAfrgaaTIC7I7AZNm0CsVG X-Received: by 2002:a17:902:bb0b:: with SMTP id l11mr638319pls.219.1551377157958; Thu, 28 Feb 2019 10:05:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551377157; cv=none; d=google.com; s=arc-20160816; b=GhWBcM80gCSiLUojd5PqTvjrTEicnFTFYxXQ42MVlvOXrb8a7LqYtMcklX1Hp7L/bM rYvrPKR3Jsm6eA3EV0EmBuN83FoFmNrgRFe3PgkaeyWF0KqoNdaOSzoacziJlmw1dy87 1upNoB0npJo4tb7WuxtoEL93TSItxBO9/EE9kF+4k8wp7X/ZgxBU6yoNnT+e7fuTsN15 2+TP/TsCE0c8lO4SqtdzqrrYbIhqZCqi6MYZQefqFkcd503jDtDxI3yI+MCXz7iJ1KCk R/sv2ZV38zEc46dikCbkAYkpRZc4UoX9HBFa2U8hbe6pao4EbNESOeFX4S1oNasUyEd7 2trQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=TjsXv3ru6AjzTqCbbVdxP9coBsEnv9ljHZX2t46U/8Q=; b=frBCnUFOT7CvJPq6O9BwEngkVeghz5/MFohgA85hXIsIbxh2EecVf0AJ6tA2sC1McC HsKre9FtREysNEZov/qetxPDJR4ayTHoyVf2PfT5MOPhZk55kM5inZJnLhmi/rC3V5nG RHRE2bTCppzh6WTmYCeWSL90FnstHmUA6LdE04i+cTb4a5Nwi3Gjp5FmfxK6q9sVUfB/ UBDfmh3MduyqcNiVEh/5J8tkVoUYmYNOtmGArURpQYefcyY6vCWj2fCuW2w1jNCMCIF2 FkOEUVOqvLCBdSIKLSGtkT9cqwErWslPUlxZ+iytcjcNWvtGUGeWg0wJLRFLH4HjzopN CmeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="gDikd4k/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q61si16140145plb.49.2019.02.28.10.05.22; Thu, 28 Feb 2019 10:05:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="gDikd4k/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732411AbfB1QDu (ORCPT + 99 others); Thu, 28 Feb 2019 11:03:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:49754 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731208AbfB1QDu (ORCPT ); Thu, 28 Feb 2019 11:03:50 -0500 Received: from localhost.localdomain (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0C931218B0; Thu, 28 Feb 2019 16:03:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1551369829; bh=0moKi9ZDADvDamp5b4cHz81e+NQhJ8w3MIPUXyiDZQI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gDikd4k/4WtwbrVy+FkwkVJ7/AaJKHSEA0dtvP0kI9CU2uk48GA2p3or1i/7DusKg cVW+BMGivYwr/OkQ8SmOUDFNXeY4vHGUAiFiTNurjpKYmusSHQfk4VYTZK9hiLK6Wk WUqGoAj3fkck0o7OaxtvmtfBWcwDSDVHg+RKyJqk= From: Masami Hiramatsu To: Steven Rostedt , Linus Torvalds , Shuah Khan Cc: mhiramat@kernel.org, linux-kernel@vger.kernel.org, Andy Lutomirski , Ingo Molnar , Andrew Morton , Changbin Du , Jann Horn , Kees Cook , Andy Lutomirski , Alexei Starovoitov , Nadav Amit , Peter Zijlstra , Joel Fernandes , yhs@fb.com Subject: [PATCH v5 2/6] uaccess: Use user_access_ok() in user_access_begin() Date: Fri, 1 Mar 2019 01:03:25 +0900 Message-Id: <155136980507.2968.15165201054223875356.stgit@devbox> X-Mailer: git-send-email 2.13.6 In-Reply-To: <155136974478.2968.3105123100519786079.stgit@devbox> References: <155136974478.2968.3105123100519786079.stgit@devbox> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use user_access_ok() instead of access_ok() in user_access_begin() to validate the access context is user. This also allow us to use (generic) strncpy_from_user() and strnlen_user() in atomic state with setting USER_DS and disable pagefaults. Signed-off-by: Masami Hiramatsu --- arch/x86/include/asm/uaccess.h | 2 +- include/linux/uaccess.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h index 3125d129d3b6..3b7502a34114 100644 --- a/arch/x86/include/asm/uaccess.h +++ b/arch/x86/include/asm/uaccess.h @@ -715,7 +715,7 @@ extern struct movsl_mask { */ static __must_check inline bool user_access_begin(const void __user *ptr, size_t len) { - if (unlikely(!access_ok(ptr,len))) + if (unlikely(!user_access_ok(ptr, len))) return 0; __uaccess_begin_nospec(); return 1; diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h index bf762689658b..1afd9dfabe67 100644 --- a/include/linux/uaccess.h +++ b/include/linux/uaccess.h @@ -282,7 +282,7 @@ extern long strncpy_from_unsafe(char *dst, const void *unsafe_addr, long count); probe_kernel_read(&retval, addr, sizeof(retval)) #ifndef user_access_begin -#define user_access_begin(ptr,len) access_ok(ptr, len) +#define user_access_begin(ptr, len) user_access_ok(ptr, len) #define user_access_end() do { } while (0) #define unsafe_get_user(x, ptr, err) do { if (unlikely(__get_user(x, ptr))) goto err; } while (0) #define unsafe_put_user(x, ptr, err) do { if (unlikely(__put_user(x, ptr))) goto err; } while (0)