bin/184950: swapon aborts on gdbe device
Jilles Tjoelker
jilles at stack.nl
Fri Dec 20 23:20:01 UTC 2013
The following reply was made to PR bin/184950; it has been noted by GNATS.
From: Jilles Tjoelker <jilles at stack.nl>
To: bug-followup at FreeBSD.org, hsn at sendmail.cz
Cc:
Subject: Re: bin/184950: swapon aborts on gdbe device
Date: Sat, 21 Dec 2013 00:11:18 +0100
In PR bin/184950, you wrote:
> i have system configured for encrypted swap gdbe_swap_enabled=YES
> in fstab
> /dev/ada0s1b.bde none swap sw 0 0
> in backtrace:
> function swap_on_off() fails at 0x0804a756 which triggers stack
> checking routines from libc __stack_chk_fail() printing stack
> underflow
This bug is probably not that conspicuous because most people use geli
instead of gbde for disk encryption.
I looked at the code anyway, and I think the compiler and the buffer
overflow detector are perfectly right. On platforms where char is signed
(i.e. most, with the notable exception of arm), the sprintf() call in
swap_on_off_gbde() may write 9 instead of the expected 3 bytes. There is
a probability of 12.5% that the last 3 chars are all non-negative and
therefore no buffer overflow occurs.
The below patch should fix it. I have only tested that it compiles.
Index: sbin/swapon/swapon.c
===================================================================
--- sbin/swapon/swapon.c (revision 259508)
+++ sbin/swapon/swapon.c (working copy)
@@ -266,7 +266,8 @@ static const char *
swap_on_off_gbde(const char *name, int doingall)
{
const char *ret;
- char pass[64 * 2 + 1], bpass[64];
+ char pass[64 * 2 + 1];
+ unsigned char bpass[64];
char *dname;
int i, error;
--
Jilles Tjoelker
More information about the freebsd-bugs
mailing list