[v1,3/3] net/failsafe: fix default service proxy state
Checks
Commit Message
The service proxy is initialized at 0. This is assuming that all of
its fields are invalid at 0. The issue is that a file descriptor at 0 is a
valid one.
The value -1 is used as sentinel during cleanup. Initialize the RX proxy
file descriptor to -1.
Fixes: 366226dd859f ("net/failsafe: fix fd leak")
Signed-off-by: Gaetan Rivet <grive@u256.net>
Cc: wangyunjian@huawei.com
Cc: Ali Alnubani <alialnu@mellanox.com>
---
drivers/net/failsafe/failsafe.c | 1 +
drivers/net/failsafe/failsafe_private.h | 8 ++++++++
2 files changed, 9 insertions(+)
Comments
Thanks Gaetan.
> -----Original Message-----
> From: Gaetan Rivet <grive@u256.net>
> Sent: Tuesday, May 5, 2020 10:11 PM
> To: dev@dpdk.org
> Cc: wangyunjian@huawei.com; Ali Alnubani <alialnu@mellanox.com>
> Subject: [PATCH v1 3/3] net/failsafe: fix default service proxy state
>
> The service proxy is initialized at 0. This is assuming that all of its fields are
> invalid at 0. The issue is that a file descriptor at 0 is a valid one.
>
> The value -1 is used as sentinel during cleanup. Initialize the RX proxy file
> descriptor to -1.
>
> Fixes: 366226dd859f ("net/failsafe: fix fd leak")
> Signed-off-by: Gaetan Rivet <grive@u256.net>
> Cc: wangyunjian@huawei.com
> Cc: Ali Alnubani <alialnu@mellanox.com>
Tested-by: Ali Alnubani <alialnu@mellanox.com>
On 5/5/2020 8:10 PM, Gaetan Rivet wrote:
> The service proxy is initialized at 0. This is assuming that all of
> its fields are invalid at 0. The issue is that a file descriptor at 0 is a
> valid one.
>
> The value -1 is used as sentinel during cleanup. Initialize the RX proxy
> file descriptor to -1.
>
> Fixes: 366226dd859f ("net/failsafe: fix fd leak")
> Signed-off-by: Gaetan Rivet <grive@u256.net>
I have squashed this to the commit in the fixes line, to not leave any commit
that can cause crash, and kept both sign-offs and Ali's test tag.
Squashed into relevant commit in next-net, thanks.
@@ -190,6 +190,7 @@ fs_eth_dev_create(struct rte_vdev_device *vdev)
}
priv = PRIV(dev);
priv->data = dev->data;
+ priv->rxp = FS_RX_PROXY_INIT;
dev->dev_ops = &failsafe_ops;
dev->data->mac_addrs = &PRIV(dev)->mac_addrs[0];
dev->data->dev_link = eth_link;
@@ -58,6 +58,14 @@ struct rx_proxy {
enum rxp_service_state sstate;
};
+#define FS_RX_PROXY_INIT (struct rx_proxy){ \
+ .efd = -1, \
+ .evec = NULL, \
+ .sid = 0, \
+ .scid = 0, \
+ .sstate = SS_NO_SERVICE, \
+}
+
struct rxq {
struct fs_priv *priv;
uint16_t qid;