From: Zhen Lei <thunder.leizhen@huawei.com>
To: Kees Cook <keescook@chromium.org>,
linux-kernel <linux-kernel@vger.kernel.org>
Cc: Zhen Lei <thunder.leizhen@huawei.com>
Subject: [PATCH 1/1] samples/seccomp: fix error return code in handle_req()
Date: Sat, 8 May 2021 12:01:01 +0800 [thread overview]
Message-ID: <20210508040101.2474-1-thunder.leizhen@huawei.com> (raw)
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
reply other threads:[~2021-05-08 4:01 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20210508040101.2474-1-thunder.leizhen@huawei.com \
--to=thunder.leizhen@huawei.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
/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).