All of lore.kernel.org
 help / color / mirror / Atom feed
From: Seung-Woo Kim <sw0312.kim@samsung.com>
To: linux-modules@vger.kernel.org, lucas.de.marchi@gmail.com
Cc: gladkov.alexey@gmail.com, sw0312.kim@samsung.com, sungguk.na@samsung.com
Subject: [PATCH 2/2] libkmod: fix possible double free with wrong modules.builtin.modinfo
Date: Tue, 13 Apr 2021 20:23:15 +0900	[thread overview]
Message-ID: <20210413112315.18907-3-sw0312.kim@samsung.com> (raw)
In-Reply-To: <20210413112315.18907-1-sw0312.kim@samsung.com>

Fix double free for *modinfo with non '\0' terminated wrong
modules.builtin.modinfo, which is because EOF is minus value.

Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.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 a75a542f6942..a002cb5ee2c6 100644
--- a/libkmod/libkmod-builtin.c
+++ b/libkmod/libkmod-builtin.c
@@ -313,7 +313,7 @@ ssize_t kmod_builtin_get_modinfo(struct kmod_ctx *ctx, const char *modname,
 	while (offset < iter->next) {
 		offset = get_string(iter, pos, &line, &linesz);
 		if (offset <= 0) {
-			count = (offset) ? -errno : -EOF;
+			count = (offset) ? -errno : -EINVAL;
 			free(*modinfo);
 			goto fail;
 		}
-- 
2.19.2


  parent reply	other threads:[~2021-04-13 11:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20210413112018epcas1p15c2cb9693086133c145845030df145ef@epcas1p1.samsung.com>
2021-04-13 11:23 ` [PATCH 0/2] harden libkmod-builtin with wrong modules.builtin.modinfo Seung-Woo Kim
     [not found]   ` <CGME20210413112018epcas1p4e7e6b23060a83694867b07a1f1afc200@epcas1p4.samsung.com>
2021-04-13 11:23     ` [PATCH 1/2] libkmod: fix an overflow " Seung-Woo Kim
     [not found]   ` <CGME20210413112019epcas1p22c64b861d296333a64c348020c7ca20e@epcas1p2.samsung.com>
2021-04-13 11:23     ` Seung-Woo Kim [this message]
2021-04-17 20:58   ` [PATCH 0/2] harden libkmod-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=20210413112315.18907-3-sw0312.kim@samsung.com \
    --to=sw0312.kim@samsung.com \
    --cc=gladkov.alexey@gmail.com \
    --cc=linux-modules@vger.kernel.org \
    --cc=lucas.de.marchi@gmail.com \
    --cc=sungguk.na@samsung.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 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.