diff mbox

kbuild: replace unbounded sprintf call in modpost

Message ID 20131025131443.GA7759@www.outflux.net (mailing list archive)
State New, archived
Headers show

Commit Message

Kees Cook Oct. 25, 2013, 1:14 p.m. UTC
The modpost tool could overflow its stack buffer if someone was running
with an insane shell environment. Regardless, it's technically a bug,
so this fixes it to truncate the string instead of seg-faulting.

Found by Coverity.

Signed-off-by: Kees Cook <keescook@chromium.org>
---
 scripts/mod/sumversion.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Michal Marek Nov. 6, 2013, 9:30 p.m. UTC | #1
On Fri, Oct 25, 2013 at 06:14:43AM -0700, Kees Cook wrote:
> The modpost tool could overflow its stack buffer if someone was running
> with an insane shell environment. Regardless, it's technically a bug,
> so this fixes it to truncate the string instead of seg-faulting.
> 
> Found by Coverity.
> 
> Signed-off-by: Kees Cook <keescook@chromium.org>

Applied to kbuild.git#kbuild.

Michal
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
index 9dfcd6d988da..deb2994b04c4 100644
--- a/scripts/mod/sumversion.c
+++ b/scripts/mod/sumversion.c
@@ -416,7 +416,7 @@  void get_src_version(const char *modname, char sum[], unsigned sumlen)
 		basename = strrchr(modname, '/') + 1;
 	else
 		basename = modname;
-	sprintf(filelist, "%s/%.*s.mod", modverdir,
+	snprintf(filelist, sizeof(filelist), "%s/%.*s.mod", modverdir,
 		(int) strlen(basename) - 2, basename);
 
 	file = grab_file(filelist, &len);