Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1424557ybg; Tue, 2 Jun 2020 09:32:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZwkN1zJPVAEv8uYbZixYkF6m6nE1fUkApWoLCvG/t9WF9AGQlhXU/Al4QY2pnZBQJGo6y X-Received: by 2002:a17:906:653:: with SMTP id t19mr23671883ejb.346.1591115577261; Tue, 02 Jun 2020 09:32:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591115577; cv=none; d=google.com; s=arc-20160816; b=hivoEHgxdRKpUEap+IxNXa5J5KIbiAkJGyj26xpe0hzTX7FpdZtB8QMb2F/t2ESjug xyWdvAqEx5cw8A2TwXrqxo0KGPFd5OXIDjsDlYHj0ESSfY7h1FbUEFOa4Ya3Pg2NVMJ5 HctTdKQU5jyUIlHdbSWIPaaYQnj2Osp2JwEYorLLmyMw6YGdEbdT57c0oi3ITNI+smyv pn88IbF//UxgiTraukFtdiAD1meg2pRvaemShFBhcS2qhwI2+rmX9R904pgilpfm8YU+ Io3Te6H3oYsmDQ3w8TAN8aPwzlV+VUfC02KWB7XfoFP9olRGZuBeIYvnmWHF+5APrZ6O ReZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=LjoI3ytLVrAcYOD29qydcrnsw4dE17QpiS4ijPMAnl8=; b=0rD0VPbCuCvNBHCjtC2GIQUID1hOg2Np8nYU49HjJj491yg7stSVhX3kv6Ml+VSx+k Af7/C7+wyECy3PKLyVpqfI/24Wp8u6/rn/54dXKrOX3M8vLdQB/eK/jpKmFoSzT9wFRF RO9R9MBHqFIk59mCUKzt7jj/h4EhHEf4yzgNPd6ZuWPym+hcxZrB/RnC7oc+Gzf/rtjg 8KrfdLmrsPdY0uJ4m7eOrk1L+RowaMxFRkCAYCqQX7pvKHUkvY4xe3wPq/96cQN8gEak FGd/Yy4Ebsry2sZHOreXpS90tFpkuosVbPJPXmaiNziezDw7O0juhoQbRDqbd8JXzbFS ZAQw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c2si1922397edq.502.2020.06.02.09.32.33; Tue, 02 Jun 2020 09:32:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727795AbgFBQ2U (ORCPT + 99 others); Tue, 2 Jun 2020 12:28:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727113AbgFBQ2U (ORCPT ); Tue, 2 Jun 2020 12:28:20 -0400 Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [IPv6:2002:c35c:fd02::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C35B9C05BD1E; Tue, 2 Jun 2020 09:28:19 -0700 (PDT) Received: from viro by ZenIV.linux.org.uk with local (Exim 4.93 #3 (Red Hat Linux)) id 1jg9lp-0021Yj-0I; Tue, 02 Jun 2020 16:28:09 +0000 Date: Tue, 2 Jun 2020 17:28:08 +0100 From: Al Viro To: butt3rflyh4ck Cc: namjae.jeon@samsung.com, sj1557.seo@samsung.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, syzkaller Subject: Re: memory leak in exfat_parse_param Message-ID: <20200602162808.GK23230@ZenIV.linux.org.uk> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 02, 2020 at 01:03:05PM +0800, butt3rflyh4ck wrote: > I report a bug (in linux-5.7.0-rc7) found by syzkaller. > > kernel config: https://github.com/butterflyhack/syzkaller-fuzz/blob/master/config-v5.7.0-rc7 > > and can reproduce. > > A param->string held by exfat_mount_options. Humm... First of all, exfat_free() ought to call exfat_free_upcase_table(). What's more, WTF bother with that kstrdup(), anyway? Just steal the string and be done with that... Signed-off-by: Al Viro --- diff --git a/fs/exfat/super.c b/fs/exfat/super.c index 0565d5539d57..01cd7ed1614d 100644 --- a/fs/exfat/super.c +++ b/fs/exfat/super.c @@ -259,9 +259,8 @@ static int exfat_parse_param(struct fs_context *fc, struct fs_parameter *param) break; case Opt_charset: exfat_free_iocharset(sbi); - opts->iocharset = kstrdup(param->string, GFP_KERNEL); - if (!opts->iocharset) - return -ENOMEM; + opts->iocharset = param->string; + param->string = NULL; break; case Opt_errors: opts->errors = result.uint_32; @@ -611,7 +610,10 @@ static int exfat_get_tree(struct fs_context *fc) static void exfat_free(struct fs_context *fc) { - kfree(fc->s_fs_info); + struct exfat_sb_info *sbi = fc->s_fs_info; + + exfat_free_iocharset(sbi); + kfree(sbi); } static const struct fs_context_operations exfat_context_ops = {