mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 03:29:47 +07:00
d41519a69b
On sparc, if we have an alloca() like situation, as is the case with SHASH_DESC_ON_STACK(), we can end up referencing deallocated stack memory. The result can be that the value is clobbered if a trap or interrupt arrives at just the right instruction. It only occurs if the function ends returning a value from that alloca() area and that value can be placed into the return value register using a single instruction. For example, in lib/libcrc32c.c:crc32c() we end up with a return sequence like: return %i7+8 lduw [%o5+16], %o0 ! MEM[(u32 *)__shash_desc.1_10 + 16B], %o5 holds the base of the on-stack area allocated for the shash descriptor. But the return released the stack frame and the register window. So if an intererupt arrives between 'return' and 'lduw', then the value read at %o5+16 can be corrupted. Add a data compiler barrier to work around this problem. This is exactly what the gcc fix will end up doing as well, and it absolutely should not change the code generated for other cpus (unless gcc on them has the same bug :-) With crucial insight from Eric Sandeen. Cc: <stable@vger.kernel.org> Reported-by: Anatoly Pugachev <matorola@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
106 lines
3.0 KiB
C
106 lines
3.0 KiB
C
/*
|
|
* Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved.
|
|
* Copyright (c) 2015 System Fabric Works, Inc. All rights reserved.
|
|
*
|
|
* This software is available to you under a choice of one of two
|
|
* licenses. You may choose to be licensed under the terms of the GNU
|
|
* General Public License (GPL) Version 2, available from the file
|
|
* COPYING in the main directory of this source tree, or the
|
|
* OpenIB.org BSD license below:
|
|
*
|
|
* Redistribution and use in source and binary forms, with or
|
|
* without modification, are permitted provided that the following
|
|
* conditions are met:
|
|
*
|
|
* - Redistributions of source code must retain the above
|
|
* copyright notice, this list of conditions and the following
|
|
* disclaimer.
|
|
*
|
|
* - Redistributions in binary form must reproduce the above
|
|
* copyright notice, this list of conditions and the following
|
|
* disclaimer in the documentation and/or other materials
|
|
* provided with the distribution.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*/
|
|
|
|
#ifndef RXE_H
|
|
#define RXE_H
|
|
|
|
#ifdef pr_fmt
|
|
#undef pr_fmt
|
|
#endif
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/skbuff.h>
|
|
#include <linux/crc32.h>
|
|
|
|
#include <rdma/ib_verbs.h>
|
|
#include <rdma/ib_user_verbs.h>
|
|
#include <rdma/ib_pack.h>
|
|
#include <rdma/ib_smi.h>
|
|
#include <rdma/ib_umem.h>
|
|
#include <rdma/ib_cache.h>
|
|
#include <rdma/ib_addr.h>
|
|
#include <crypto/hash.h>
|
|
|
|
#include "rxe_net.h"
|
|
#include "rxe_opcode.h"
|
|
#include "rxe_hdr.h"
|
|
#include "rxe_param.h"
|
|
#include "rxe_verbs.h"
|
|
|
|
#define RXE_UVERBS_ABI_VERSION (1)
|
|
|
|
#define IB_PHYS_STATE_LINK_UP (5)
|
|
#define IB_PHYS_STATE_LINK_DOWN (3)
|
|
|
|
#define RXE_ROCE_V2_SPORT (0xc000)
|
|
|
|
static inline u32 rxe_crc32(struct rxe_dev *rxe,
|
|
u32 crc, void *next, size_t len)
|
|
{
|
|
u32 retval;
|
|
int err;
|
|
|
|
SHASH_DESC_ON_STACK(shash, rxe->tfm);
|
|
|
|
shash->tfm = rxe->tfm;
|
|
shash->flags = 0;
|
|
*(u32 *)shash_desc_ctx(shash) = crc;
|
|
err = crypto_shash_update(shash, next, len);
|
|
if (unlikely(err)) {
|
|
pr_warn_ratelimited("failed crc calculation, err: %d\n", err);
|
|
return crc32_le(crc, next, len);
|
|
}
|
|
|
|
retval = *(u32 *)shash_desc_ctx(shash);
|
|
barrier_data(shash_desc_ctx(shash));
|
|
return retval;
|
|
}
|
|
|
|
int rxe_set_mtu(struct rxe_dev *rxe, unsigned int dev_mtu);
|
|
|
|
int rxe_add(struct rxe_dev *rxe, unsigned int mtu);
|
|
void rxe_remove(struct rxe_dev *rxe);
|
|
void rxe_remove_all(void);
|
|
|
|
int rxe_rcv(struct sk_buff *skb);
|
|
|
|
void rxe_dev_put(struct rxe_dev *rxe);
|
|
struct rxe_dev *net_to_rxe(struct net_device *ndev);
|
|
struct rxe_dev *get_rxe_by_name(const char* name);
|
|
|
|
void rxe_port_up(struct rxe_dev *rxe);
|
|
void rxe_port_down(struct rxe_dev *rxe);
|
|
|
|
#endif /* RXE_H */
|