[PATCH 3/4] user_data: Recognize uaccess for non-x86 architectures

Andrew Murray <[email protected]>
Newsgroups org.kernel.vger.smatch
Message-ID <[email protected]>
We identify some user data by recognizing both use of the get_user
macro and assignment from __val_gu. However on most non-x86
architectures the get_user macro uses the variable __gu_val instead
of __val_gu.

Let's update handle_get_user to recognize that get_user may also
use __gu_val.

Signed-off-by: Andrew Murray <[email protected]>
---
 check_get_user_overflow.c | 2 +-
 smatch_kernel_user_data.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/check_get_user_overflow.c b/check_get_user_overflow.c
index 20ec952c885a..fed299ee2300 100644
--- a/check_get_user_overflow.c
+++ b/check_get_user_overflow.c
@@ -108,7 +108,7 @@ static void match_assign(struct expression *expr)
 		return;
 	}
 	name = expr_to_var(expr->right);
-	if (!name || strcmp(name, "__val_gu") != 0)
+	if (!name || (strcmp(name, "__val_gu") != 0 && strcmp(name, "__gu_val")))
 		goto free;
 	set_state_expr(my_max_id, expr->left, &user_data);
 	set_state_expr(my_min_id, expr->left, &user_data);
diff --git a/smatch_kernel_user_data.c b/smatch_kernel_user_data.c
index bc9298fd6312..7c5fb8d7d872 100644
--- a/smatch_kernel_user_data.c
+++ b/smatch_kernel_user_data.c
@@ -542,7 +542,7 @@ static int handle_get_user(struct expression *expr)
 		return 0;
 
 	name = expr_to_var(expr->right);
-	if (!name || strcmp(name, "__val_gu") != 0)
+	if (!name || (strcmp(name, "__val_gu") != 0 && strcmp(name, "__gu_val") != 0))
 		goto free;
 	set_state_expr(my_id, expr->left, alloc_estate_whole(get_type(expr->left)));
 	ret = 1;
-- 
2.21.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.