hinic: fix bug of wq out of bound access
authorQiao Ma <mqaio@linux.alibaba.com>
Thu, 28 Apr 2022 12:30:16 +0000 (20:30 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 12 May 2022 10:30:18 +0000 (12:30 +0200)
commit299c189f4778267740026feffded245ce96ae65c
treedbec0ebd5d9c58b15904e2305124de7c7b7c5ac0
parent74b9abc46862aa82606893afaef4d01f4bc9cf8d
hinic: fix bug of wq out of bound access

commit 52b2abef450a78e25d485ac61e32f4ce86a87701 upstream.

If wq has only one page, we need to check wqe rolling over page by
compare end_idx and curr_idx, and then copy wqe to shadow wqe to
avoid out of bound access.
This work has been done in hinic_get_wqe, but missed for hinic_read_wqe.
This patch fixes it, and removes unnecessary MASKED_WQE_IDX().

Fixes: 7dd29ee12865 ("hinic: add sriov feature support")
Signed-off-by: Qiao Ma <mqaio@linux.alibaba.com>
Reviewed-by: Xunlei Pang <xlpang@linux.alibaba.com>
Link: https://lore.kernel.org/r/282817b0e1ae2e28fdf3ed8271a04e77f57bf42e.1651148587.git.mqaio@linux.alibaba.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/huawei/hinic/hinic_hw_wq.c