Received: from eggs.gnu.org ([2001:4830:134:3::10]:46613) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YzNp3-00017P-SA for qemu-devel@nongnu.org; Mon, 01 Jun 2015 07:24:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YzNov-00027A-Og for qemu-devel@nongnu.org; Mon, 01 Jun 2015 07:24:01 -0400 From: Markus Armbruster References: <1432811743-2423-1-git-send-email-mjt@msgid.tls.msk.ru> <87bngzluvg.fsf@blackfin.pond.sub.org> <556C1B70.3060209@msgid.tls.msk.ru> Date: Mon, 01 Jun 2015 13:23:50 +0200 In-Reply-To: <556C1B70.3060209@msgid.tls.msk.ru> (Michael Tokarev's message of "Mon, 01 Jun 2015 11:44:32 +0300") Message-ID: <87382bekop.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH] slirp: use less predictable directory name in /tmp for smb config (CVE-2015-4037) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael Tokarev Cc: pmatouse@redhat.com, P J P , qemu-trivial@nongnu.org, Jan Kiszka , qemu-devel@nongnu.org, Miroslav Rezanina Michael Tokarev writes: > 01.06.2015 11:01, Markus Armbruster wrote: > [] >>> - snprintf(s->smb_dir, sizeof(s->smb_dir), "/tmp/qemu-smb.%ld-%d", >>> - (long)getpid(), instance++); >>> - if (mkdir(s->smb_dir, 0700) < 0) { >>> + strcpy(s->smb_dir, "/tmp/qemu-smb.XXXXXX"); >>> + if (!mkdtemp(s->smb_dir)) { >>> error_report("could not create samba server dir '%s'", s->smb_dir); >>> return -1; >>> } >> >> Uh, I have to suspend my R-by. This clobbers s->smb_dir[] when >> mkdtemp() fails. Is that safe? Explain why, and get my R-by back. > > At least this is not different from the original behavour. Fair enough, R-by unsuspended. > The only place where this variable is used is in the slirp_smb_cleanup() > function, which, if smb_dir[0] != 0, does rm -rf on it. > I think it will be better to add s->smb_dir[0] = 0 here before return. Makes sense. > On the other hand this isn't really that important given when we can > expect mkdtemp() to fail. Not sure I got this part. Not sure I need to :)