提交 38e9d289 编写于 作者: H Haiyue Wang 提交者: Zheng Zengkai

gve: fix the wrong AdminQ buffer overflow check

stable inclusion
from stable-5.10.65
commit f1673e85254d3dae8f595c0367cd33c73530952e
bugzilla: 182361 https://gitee.com/openeuler/kernel/issues/I4EH3U

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=f1673e85254d3dae8f595c0367cd33c73530952e

--------------------------------

[ Upstream commit 63a9192b ]

The 'tail' pointer is also free-running count, so it needs to be masked
as 'adminq_prod_cnt' does, to become an index value of AdminQ buffer.

Fixes: 5cdad90d ("gve: Batch AQ commands for creating and destroying queues.")
Signed-off-by: NHaiyue Wang <haiyue.wang@intel.com>
Reviewed-by: NCatherine Sullivan <csully@google.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 6a062f7a
...@@ -182,7 +182,8 @@ static int gve_adminq_issue_cmd(struct gve_priv *priv, ...@@ -182,7 +182,8 @@ static int gve_adminq_issue_cmd(struct gve_priv *priv,
tail = ioread32be(&priv->reg_bar0->adminq_event_counter); tail = ioread32be(&priv->reg_bar0->adminq_event_counter);
// Check if next command will overflow the buffer. // Check if next command will overflow the buffer.
if (((priv->adminq_prod_cnt + 1) & priv->adminq_mask) == tail) { if (((priv->adminq_prod_cnt + 1) & priv->adminq_mask) ==
(tail & priv->adminq_mask)) {
int err; int err;
// Flush existing commands to make room. // Flush existing commands to make room.
...@@ -192,7 +193,8 @@ static int gve_adminq_issue_cmd(struct gve_priv *priv, ...@@ -192,7 +193,8 @@ static int gve_adminq_issue_cmd(struct gve_priv *priv,
// Retry. // Retry.
tail = ioread32be(&priv->reg_bar0->adminq_event_counter); tail = ioread32be(&priv->reg_bar0->adminq_event_counter);
if (((priv->adminq_prod_cnt + 1) & priv->adminq_mask) == tail) { if (((priv->adminq_prod_cnt + 1) & priv->adminq_mask) ==
(tail & priv->adminq_mask)) {
// This should never happen. We just flushed the // This should never happen. We just flushed the
// command queue so there should be enough space. // command queue so there should be enough space.
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册