Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp4414955pxy; Tue, 27 Apr 2021 04:41:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxT1ZqksYd22tKRWDCQFmSzzMa9fplbg0rB+H2/7FOzX3x3w4HuKDFTyywGLCrZ/lpTYoX6 X-Received: by 2002:a05:6402:35cd:: with SMTP id z13mr3758651edc.21.1619523683276; Tue, 27 Apr 2021 04:41:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619523683; cv=none; d=google.com; s=arc-20160816; b=S+O3oniMFnSkeTS++rSIZDam/yOJ0IZoHOn62mrtS1M8DG6fVyVy+lW9/kXZAMTHiJ DGTaVM5EVMrUWP+jjWvDPPr8O1f3UrqJoa0YZcDW1Y3MuRTQMHe9eCEdQrt2clKcwpdz cBXZW84foafI37BYA8qD5zl7+Bv1/zaCqYkNkee8ZiwefvrSUQvROaf/W44RhLx1d3M9 0zGT1Ahtfdls77E2prpps4KveTRc71fWOOPrE9U43jwMQt/iWRB3aYO52G+IcwwtWMcS aPH/Y7w2d+2ODX0Fg5BSGN0c5xzEkYc3WvGmsYjpIMbJ2ig3qxP3T9dVUX45nkWlxl1O Q88g== 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=FdRNUDmaw6Uixhml5gC5Gu1hUUVcCrvrJf8DBXfbz8YN5RX1o3J87caBKpgO5aoBQh jRXWBmurm3nJAEHfijtyB2NjIAZ5nbSaUC7zLsUEdGjHtN8osiB/Ghq14SFIJBGf83fN 1CZ5Z4O/3f+VmJ1BRxrn7iRdKd5HUIMTdymVatOX8zNhAG/HNWtxeaD74CsCLlg9qLSp GnZ/TPK5so0g6eRtuH4l4n7eFTDkQMgfjPw5KsgjdrES8Ayv7SG2Uobxu+7+U1TJzodd XASTjIF4ZsjhriDXoYaBejpxoSVC1aiuWyxeemcWKX7xFmPlCaNotiVBo9Vkzcfo8IRr mv1g== 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 o10si1378363ejd.653.2021.04.27.04.41.00; Tue, 27 Apr 2021 04:41:23 -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 S237609AbhD0Lio (ORCPT + 99 others); Tue, 27 Apr 2021 07:38:44 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:2927 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230365AbhD0Lie (ORCPT ); Tue, 27 Apr 2021 07:38:34 -0400 Received: from fraeml714-chm.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4FV0165HZyz68996; Tue, 27 Apr 2021 19:30:02 +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; Tue, 27 Apr 2021 13:37:46 +0200 From: Roberto Sassu To: , , , CC: , , , , , , Roberto Sassu , , Jeff Mahoney , Tetsuo Handa Subject: [PATCH v3 1/6] reiserfs: Add missing calls to reiserfs_security_free() Date: Tue, 27 Apr 2021 13:37:27 +0200 Message-ID: <20210427113732.471066-2-roberto.sassu@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210427113732.471066-1-roberto.sassu@huawei.com> References: <20210427113732.471066-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: lhreml751-chm.china.huawei.com (10.201.108.201) 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