All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] Miscellaneous fixes
@ 2019-07-08 11:22 Andrew Murray
  2019-07-08 11:22 ` [PATCH 1/4] smdb.py: fix handling of capped ranges Andrew Murray
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Andrew Murray @ 2019-07-08 11:22 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: smatch

This series provides miscellaneous fixes and removes some unintended
debug.

Andrew Murray (4):
  smdb.py: fix handling of capped ranges
  smdb.py: fix param tracking now that we use $ instead of p
  user_data: Recognize uaccess for non-x86 architectures
  kchecker: remove debug

 check_get_user_overflow.c | 2 +-
 smatch_data/db/smdb.py    | 6 +++---
 smatch_kernel_user_data.c | 2 +-
 smatch_scripts/kchecker   | 1 -
 4 files changed, 5 insertions(+), 6 deletions(-)

-- 
2.21.0

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/4] smdb.py: fix handling of capped ranges
  2019-07-08 11:22 [PATCH 0/4] Miscellaneous fixes Andrew Murray
@ 2019-07-08 11:22 ` Andrew Murray
  2019-07-08 11:22 ` [PATCH 2/4] smdb.py: fix param tracking now that we use $ instead of p Andrew Murray
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Andrew Murray @ 2019-07-08 11:22 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: smatch

The get_next_str function of smdb.py does not understand ranges that
have flags in square brackets. This results in a range such as
"0,4096-18446744073709547520[c]" being interpreted as 0->0 and 4096->0.

Let's fix this by breaking when we reach an opening square bracket.

Signed-off-by: Andrew Murray <andrew.murray@arm.com>
---
 smatch_data/db/smdb.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/smatch_data/db/smdb.py b/smatch_data/db/smdb.py
index c0b310b13b1d..1e089b4804bd 100755
--- a/smatch_data/db/smdb.py
+++ b/smatch_data/db/smdb.py
@@ -267,7 +267,7 @@ def get_next_str(txt):
         if txt[0] == '-':
             parsed += 1
         for char in txt[parsed:]:
-            if char == '-':
+            if char == '-' or char == '[':
                 break
             parsed += 1
         val = txt[:parsed]
-- 
2.21.0

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/4] smdb.py: fix param tracking now that we use $ instead of p
  2019-07-08 11:22 [PATCH 0/4] Miscellaneous fixes Andrew Murray
  2019-07-08 11:22 ` [PATCH 1/4] smdb.py: fix handling of capped ranges Andrew Murray
@ 2019-07-08 11:22 ` Andrew Murray
  2019-07-08 11:22 ` [PATCH 3/4] user_data: Recognize uaccess for non-x86 architectures Andrew Murray
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Andrew Murray @ 2019-07-08 11:22 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: smatch

Since d8084fee2b7c the data source of a parameter is now stored with the
notation: $0 instead of p0 (where the $ or p indicates that the data source
of the parameter is from the callers function parameters, the value next to
it is the parameter number).

Let's update the smdb script to reflect this.

Fixes: d8084fee2b7c ("data_source: change how parameter data source information is recorded")
Signed-off-by: Andrew Murray <andrew.murray@arm.com>
---
 smatch_data/db/smdb.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/smatch_data/db/smdb.py b/smatch_data/db/smdb.py
index 1e089b4804bd..9025a95070b5 100755
--- a/smatch_data/db/smdb.py
+++ b/smatch_data/db/smdb.py
@@ -574,8 +574,8 @@ def trace_param_helper(func, param, indent = 0):
     sources = trace_callers(func, param)
     for path in sources:
 
-        if len(path[1]) and path[1][0] == 'p' and path[1][1] == ' ':
-            p = int(path[1][2:])
+        if len(path[1]) and path[1][0] == '$':
+            p = int(re.findall('\d+', path[1][1:])[0])
             trace_param_helper(path[0], p, indent + 2)
         elif len(path[0]) and path[0][0] == '%':
             print "  %s%s" %(" " * indent, path[1])
-- 
2.21.0

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/4] user_data: Recognize uaccess for non-x86 architectures
  2019-07-08 11:22 [PATCH 0/4] Miscellaneous fixes Andrew Murray
  2019-07-08 11:22 ` [PATCH 1/4] smdb.py: fix handling of capped ranges Andrew Murray
  2019-07-08 11:22 ` [PATCH 2/4] smdb.py: fix param tracking now that we use $ instead of p Andrew Murray
