Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp6420585imm; Mon, 27 Aug 2018 15:50:32 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZ3VGY9gRMklV7thV7A+Q1PU21VtSnUPYkUMYJwBOFE+y5elRtY3Mz++esJc/3Ef9cURPgM X-Received: by 2002:a63:fb57:: with SMTP id w23-v6mr13950004pgj.441.1535410231980; Mon, 27 Aug 2018 15:50:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535410231; cv=none; d=google.com; s=arc-20160816; b=kWI6zA4oeMu16mOh+n3kmiytLGNEZV6gxSpkMzsgOeYI6cEcIgyjdEWzvKur1Iumv/ fsXxWrTfUUaOcdbwExanqxPKVsWDbUTXycNQ8fmgIKvqqq0oDfZER4ZBCoDZhQk48558 Y9SYBqg2+7qbhdDYkzDfZaKBnWMKa+bZlNrC9jfZe1Y1RmNcEJksvDVLxZ8TWYKdovSn UpZUhDyOTt0yZrZFCISC4dpB/OvfDsiuUwh6ygmaEyuDypDHCMyIgqidP3lOgIntV832 o/7VMsyqTz2S8Tcftjo5ICcDnz00DzELMYEZOMMBfbnRn7T3t28BwYVfDovO7eTsOv7v mP/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=a6oeVFhTRqoziCG1Ud6f6g9a/QWY+1uBtMK6VKQqTLQ=; b=OvItmdI9NWWJHpNE+c6JMRP9RYkODD6NhWooSR32ryAPjrJ9MtSdIt7FNWEzmVpVvi fkrN+IdbFi2ktob8nHdZ5PazA64k3HQdVuBgGJ9p8MtpQLZD9HTry+LFZEuj2Tfmmifo YSSma6yc1Nd3OQy0oP2G6hzwU25n9yAnB42vY0Hi3wLGOG8XZItH0wuePUawZk0Pjcv5 hIt3hhs1FBmHv5/re//HC20VodDG4nwULRFm6McaH35Jn1xKV+p0BSVs+lyG0j/fYvnV RhF7bUFQDApqYNmj1J2DSKPsFEpK2pe56l1fNopHMG3DeVtRukTnkUfmuy55iTWDRL0a 1S4A== ARC-Authentication-Results: i=1; mx.google.com; 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 m61-v6si458947plb.296.2018.08.27.15.50.17; Mon, 27 Aug 2018 15:50:31 -0700 (PDT) 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; 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 S1727312AbeH1ChU (ORCPT + 99 others); Mon, 27 Aug 2018 22:37:20 -0400 Received: from nautica.notk.org ([91.121.71.147]:54348 "EHLO nautica.notk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726994AbeH1ChU (ORCPT ); Mon, 27 Aug 2018 22:37:20 -0400 Received: by nautica.notk.org (Postfix, from userid 1001) id CFB79C009; Tue, 28 Aug 2018 00:48:39 +0200 (CEST) From: Dominique Martinet To: v9fs-developer@lists.sourceforge.net Cc: Dominique Martinet , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com, Eric Van Hensbergen , Latchesar Ionkov Subject: [PATCH 1/2] v9fs_dir_readdir: fix double-free on p9stat_read error Date: Tue, 28 Aug 2018 00:48:27 +0200 Message-Id: <1535410108-20650-1-git-send-email-asmadeus@codewreck.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <000000000000af648b057456e234@google.com> References: <000000000000af648b057456e234@google.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dominique Martinet 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. Signed-off-by: Dominique Martinet Reported-by: syzbot+d4252148d198410b864f@syzkaller.appspotmail.com Cc: Eric Van Hensbergen Cc: Latchesar Ionkov --- fs/9p/vfs_dir.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/fs/9p/vfs_dir.c b/fs/9p/vfs_dir.c index b0405d6aac85..48db9a9f13f9 100644 --- a/fs/9p/vfs_dir.c +++ b/fs/9p/vfs_dir.c @@ -76,15 +76,6 @@ static inline int dt_type(struct p9_wstat *mistat) 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 *file, struct dir_context *ctx) 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; -- 2.17.1