]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
elf_note_prpsinfo: handle more failures from proc_getargv()
authorKonstantin Belousov <kib@FreeBSD.org>
Fri, 3 Jun 2022 08:21:23 +0000 (11:21 +0300)
committerMark Johnston <markj@FreeBSD.org>
Tue, 9 Aug 2022 19:57:10 +0000 (15:57 -0400)
commit0aa6d8576d9e7e4463323b82b7dac178f56237e0
tree91a5509e0c76dcbb2eb8e5c694d2538b4efb4fff
parent7f83d23ecfce15cc83f51aa9d1c4f95c24448ab9
elf_note_prpsinfo: handle more failures from proc_getargv()

Resulting sbuf_len() from proc_getargv() might return 0 if user mangled
ps_strings enough. Also, sbuf_len() API contract is to return -1 if the
buffer overflowed. The later should not occur because get_ps_strings()
checks for catenated length, but check for this subtle detail explicitly
as well to be more resilent.

The end result is that p_comm is used in this situations.

Approved by: so
Security: FreeBSD-SA-22:09.elf
Reported by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
Reviewed by: delphij, markj
admbugs: 988
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35391

(cherry picked from commit 00d17cf342cd9f4f8fd1dcd79c8caec359145532)
(cherry picked from commit 2170511d491b65a07dc4416ecda2fbb37349aa10)
sys/kern/imgact_elf.c