From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF01713CA93; Thu, 12 Dec 2024 15:18:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734016684; cv=none; b=Vl0wQltDaHOGoQDE8pwREWn/sRe8E3KOexF+AaCxP3UJDz1WAM8Qo/iOPTdz+pfoMEthynU+dCdTcXXtQy9uoXY5ZqkOxiiUhekeWbjpUxmV/XnL0OLWD22gROSls5IQhSVtcQLT7k1JdGgbGs7GDxfJsOeZ4Y9WLIt802bp0og= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734016684; c=relaxed/simple; bh=12J0URwqVQCFlcZiZ8iLnm+eas1uRR56CFpiApRz9So=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g+T5ZSl8adaIXEJKAxLFnRr1Ks1XnaWBqfljCGhpT4DhnWAGIB31cZDir9MTxO1mT4RXgNd0iKDPykp1kS3wb+Rr7bz/R3/WfZqY/mvTgw3bbxEntzt1VJ1q53H9RcJeTHPdE0WJ6Rk/e2HMsd9hSnzIiPOD4NxPipycnS/G9fU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=d1H1rowN; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="d1H1rowN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1AC5C4CEDE; Thu, 12 Dec 2024 15:18:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1734016683; bh=12J0URwqVQCFlcZiZ8iLnm+eas1uRR56CFpiApRz9So=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d1H1rowNhv/65DFftmL0SwjejmAq5aYZ6f5EWUJ1DtoxEplAZ9V/g2NuUcccQP44q BZS3TzWPL0sLQl8KSbxdPoQjFky1nOVkdtIkIleSnVu6BzchB58t1Rbe/xRb+Wnjtt R0Zu9uwaXpqCSt5c30o3H07iM0qIW/7BWUYzLcjs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Alexander Aring , David Teigland , Sasha Levin Subject: [PATCH 6.12 269/466] dlm: fix possible lkb_resource null dereference Date: Thu, 12 Dec 2024 15:57:18 +0100 Message-ID: <20241212144317.416194551@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241212144306.641051666@linuxfoundation.org> References: <20241212144306.641051666@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alexander Aring [ Upstream commit b98333c67daf887c724cd692e88e2db9418c0861 ] This patch fixes a possible null pointer dereference when this function is called from request_lock() as lkb->lkb_resource is not assigned yet, only after validate_lock_args() by calling attach_lkb(). Another issue is that a resource name could be a non printable bytearray and we cannot assume to be ASCII coded. The log functionality is probably never being hit when DLM is used in normal way and no debug logging is enabled. The null pointer dereference can only occur on a new created lkb that does not have the resource assigned yet, it probably never hits the null pointer dereference but we should be sure that other changes might not change this behaviour and we actually can hit the mentioned null pointer dereference. In this patch we just drop the printout of the resource name, the lkb id is enough to make a possible connection to a resource name if this exists. Signed-off-by: Alexander Aring Signed-off-by: David Teigland Signed-off-by: Sasha Levin --- fs/dlm/lock.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c index 865dc70a9dfc4..dddedaef5e93d 100644 --- a/fs/dlm/lock.c +++ b/fs/dlm/lock.c @@ -2861,16 +2861,14 @@ static int validate_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb, case -EINVAL: /* annoy the user because dlm usage is wrong */ WARN_ON(1); - log_error(ls, "%s %d %x %x %x %d %d %s", __func__, + log_error(ls, "%s %d %x %x %x %d %d", __func__, rv, lkb->lkb_id, dlm_iflags_val(lkb), args->flags, - lkb->lkb_status, lkb->lkb_wait_type, - lkb->lkb_resource->res_name); + lkb->lkb_status, lkb->lkb_wait_type); break; default: - log_debug(ls, "%s %d %x %x %x %d %d %s", __func__, + log_debug(ls, "%s %d %x %x %x %d %d", __func__, rv, lkb->lkb_id, dlm_iflags_val(lkb), args->flags, - lkb->lkb_status, lkb->lkb_wait_type, - lkb->lkb_resource->res_name); + lkb->lkb_status, lkb->lkb_wait_type); break; } -- 2.43.0