Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp34663pxy; Wed, 21 Apr 2021 17:39:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkUn1gJ7HEMRn8dbJeU2uV5POHvS/4ZBmJH1vf+bXuGuUDwl8SJoMOC5lVNmtfLKKM0Nlr X-Received: by 2002:a63:3812:: with SMTP id f18mr808107pga.380.1619051970371; Wed, 21 Apr 2021 17:39:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619051970; cv=none; d=google.com; s=arc-20160816; b=Omtwk84Rw1qpHf6esSwV2ipLUfwZIZzLSx5tdAYoi5sSQ4YAnRfo2mKtXJBhLj+e5y 6K1qATqFxrpT6xT2A3fTyDdoPEBsTLUeYK16WEVab6TQy79WO3k4NIq3WedPjEqx4Rkm Rky7pjjviHf1lb+zraRibtmus3nhj8PHYq74zAtdnIWUlVFWq4eqwy5KCRYDaNSwEOGR fUSslrveNQkmKVfeaYOfhCyz0arZrz96NIXvhbeETmVR3oBeOAwj40ljlgCGKPjb/6Ht MyS3/xRPjtR32RYOtxoW+MO5E6vmRnAg8E6sdasAgmQckxJPRNItKVOrl12Rtz1fPj4j c+Jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=jPCBSb8QU0tSbf7HOG1yMYqZ7+jZhNSqLC84SjS37qI=; b=jPIcB03BCPyMB+2JSR+DebPhud+ZpNylzTEMkV4Iu0TiDGUl7AuZHWljG9Nolq2th7 ueO+vlCvyvU2BhxN9/IMr12Ac9lfhZxGpiMBBTBPazhxPIczeU9yQM0vbXF5C2D4ALrr YT2A0IiFVa1iVQaPL73gxpjMUziZJNmOs+TPIzeRJu1lLYifa6Z6lNlMxFyiYYiN42gd A95U1ZrDGVBXq49vDyVHMjf40nDnAr47eoMJ/8kxTcUjeBBxEB7mdYZVoXAHqvTd1v3a ruvx8frgvuWN2onayys7QIil57ER85I6Rzgxh+hYD9ohtkoahFlKDfsXXIqPrTD6Jtky Zl8A== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k14si1496492pgg.55.2021.04.21.17.39.18; Wed, 21 Apr 2021 17:39:30 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244311AbhDUQU4 (ORCPT + 99 others); Wed, 21 Apr 2021 12:20:56 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:2897 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244252AbhDUQUi (ORCPT ); Wed, 21 Apr 2021 12:20:38 -0400 Received: from fraeml714-chm.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4FQQVf0PPBz6wjBw; Thu, 22 Apr 2021 00:09:46 +0800 (CST) Received: from roberto-ThinkStation-P620.huawei.com (10.204.62.217) by fraeml714-chm.china.huawei.com (10.206.15.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 21 Apr 2021 18:19:59 +0200 From: Roberto Sassu To: , , , CC: , , , , , Roberto Sassu , , Jeff Mahoney , Tetsuo Handa Subject: [PATCH v2 2/6] reiserfs: Add missing calls to reiserfs_security_free() Date: Wed, 21 Apr 2021 18:19:21 +0200 Message-ID: <20210421161925.968825-3-roberto.sassu@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210421161925.968825-1-roberto.sassu@huawei.com> References: <20210421161925.968825-1-roberto.sassu@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.204.62.217] X-ClientProxiedBy: lhreml754-chm.china.huawei.com (10.201.108.204) To fraeml714-chm.china.huawei.com (10.206.15.33) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 57fe60df6241 ("reiserfs: add atomic addition of selinux attributes during inode creation") defined reiserfs_security_free() to free the name and value of a security xattr allocated by the active LSM through security_old_inode_init_security(). However, this function is not called in the reiserfs code. Thus, this patch adds a call to reiserfs_security_free() whenever reiserfs_security_init() is called, and initializes value to NULL, to avoid to call kfree() on an uninitialized pointer. Fixes: 57fe60df6241 ("reiserfs: add atomic addition of selinux attributes during inode creation") Cc: stable@vger.kernel.org Cc: Jeff Mahoney Cc: Tetsuo Handa Reported-by: Mimi Zohar Reported-by: Tetsuo Handa Signed-off-by: Roberto Sassu --- fs/reiserfs/namei.c | 4 ++++ fs/reiserfs/xattr_security.c | 1 + 2 files changed, 5 insertions(+) diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c index e6eb05e2b2f1..6b5c51a77fae 100644 --- a/fs/reiserfs/namei.c +++ b/fs/reiserfs/namei.c @@ -695,6 +695,7 @@ static int reiserfs_create(struct user_namespace *mnt_userns, struct inode *dir, out_failed: reiserfs_write_unlock(dir->i_sb); + reiserfs_security_free(&security); return retval; } @@ -778,6 +779,7 @@ static int reiserfs_mknod(struct user_namespace *mnt_userns, struct inode *dir, out_failed: reiserfs_write_unlock(dir->i_sb); + reiserfs_security_free(&security); return retval; } @@ -877,6 +879,7 @@ static int reiserfs_mkdir(struct user_namespace *mnt_userns, struct inode *dir, retval = journal_end(&th); out_failed: reiserfs_write_unlock(dir->i_sb); + reiserfs_security_free(&security); return retval; } @@ -1193,6 +1196,7 @@ static int reiserfs_symlink(struct user_namespace *mnt_userns, retval = journal_end(&th); out_failed: reiserfs_write_unlock(parent_dir->i_sb); + reiserfs_security_free(&security); return retval; } diff --git a/fs/reiserfs/xattr_security.c b/fs/reiserfs/xattr_security.c index bb2a0062e0e5..b1ad93b60475 100644 --- a/fs/reiserfs/xattr_security.c +++ b/fs/reiserfs/xattr_security.c @@ -50,6 +50,7 @@ int reiserfs_security_init(struct inode *dir, struct inode *inode, int error; sec->name = NULL; + sec->value = NULL; /* Don't add selinux attributes on xattrs - they'll never get used */ if (IS_PRIVATE(dir)) -- 2.25.1