Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp253606rdb; Thu, 22 Feb 2024 02:38:21 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW3zqeZzd6fZAzrK1BZKN8hydZYq3w8O+eoc1G74WZc9m/iqqRxcSqxzvMP5mhRHhlMx2nXEXYdkvNdhwo8ovb0eoEXU6icmr32CnqGmg== X-Google-Smtp-Source: AGHT+IEoO5p9srhgN8cH4PIwXYjmuMbrO3R1AzsgKWRnTOnWjYH5FrqF22LWVNQbtbZ3WvYCEu7I X-Received: by 2002:a05:6402:12c7:b0:564:67d0:2381 with SMTP id k7-20020a05640212c700b0056467d02381mr6212094edx.40.1708598301316; Thu, 22 Feb 2024 02:38:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708598301; cv=pass; d=google.com; s=arc-20160816; b=D1159C0YRQy7dfwUbyfPARneNOs8+dI2owAedZCtBa4QvWuM4wAFQ+sSHiDBn68y4C HVu2bR54INhZRBgyhdPhGDO3h4FDEKN8bFZ+A1g3eE4oAQe/ZMm+em7ZsP8jBUS3/2gF 03iabKHG2VQEd1IQj7gO3k54aexGuxWQsR8CKsBgYA94p3R+cRJPq7wqWO1iEPONTiRd 6JEzbWy7XvAa2eAVcp8gXok9OUGuAs4LTKoIGBingOl8UrCVsVXo2avYkRDVtcoh2cBU JMbmnMixFyRLv8A92X0f++2k3fES6O9arqGuJLjy3Ew4uw2oJdcOKix87Kwyq1UqMIA5 SYDw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=kGzzuzIOGybsJ6z29Izl4lL3iuwQJ7Qr+zp2XdfdN58=; fh=HnVwUOaH0xFFSx+ca5OaOvEisbsLu3IvwevzkAotE6I=; b=IDwunptDH5hUBIe4R7h8VeeaFiwg0ZtZw9/zYr2Rm7ix30gr8C3t0y+5jR4sh+B1Ow 860G8p5dPLx/tGpS6GXw8s0BPc/+t04U2AQ3hnZEvCKachxVRh4PZOosGOTj3xMAr8md cInXlFnrhvXcXyAOj+S0tvGpzNVWBxBAhltykMe8zL/hg4Sd7hLN/NU0WlyWoeVXjeul ald5iqp8vTaWKpOWQiTysaNYDSfZ2Hz0fxz3jR5FxDYETslb8SsAscmAZr32hF3Te5Cp vRdGlozsoGi5iH2QExse8wwzeefWwoL+gRokoKdp1mCp15IDer4EIUbVOzVYd9kD59Mv 1efw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=nfschina.com); spf=pass (google.com: domain of linux-kernel+bounces-76322-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76322-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ee25-20020a056402291900b005651e309cd3si848590edb.641.2024.02.22.02.38.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 02:38:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76322-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=nfschina.com); spf=pass (google.com: domain of linux-kernel+bounces-76322-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76322-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 354271F27052 for ; Thu, 22 Feb 2024 10:26:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3E54B3B18C; Thu, 22 Feb 2024 10:26:17 +0000 (UTC) Received: from mail.nfschina.com (unknown [42.101.60.195]) by smtp.subspace.kernel.org (Postfix) with SMTP id BE4EC3C481; Thu, 22 Feb 2024 10:26:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=42.101.60.195 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708597576; cv=none; b=nSvWAv1Zb+rATCXVUqQ7ua2nb6eKoajNQ2nHbeUC8YBT7hzaPvqHvIEXnnHCtjJXUWlmOCbzAMVPXM83l4s33r57oikR4W8aNaE5s96S3E7ozOBfERRMd2uJR7ZVbvKZJ7LaP64ghGRhBUJYpbJAX+13Vj7mKn3nlAHj59+iUtk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708597576; c=relaxed/simple; bh=Rm+Yj2UuZ1027lvdPwgeiZQLrr3sHaHO5cTHO1idRqg=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=G6pfVhou3QvsIsUHgvSK9LgyiZD8E6u8zQI31mun11HkxUs78/jVYaqsbHnVMBF5umGRrLNNu2NajhtLrOWMPep1MNIcaPtOrMU0W4JGdOb+/ce4bBRNvxk8Ltl1mccPOxqxsCZmdq5upA8lMn94hv87dD4SJ+MRVm+lEjgprc8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nfschina.com; spf=pass smtp.mailfrom=nfschina.com; arc=none smtp.client-ip=42.101.60.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nfschina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nfschina.com Received: from localhost.localdomain (unknown [180.167.10.98]) by mail.nfschina.com (Maildata Gateway V2.8.8) with ESMTPSA id 093096032FDD7; Thu, 22 Feb 2024 18:25:52 +0800 (CST) X-MD-Sfrom: suhui@nfschina.com X-MD-SrcIP: 180.167.10.98 From: Su Hui To: hubcap@omnibond.com, martin@omnibond.com Cc: Su Hui , xiyuyang19@fudan.edu.cn, cymi20@fudan.edu.cn, tanxin.ctf@gmail.com, devel@lists.orangefs.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] orangefs: Fix possible NULL deference in orangefs_mount Date: Thu, 22 Feb 2024 18:25:49 +0800 Message-Id: <20240222102548.1426561-1-suhui@nfschina.com> X-Mailer: git-send-email 2.30.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit scripts/coccinelle/null/deref_null.cocci complains: fs/orangefs/super.c:584:18-25: ERROR: ORANGEFS_SB ( sb ) is NULL but dereferenced. When memory allocation for orangefs_sb_info_s fails, ORANGEFS_SB(sb) is NULL and ORANGEFS_SB(sb)->no_list will result in NULL deference. Add a judgement to fix this NULL deference problem. Fixes: ac2c63757f4f ("orangefs: Fix sb refcount leak when allocate sb info failed.") Signed-off-by: Su Hui --- fs/orangefs/super.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/orangefs/super.c b/fs/orangefs/super.c index 5254256a224d..c056c86e2482 100644 --- a/fs/orangefs/super.c +++ b/fs/orangefs/super.c @@ -581,7 +581,8 @@ struct dentry *orangefs_mount(struct file_system_type *fst, free_sb_and_op: /* Will call orangefs_kill_sb with sb not in list. */ - ORANGEFS_SB(sb)->no_list = 1; + if (ORANGEFS_SB(sb)) + ORANGEFS_SB(sb)->no_list = 1; /* ORANGEFS_VFS_OP_FS_UMOUNT is done by orangefs_kill_sb. */ deactivate_locked_super(sb); free_op: -- 2.30.2