* [PATCH v2] IB/rxe: don't crash, if allocation of crc algorithm failed
@ 2017-10-31 10:16 Thomas Bogendoerfer
2017-10-31 10:52 ` Leon Romanovsky
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Thomas Bogendoerfer @ 2017-10-31 10:16 UTC (permalink / raw)
To: Moni Shoua, Doug Ledford, linux-rdma, linux-kernel
Following crash happens, if crc algorithm couldn't be allocated:
[ 1087.989072] rdma_rxe: loaded
[ 1097.855397] PCLMULQDQ-NI instructions are not detected.
[ 1097.901220] rdma_rxe: failed to allocate crc algorithmi err:-2
[ 1097.901248] BUG: unable to handle kernel
[ 1097.901249] NULL pointer dereference
[ 1097.901250] at 0000000000000046
[...]
Reason is that rxe->tfm is assigned the error return, which will then
be used for crypto_free_shash() in rxe_cleanup. Fix by using a
temporary variable and assigning it rxe->tfm after allocation succeeded.
Fixes: cee2688e3cd6 ("IB/rxe: Offload CRC calculation when possible")
Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
---
drivers/infiniband/sw/rxe/rxe_verbs.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c
index ff77f4f66970..d03002b9d84d 100644
--- a/drivers/infiniband/sw/rxe/rxe_verbs.c
+++ b/drivers/infiniband/sw/rxe/rxe_verbs.c
@@ -1192,6 +1192,7 @@ int rxe_register_device(struct rxe_dev *rxe)
int err;
int i;
struct ib_device *dev = &rxe->ib_dev;
+ struct crypto_shash *tfm;
strlcpy(dev->name, "rxe%d", IB_DEVICE_NAME_MAX);
strlcpy(dev->node_desc, "rxe", sizeof(dev->node_desc));
@@ -1289,12 +1290,13 @@ int rxe_register_device(struct rxe_dev *rxe)
dev->get_hw_stats = rxe_ib_get_hw_stats;
dev->alloc_hw_stats = rxe_ib_alloc_hw_stats;
- rxe->tfm = crypto_alloc_shash("crc32", 0, 0);
- if (IS_ERR(rxe->tfm)) {
+ tfm = crypto_alloc_shash("crc32", 0, 0);
+ if (IS_ERR(tfm)) {
pr_err("failed to allocate crc algorithm err:%ld\n",
- PTR_ERR(rxe->tfm));
- return PTR_ERR(rxe->tfm);
+ PTR_ERR(tfm));
+ return PTR_ERR(tfm);
}
+ rxe->tfm = tfm;
err = ib_register_device(dev, NULL);
if (err) {
--
2.12.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] IB/rxe: don't crash, if allocation of crc algorithm failed
2017-10-31 10:16 [PATCH v2] IB/rxe: don't crash, if allocation of crc algorithm failed Thomas Bogendoerfer
@ 2017-10-31 10:52 ` Leon Romanovsky
2017-10-31 11:08 ` Moni Shoua
2017-11-10 18:44 ` Doug Ledford
2 siblings, 0 replies; 4+ messages in thread
From: Leon Romanovsky @ 2017-10-31 10:52 UTC (permalink / raw)
To: Thomas Bogendoerfer; +Cc: Moni Shoua, Doug Ledford, linux-rdma, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1980 bytes --]
On Tue, Oct 31, 2017 at 11:16:46AM +0100, Thomas Bogendoerfer wrote:
> Following crash happens, if crc algorithm couldn't be allocated:
>
> [ 1087.989072] rdma_rxe: loaded
> [ 1097.855397] PCLMULQDQ-NI instructions are not detected.
> [ 1097.901220] rdma_rxe: failed to allocate crc algorithmi err:-2
> [ 1097.901248] BUG: unable to handle kernel
> [ 1097.901249] NULL pointer dereference
> [ 1097.901250] at 0000000000000046
> [...]
>
> Reason is that rxe->tfm is assigned the error return, which will then
> be used for crypto_free_shash() in rxe_cleanup. Fix by using a
> temporary variable and assigning it rxe->tfm after allocation succeeded.
>
> Fixes: cee2688e3cd6 ("IB/rxe: Offload CRC calculation when possible")
> Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
> ---
> drivers/infiniband/sw/rxe/rxe_verbs.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c
> index ff77f4f66970..d03002b9d84d 100644
> --- a/drivers/infiniband/sw/rxe/rxe_verbs.c
> +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c
> @@ -1192,6 +1192,7 @@ int rxe_register_device(struct rxe_dev *rxe)
> int err;
> int i;
> struct ib_device *dev = &rxe->ib_dev;
> + struct crypto_shash *tfm;
>
> strlcpy(dev->name, "rxe%d", IB_DEVICE_NAME_MAX);
> strlcpy(dev->node_desc, "rxe", sizeof(dev->node_desc));
> @@ -1289,12 +1290,13 @@ int rxe_register_device(struct rxe_dev *rxe)
> dev->get_hw_stats = rxe_ib_get_hw_stats;
> dev->alloc_hw_stats = rxe_ib_alloc_hw_stats;
>
> - rxe->tfm = crypto_alloc_shash("crc32", 0, 0);
> - if (IS_ERR(rxe->tfm)) {
> + tfm = crypto_alloc_shash("crc32", 0, 0);
> + if (IS_ERR(tfm)) {
> pr_err("failed to allocate crc algorithm err:%ld\n",
> - PTR_ERR(rxe->tfm));
> - return PTR_ERR(rxe->tfm);
> + PTR_ERR(tfm));
> + return PTR_ERR(tfm);
> }
> + rxe->tfm = tfm;
Thanks,
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] IB/rxe: don't crash, if allocation of crc algorithm failed
2017-10-31 10:16 [PATCH v2] IB/rxe: don't crash, if allocation of crc algorithm failed Thomas Bogendoerfer
2017-10-31 10:52 ` Leon Romanovsky
@ 2017-10-31 11:08 ` Moni Shoua
2017-11-10 18:44 ` Doug Ledford
2 siblings, 0 replies; 4+ messages in thread
From: Moni Shoua @ 2017-10-31 11:08 UTC (permalink / raw)
To: Thomas Bogendoerfer; +Cc: Doug Ledford, linux-rdma, Linux Kernel Mailinglist
On Tue, Oct 31, 2017 at 12:16 PM, Thomas Bogendoerfer
<tbogendoerfer@suse.de> wrote:
> Following crash happens, if crc algorithm couldn't be allocated:
>
> [ 1087.989072] rdma_rxe: loaded
> [ 1097.855397] PCLMULQDQ-NI instructions are not detected.
> [ 1097.901220] rdma_rxe: failed to allocate crc algorithmi err:-2
> [ 1097.901248] BUG: unable to handle kernel
> [ 1097.901249] NULL pointer dereference
> [ 1097.901250] at 0000000000000046
> [...]
>
> Reason is that rxe->tfm is assigned the error return, which will then
> be used for crypto_free_shash() in rxe_cleanup. Fix by using a
> temporary variable and assigning it rxe->tfm after allocation succeeded.
>
> Fixes: cee2688e3cd6 ("IB/rxe: Offload CRC calculation when possible")
> Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
> ---
> drivers/infiniband/sw/rxe/rxe_verbs.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c
> index ff77f4f66970..d03002b9d84d 100644
> --- a/drivers/infiniband/sw/rxe/rxe_verbs.c
> +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c
> @@ -1192,6 +1192,7 @@ int rxe_register_device(struct rxe_dev *rxe)
> int err;
> int i;
> struct ib_device *dev = &rxe->ib_dev;
> + struct crypto_shash *tfm;
>
> strlcpy(dev->name, "rxe%d", IB_DEVICE_NAME_MAX);
> strlcpy(dev->node_desc, "rxe", sizeof(dev->node_desc));
> @@ -1289,12 +1290,13 @@ int rxe_register_device(struct rxe_dev *rxe)
> dev->get_hw_stats = rxe_ib_get_hw_stats;
> dev->alloc_hw_stats = rxe_ib_alloc_hw_stats;
>
> - rxe->tfm = crypto_alloc_shash("crc32", 0, 0);
> - if (IS_ERR(rxe->tfm)) {
> + tfm = crypto_alloc_shash("crc32", 0, 0);
> + if (IS_ERR(tfm)) {
> pr_err("failed to allocate crc algorithm err:%ld\n",
> - PTR_ERR(rxe->tfm));
> - return PTR_ERR(rxe->tfm);
> + PTR_ERR(tfm));
> + return PTR_ERR(tfm);
> }
> + rxe->tfm = tfm;
>
> err = ib_register_device(dev, NULL);
> if (err) {
> --
> 2.12.3
>
> --
Thanks
Acked-by: Moni Shoua <monis@mellanox.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] IB/rxe: don't crash, if allocation of crc algorithm failed
2017-10-31 10:16 [PATCH v2] IB/rxe: don't crash, if allocation of crc algorithm failed Thomas Bogendoerfer
2017-10-31 10:52 ` Leon Romanovsky
2017-10-31 11:08 ` Moni Shoua
@ 2017-11-10 18:44 ` Doug Ledford
2 siblings, 0 replies; 4+ messages in thread
From: Doug Ledford @ 2017-11-10 18:44 UTC (permalink / raw)
To: Thomas Bogendoerfer, Moni Shoua, linux-rdma, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 965 bytes --]
On Tue, 2017-10-31 at 11:16 +0100, Thomas Bogendoerfer wrote:
> Following crash happens, if crc algorithm couldn't be allocated:
>
> [ 1087.989072] rdma_rxe: loaded
> [ 1097.855397] PCLMULQDQ-NI instructions are not detected.
> [ 1097.901220] rdma_rxe: failed to allocate crc algorithmi err:-2
> [ 1097.901248] BUG: unable to handle kernel
> [ 1097.901249] NULL pointer dereference
> [ 1097.901250] at 0000000000000046
> [...]
>
> Reason is that rxe->tfm is assigned the error return, which will then
> be used for crypto_free_shash() in rxe_cleanup. Fix by using a
> temporary variable and assigning it rxe->tfm after allocation succeeded.
>
> Fixes: cee2688e3cd6 ("IB/rxe: Offload CRC calculation when possible")
> Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
Thanks, applied.
--
Doug Ledford <dledford@redhat.com>
GPG KeyID: B826A3330E572FDD
Key fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-11-10 18:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-31 10:16 [PATCH v2] IB/rxe: don't crash, if allocation of crc algorithm failed Thomas Bogendoerfer
2017-10-31 10:52 ` Leon Romanovsky
2017-10-31 11:08 ` Moni Shoua
2017-11-10 18:44 ` Doug Ledford
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).