lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1608306316-32096-1-git-send-email-shradha.t@samsung.com>
Date:   Fri, 18 Dec 2020 21:15:16 +0530
From:   Shradha Todi <shradha.t@...sung.com>
To:     linux-kernel@...r.kernel.org, linux-pci@...r.kernel.org
Cc:     kishon@...com, lorenzo.pieralisi@....com, bhelgaas@...gle.com,
        pankaj.dubey@...sung.com, Shradha Todi <shradha.t@...sung.com>,
        Sriram Dash <sriram.dash@...sung.com>
Subject: [PATCH v2] PCI: endpoint: Fix NULL pointer dereference for
 ->get_features()

get_features ops of pci_epc_ops may return NULL, causing NULL pointer
dereference in pci_epf_test_bind function. Let us add a check for
pci_epc_feature pointer in pci_epf_test_bind before we access it to
avoid any such NULL pointer dereference and return -ENOTSUPP in case
pci_epc_feature is not found.

Reviewed-by: Pankaj Dubey <pankaj.dubey@...sung.com>
Signed-off-by: Sriram Dash <sriram.dash@...sung.com>
Signed-off-by: Shradha Todi <shradha.t@...sung.com>
---
v2:
 rebase on v1
 v1: https://lore.kernel.org/patchwork/patch/1208269/

 drivers/pci/endpoint/functions/pci-epf-test.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c
index 66723d5..f1842e6 100644
--- a/drivers/pci/endpoint/functions/pci-epf-test.c
+++ b/drivers/pci/endpoint/functions/pci-epf-test.c
@@ -835,13 +835,16 @@ static int pci_epf_test_bind(struct pci_epf *epf)
 		return -EINVAL;
 
 	epc_features = pci_epc_get_features(epc, epf->func_no);
-	if (epc_features) {
-		linkup_notifier = epc_features->linkup_notifier;
-		core_init_notifier = epc_features->core_init_notifier;
-		test_reg_bar = pci_epc_get_first_free_bar(epc_features);
-		pci_epf_configure_bar(epf, epc_features);
+	if (!epc_features) {
+		dev_err(&epf->dev, "epc_features not implemented\n");
+		return -EOPNOTSUPP;
 	}
 
+	linkup_notifier = epc_features->linkup_notifier;
+	core_init_notifier = epc_features->core_init_notifier;
+	test_reg_bar = pci_epc_get_first_free_bar(epc_features);
+	pci_epf_configure_bar(epf, epc_features);
+
 	epf_test->test_reg_bar = test_reg_bar;
 	epf_test->epc_features = epc_features;
 
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