linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] samples/seccomp: fix error return code in handle_req()
@ 2021-05-08  4:01 Zhen Lei
  0 siblings, 0 replies; only message in thread
From: Zhen Lei @ 2021-05-08  4:01 UTC (permalink / raw)
  To: Kees Cook, linux-kernel; +Cc: Zhen Lei

Unlike branch "if (lseek(mem, req->data.args[0], SEEK_SET) < 0)" above,
'ret' is overwritten by the previous 'ret = read(...)' statement.
Therefore, 'ret' needs to be explicitly assigned to -1 here. Otherwise,
0 is incorrectly returned.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
 samples/seccomp/user-trap.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/samples/seccomp/user-trap.c b/samples/seccomp/user-trap.c
index 20291ec6489f..c1d4ca0284ba 100644
--- a/samples/seccomp/user-trap.c
+++ b/samples/seccomp/user-trap.c
@@ -164,6 +164,7 @@ static int handle_req(struct seccomp_notif *req,
 	}
 
 	if (lseek(mem, req->data.args[1], SEEK_SET) < 0) {
+		ret = -1;
 		perror("seek");
 		goto out;
 	}
-- 
2.25.1



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-05-08  4:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-08  4:01 [PATCH 1/1] samples/seccomp: fix error return code in handle_req() Zhen Lei

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).