@ 2019-07-08 11:22 ` Andrew Murray
  2019-07-08 11:22 ` [PATCH 4/4] kchecker: remove debug Andrew Murray
  2019-07-17 10:18 ` [PATCH 0/4] Miscellaneous fixes Dan Carpenter
  4 siblings, 0 replies; 7+ messages in thread
From: Andrew Murray @ 2019-07-08 11:22 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: smatch

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 <andrew.murray@arm.com>
---
 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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/4] kchecker: remove debug
  2019-07-08 11:22 [PATCH 0/4] Miscellaneous fixes Andrew Murray
                   ` (2 preceding siblings ...)
  2019-07-08 11:22 ` [PATCH 3/4] user_data: Recognize uaccess for non-x86 architectures Andrew Murray
@ 2019-07-08 11:22 ` Andrew Murray
  2019-07-17 10:18 ` [PATCH 0/4] Miscellaneous fixes Dan Carpenter
  4 siblings, 0 replies; 7+ messages in thread
From: Andrew Murray @ 2019-07-08 11:22 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: smatch

Remove unnecessary debug from kchecker script when cross-building.

Signed-off-by: Andrew Murray <andrew.murray@arm.com>
---
 smatch_scripts/kchecker | 1 -
 1 file changed, 1 deletion(-)

diff --git a/smatch_scripts/kchecker b/smatch_scripts/kchecker
index 2ca9b0f00f49..229250b4da8b 100755
--- a/smatch_scripts/kchecker
+++ b/smatch_scripts/kchecker
@@ -71,7 +71,6 @@ if  echo $oname | grep -q .o$ ; then
 fi
 
 if [[ ! -z $ARCH ]]; then
-	echo "yes"
 	KERNEL_ARCH="ARCH=$ARCH"
 fi
 if [[ ! -z $CROSS_COMPILE ]] ; then
-- 
2.21.0

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/4] Miscellaneous fixes
  2019-07-08 11:22 [PATCH 0/4] Miscellaneous fixes Andrew Murray
                   ` (3 preceding siblings ...)
  2019-07-08 11:22 ` [PATCH 4/4] kchecker: remove debug Andrew Murray
@ 2019-07-17 10:18 ` Dan Carpenter
  2019-10-07 14:20   ` Andrew Murray
  4 siblings, 1 reply; 7+ messages in thread
From: Dan Carpenter @ 2019-07-17 10:18 UTC (permalink / raw)
  To: Andrew Murray; +Cc: smatch

I'm back home now.  I've applied this series.  Thanks!

I don't know if my phone emails made any sense at all.  Let me know if
you need anything else.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/4] Miscellaneous fixes
  2019-07-17 10:18 ` [PATCH 0/4] Miscellaneous fixes Dan Carpenter
@ 2019-10-07 14:20   ` Andrew Murray
  0 siblings, 0 replies; 7+ messages in thread
From: Andrew Murray @ 2019-10-07 14:20 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: smatch

On Wed, Jul 17, 2019 at 01:18:14PM +0300, Dan Carpenter wrote:
> I'm back home now.  I've applied this series.  Thanks!

Thanks for this.

> 
> I don't know if my phone emails made any sense at all.  Let me know if
> you need anything else.

They do, thanks for the responses, apologies for my slow reply.

I'll share my progress on the list shortly.

Thanks,

Andrew Murray

> 
> regards,
> dan carpenter
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-10-07 14:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-08 11:22 [PATCH 0/4] Miscellaneous fixes Andrew Murray
2019-07-08 11:22 ` [PATCH 1/4] smdb.py: fix handling of capped ranges Andrew Murray
2019-07-08 11:22 ` [PATCH 2/4] smdb.py: fix param tracking now that we use $ instead of p Andrew Murray
2019-07-08 11:22 ` [PATCH 3/4] user_data: Recognize uaccess for non-x86 architectures Andrew Murray
2019-07-08 11:22 ` [PATCH 4/4] kchecker: remove debug Andrew Murray
2019-07-17 10:18 ` [PATCH 0/4] Miscellaneous fixes Dan Carpenter
2019-10-07 14:20   ` Andrew Murray

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.