Re: [PATCH] 9p/xen: Fix end of loop tests for list_for_each_entry
From: asmadeus
Date: Sun Jul 25 2021 - 16:47:03 EST
- Next message: kernel test robot: "[robh:for-next 14/20] dtbs_check: arch/arm/boot/dts/artpec6-devboard.dt.yaml: pcie@f8050000: reg-names:1: 'phy' is not one of ['dbi', 'dbi2', 'config', 'atu', 'app', 'elbi', 'mgmt', 'ctrl', 'parf', 'cfg', 'link', 'ulreg', 'smu', 'mpu']"
- Previous message: Jonathan Corbet: "Re: [PATCH] docs: submitting-patches: clarify the role of LKML"
- In reply to: Harshvardhan Jha: "[PATCH] 9p/xen: Fix end of loop tests for list_for_each_entry"
- Next in thread: Stefano Stabellini: "Re: [PATCH] 9p/xen: Fix end of loop tests for list_for_each_entry"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Harshvardhan Jha wrote on Sun, Jul 25, 2021 at 11:21:03PM +0530:
> The list_for_each_entry() iterator, "priv" in this code, can never be
> NULL so the warning would never be printed.
hm? priv won't be NULL but priv->client won't be client, so it will
return -EINVAL alright in practice?
This does fix an invalid read after the list head, so there's a real
bug, but the commit message needs fixing.
>
> Signed-off-by: Harshvardhan Jha <harshvardhan.jha@xxxxxxxxxx>
> ---
> From static analysis. Not tested.
+Stefano in To - I also can't test xen right now :/
This looks functional to me but if you have a bit of time to spare just
a mount test can't hurt.
> ---
> net/9p/trans_xen.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/9p/trans_xen.c b/net/9p/trans_xen.c
> index f4fea28e05da..3ec1a51a6944 100644
> --- a/net/9p/trans_xen.c
> +++ b/net/9p/trans_xen.c
> @@ -138,7 +138,7 @@ static bool p9_xen_write_todo(struct xen_9pfs_dataring *ring, RING_IDX size)
>
> static int p9_xen_request(struct p9_client *client, struct p9_req_t *p9_req)
> {
> - struct xen_9pfs_front_priv *priv = NULL;
> + struct xen_9pfs_front_priv *priv;
> RING_IDX cons, prod, masked_cons, masked_prod;
> unsigned long flags;
> u32 size = p9_req->tc.size;
> @@ -151,7 +151,7 @@ static int p9_xen_request(struct p9_client *client, struct p9_req_t *p9_req)
> break;
> }
> read_unlock(&xen_9pfs_lock);
> - if (!priv || priv->client != client)
> + if (list_entry_is_head(priv, &xen_9pfs_devs, list))
> return -EINVAL;
>
> num = p9_req->tc.tag % priv->num_rings;
--
Dominique
- Next message: kernel test robot: "[robh:for-next 14/20] dtbs_check: arch/arm/boot/dts/artpec6-devboard.dt.yaml: pcie@f8050000: reg-names:1: 'phy' is not one of ['dbi', 'dbi2', 'config', 'atu', 'app', 'elbi', 'mgmt', 'ctrl', 'parf', 'cfg', 'link', 'ulreg', 'smu', 'mpu']"
- Previous message: Jonathan Corbet: "Re: [PATCH] docs: submitting-patches: clarify the role of LKML"
- In reply to: Harshvardhan Jha: "[PATCH] 9p/xen: Fix end of loop tests for list_for_each_entry"
- Next in thread: Stefano Stabellini: "Re: [PATCH] 9p/xen: Fix end of loop tests for list_for_each_entry"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]