public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next] libbpf: Fix theoretical u32 underflow in find_cd() function
@ 2023-03-07 21:55 Daniel Müller
  2023-03-07 23:40 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Müller @ 2023-03-07 21:55 UTC (permalink / raw)
  To: bpf, ast, andrii, daniel, kafai, kernel-team

Coverity reported a potential underflow of the offset variable used in
the find_cd() function. Switch to using a signed 64 bit integer for the
representation of offset to make sure we can never underflow.

Fixes: 1eebcb60633f ("libbpf: Implement basic zip archive parsing support")
Signed-off-by: Daniel Müller <deso@posteo.net>
---
 tools/lib/bpf/zip.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/lib/bpf/zip.c b/tools/lib/bpf/zip.c
index 8458c2..f561aa 100644
--- a/tools/lib/bpf/zip.c
+++ b/tools/lib/bpf/zip.c
@@ -168,9 +168,8 @@ static int try_parse_end_of_cd(struct zip_archive *archive, __u32 offset)
 
 static int find_cd(struct zip_archive *archive)
 {
+	int64_t limit, offset;
 	int rc = -EINVAL;
-	int64_t limit;
-	__u32 offset;
 
 	if (archive->size <= sizeof(struct end_of_cd_record))
 		return -EINVAL;
-- 
2.34.1


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

* Re: [PATCH bpf-next] libbpf: Fix theoretical u32 underflow in find_cd() function
  2023-03-07 21:55 [PATCH bpf-next] libbpf: Fix theoretical u32 underflow in find_cd() function Daniel Müller
@ 2023-03-07 23:40 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-03-07 23:40 UTC (permalink / raw)
  To: =?utf-8?q?Daniel_M=C3=BCller_=3Cdeso=40posteo=2Enet=3E?=
  Cc: bpf, ast, andrii, daniel, kafai, kernel-team

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:

On Tue,  7 Mar 2023 21:55:04 +0000 you wrote:
> Coverity reported a potential underflow of the offset variable used in
> the find_cd() function. Switch to using a signed 64 bit integer for the
> representation of offset to make sure we can never underflow.
> 
> Fixes: 1eebcb60633f ("libbpf: Implement basic zip archive parsing support")
> Signed-off-by: Daniel Müller <deso@posteo.net>
> 
> [...]

Here is the summary with links:
  - [bpf-next] libbpf: Fix theoretical u32 underflow in find_cd() function
    https://git.kernel.org/bpf/bpf-next/c/3ecde2182adb

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2023-03-07 23:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-07 21:55 [PATCH bpf-next] libbpf: Fix theoretical u32 underflow in find_cd() function Daniel Müller
2023-03-07 23:40 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox