Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp888439yba; Thu, 18 Apr 2019 11:14:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqyBDgcbQ4rFujR3Gm1q1pfs6NCM3u5NSG0kMOsN/AbhCsl+a34y4XZYHHEmqlp4oIgZCG2Z X-Received: by 2002:a17:902:ea02:: with SMTP id cu2mr2304239plb.146.1555611289189; Thu, 18 Apr 2019 11:14:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555611289; cv=none; d=google.com; s=arc-20160816; b=v9D+G31J5q6noBrsGH8BAWEpvPP3XMLdYp3soOrbSblQgv/mXizCUmVHj1W+n8wAD/ OEPMdmtxufsS3JPpn6pDeAfl4bsKTcKwKugPrY7zJRsf9puBFOWKdcoj+lNyaFEvoYwM lYSAc1SiZw+lOhUBHmgs24wpOJlmBhzaqmBLRStDaT4dvNqc7XgErxWzDfrs+1ctFVXS Bf6m6bt/hFgKBWf8xqRyd54qOr9y9XA+QSZ545vKONtg62T7gqWya50qVMLsfzUOtHmO uf3Y4HFP+5/09LT4qq51XQsHKr2VvV8CuT+Wt8vtY88DV6O85uwIDNMl30OeycZ2L8ei d3zQ== 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=qQSOaZ5ZCfTe8W+tTYzDZui/lVqF6QvUX+DJKwnpQ+M=; b=RWhikjbiKIepkVysC4gI9JxtRsTcut+uQ13XALtULitlogJFMBJlveWEOPizDL5Gy5 ZNeBi31t9rdBdmNc9Tf5+Uodbx1SxNvduMO6Sw7qBuYa2KrtZOyNvy6H2flA48yIoGXt 1O8pyb+NlJ9wiFpGioi8/vnkpRIy/KzGt8gkfW8b+XnPJ/uHXn6XRMrIDGn4ZU2tYFK/ FWckfJp+GkERQrmDIriPHMtQTLgwbUDlCyMRHP4pScO3rEPLAEldPf1v3MlwtrHCMUDB v5jbfsMGILVugV3E/dtzuUVxTluLmWwO3F2acKxIEGRMsucckRdVLGlC44sCNX3l0KN2 1RzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=b72Waq6Y; 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 e14si2842259pfn.203.2019.04.18.11.14.34; Thu, 18 Apr 2019 11:14:49 -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; dkim=pass header.i=@kernel.org header.s=default header.b=b72Waq6Y; 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 S2391848AbfDRSNF (ORCPT + 99 others); Thu, 18 Apr 2019 14:13:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:45674 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390416AbfDRSNC (ORCPT ); Thu, 18 Apr 2019 14:13:02 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 D232F214DA; Thu, 18 Apr 2019 18:13:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555611181; bh=5baeiWPity8RZOHQWtYXZdv2SBsImonly71ywxIiovA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b72Waq6Yw6+EZMrnKTEHNECggc80sjodRmMTFQrt8aVianamOoKF+hT8JD1HuUFUL ILe2a+FpGlNROv3/NG6zNZMHdOs5T04FaDiGeavkIdgIeZp+mAktSK4RaYowJ7b/ta RzL6dz9b/gGtqssegEjMUcXRgQOuY3omkQbKm/Gk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiqun Li , Chao Yu , Jaegeuk Kim , Sasha Levin Subject: [PATCH 5.0 89/93] f2fs: fix to use kvfree instead of kzfree Date: Thu, 18 Apr 2019 19:58:07 +0200 Message-Id: <20190418160445.763852636@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418160436.781762249@linuxfoundation.org> References: <20190418160436.781762249@linuxfoundation.org> User-Agent: quilt/0.66 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 [ Upstream commit 2a6a7e722e7a78d774ce02b847c5b183a3ff2672 ] As Jiqun Li reported in bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=202747 System can panic due to using wrong allocate/free function pair in xattr interface: - use kvmalloc to allocate memory - use kzfree to free memory Let's fix to use kvfree instead of kzfree, BTW, we are safe to get rid of kzfree, since there is no such confidential data stored as xattr, we don't need to zero it before free memory. Fixes: 5222595d093e ("f2fs: use kvmalloc, if kmalloc is failed") Reported-by: Jiqun Li Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- fs/f2fs/xattr.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c index 73b92985198b..6b6fe6431a64 100644 --- a/fs/f2fs/xattr.c +++ b/fs/f2fs/xattr.c @@ -347,7 +347,7 @@ static int lookup_all_xattrs(struct inode *inode, struct page *ipage, *base_addr = txattr_addr; return 0; out: - kzfree(txattr_addr); + kvfree(txattr_addr); return err; } @@ -390,7 +390,7 @@ static int read_all_xattrs(struct inode *inode, struct page *ipage, *base_addr = txattr_addr; return 0; fail: - kzfree(txattr_addr); + kvfree(txattr_addr); return err; } @@ -517,7 +517,7 @@ int f2fs_getxattr(struct inode *inode, int index, const char *name, } error = size; out: - kzfree(base_addr); + kvfree(base_addr); return error; } @@ -563,7 +563,7 @@ ssize_t f2fs_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size) } error = buffer_size - rest; cleanup: - kzfree(base_addr); + kvfree(base_addr); return error; } @@ -694,7 +694,7 @@ static int __f2fs_setxattr(struct inode *inode, int index, if (!error && S_ISDIR(inode->i_mode)) set_sbi_flag(F2FS_I_SB(inode), SBI_NEED_CP); exit: - kzfree(base_addr); + kvfree(base_addr); return error; } -- 2.19.1