Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2555480imu; Thu, 29 Nov 2018 06:50:41 -0800 (PST) X-Google-Smtp-Source: AFSGD/UU3NuwTpU72C5rAna4QK2+tTeuS2ZO8+PcLpPg8yv7n1J6dZd8MVoyLtPqzfTX94ZWZIuq X-Received: by 2002:a17:902:7402:: with SMTP id g2mr1722090pll.198.1543503041542; Thu, 29 Nov 2018 06:50:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543503041; cv=none; d=google.com; s=arc-20160816; b=t7auoeMI3cAjjSAiPhFGNlUH1D7ekkURwgERPOHWHa/Q7Zjy2GhKiWD+hMCWJhraEw Btag/RzqkcyhnIBMyCni0M3pQgszQmZEzLs/e0YhL1zMfmUUdcKNMfc+vu5mafrpZMuR jxcT6ACF4hDOx/EpI1p5OXXnuqupFga8bKicfQT+cd0iKPXT7f3GbEQmPjs2cY5ynvsF 6fwq5M0DZDjWu+LXbHui7U7sgfcoa4s4y0u0KT3wo/baPrmlGJauBhvbwr8eDTeuP6Ob JDgM3CwMW171EAruhu6aQqzjqcdHlzlotcXHR7sRT8pn7BAw2ywMoT+jMuyoIhKvD9OU PIyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rvNtDnfRmVoQFmj0cvRPYGsjSrImUej0eZEMRFex634=; b=z7tHoO6zkX9QWHl6EY8Lw+9ybyoDqBHgwUwNWCoUjZmzIv8fSAQEgDvD8DMl54iUrz eGbFfJQ8Poi/VDI7zYm83X2R4aMw5wJyw2rJ6pvYZlq1Y2YuUwnkEMRqqkjCoq84ZB+0 kSNr1ZrQzmJkqT1kLk2/UdBu1/gQ5Hg4Vusy8rYS4uHQw5UPga2LRIT2Wv+V+yXTql2y 8IG9XkDDcWyPwci9r8TWmLuBx2X6QYUFjltakTKb8MDEl3LEuXtwCUc6adUFLsE6Iw6e OJLfllKZNH/EABgC/4e/emTQjCHE0VoYfOcBwestu5jw0EiSa4EFdZjWa9D4jSPHvUi+ 1Nkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vEOR+bEQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l3si2292361pld.229.2018.11.29.06.50.25; Thu, 29 Nov 2018 06:50:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vEOR+bEQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732798AbeK3Ba0 (ORCPT + 99 others); Thu, 29 Nov 2018 20:30:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:57466 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732789AbeK3Ba0 (ORCPT ); Thu, 29 Nov 2018 20:30:26 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C38952133F; Thu, 29 Nov 2018 14:24:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543501494; bh=X5pEFkr/FeCSE0h4MpHittvlsc0CJ0MO0c1lPj1n5S0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vEOR+bEQGepybZYj+VnSScGCAMUzlYZ6WZNK7oQJ7Cb9V2UcFiM11P/1IZXM6QU3T Wh1gYF4WEJHrSnGKJSB0o+izWvN73C2DDzRZHMBI4horYgVqz8mTroXOdvpwkKBTaG CZBdq6fbiaHwIQMABGaO3SK4JRqOo6sLObqln9H4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dominique Martinet , syzbot+d4252148d198410b864f@syzkaller.appspotmail.com Subject: [PATCH 4.14 021/100] v9fs_dir_readdir: fix double-free on p9stat_read error Date: Thu, 29 Nov 2018 15:11:51 +0100 Message-Id: <20181129140100.598768296@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181129140058.768942700@linuxfoundation.org> References: <20181129140058.768942700@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dominique Martinet commit 81c99089bce693b94b775b6eb888115d2d540086 upstream. p9stat_read will call p9stat_free on error, we should only free the struct content on success. There also is no need to "p9stat_init" st as the read function will zero the whole struct for us anyway, so clean up the code a bit while we are here. Link: http://lkml.kernel.org/r/1535410108-20650-1-git-send-email-asmadeus@codewreck.org Signed-off-by: Dominique Martinet Reported-by: syzbot+d4252148d198410b864f@syzkaller.appspotmail.com Signed-off-by: Greg Kroah-Hartman --- fs/9p/vfs_dir.c | 11 ----------- 1 file changed, 11 deletions(-) --- a/fs/9p/vfs_dir.c +++ b/fs/9p/vfs_dir.c @@ -76,15 +76,6 @@ static inline int dt_type(struct p9_wsta return rettype; } -static void p9stat_init(struct p9_wstat *stbuf) -{ - stbuf->name = NULL; - stbuf->uid = NULL; - stbuf->gid = NULL; - stbuf->muid = NULL; - stbuf->extension = NULL; -} - /** * v9fs_alloc_rdir_buf - Allocate buffer used for read and readdir * @filp: opened file structure @@ -145,12 +136,10 @@ static int v9fs_dir_readdir(struct file rdir->tail = n; } while (rdir->head < rdir->tail) { - p9stat_init(&st); err = p9stat_read(fid->clnt, rdir->buf + rdir->head, rdir->tail - rdir->head, &st); if (err) { p9_debug(P9_DEBUG_VFS, "returned %d\n", err); - p9stat_free(&st); return -EIO; } reclen = st.size+2;