From: Yauheni Kaliuta <ykaliuta@redhat.com>
To: linux-modules@vger.kernel.org
Cc: lucas.de.marchi@gmail.com, Yauheni Kaliuta <ykaliuta@redhat.com>
Subject: [PATCH 2/2] libkmod-builtin: consider final NIL in name length check
Date: Tue, 8 Jun 2021 09:29:23 +0300 [thread overview]
Message-ID: <20210608062923.94017-2-ykaliuta@redhat.com> (raw)
In-Reply-To: <20210608062923.94017-1-ykaliuta@redhat.com>
There is potential buffer overrun in kmod_builtin_iter_get_modname()
for the name of length PATH_MAX. The required buffer size is
PATH_MAX, so `modname[len] = '\0'` with len == PATH_MAX will write
right beyond the buffer.
Check the length against PATH_MAX - 1.
Signed-off-by: Yauheni Kaliuta <ykaliuta@redhat.com>
---
libkmod/libkmod-builtin.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libkmod/libkmod-builtin.c b/libkmod/libkmod-builtin.c
index a002cb5ee2c6..3d4d77ab29b3 100644
--- a/libkmod/libkmod-builtin.c
+++ b/libkmod/libkmod-builtin.c
@@ -246,7 +246,7 @@ bool kmod_builtin_iter_get_modname(struct kmod_builtin_iter *iter,
len = dot - line;
- if (len >= PATH_MAX) {
+ if (len >= PATH_MAX - 1) {
sv_errno = ENAMETOOLONG;
goto fail;
}
--
2.31.1
next prev parent reply other threads:[~2021-06-08 6:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-08 6:28 [PATCH 0/2] Fix a couple of potential problem (static analysis) Yauheni Kaliuta
2021-06-08 6:29 ` [PATCH 1/2] libkmod-module: check "new_from_name" return value in get_builtin Yauheni Kaliuta
2021-06-08 6:29 ` Yauheni Kaliuta [this message]
2021-06-09 17:10 ` [PATCH 2/2] libkmod-builtin: consider final NIL in name length check Lucas De Marchi
2021-06-09 17:18 ` Lucas De Marchi
2021-06-22 6:31 ` Yauheni Kaliuta
2021-06-22 6:22 ` Yauheni Kaliuta
2021-06-09 17:22 ` [PATCH 1/2] libkmod-module: check "new_from_name" return value in get_builtin Lucas De Marchi
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=20210608062923.94017-2-ykaliuta@redhat.com \
--to=ykaliuta@redhat.com \
--cc=linux-modules@vger.kernel.org \
--cc=lucas.de.marchi@gmail.com \
/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).