From: Haggai Eran <haggaie-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
To: Eli Cohen <eli-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>,
roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org,
yevgenyp-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org,
Eli Cohen <eli-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Subject: Re: [PATCH for-next 2/5] IB/core: Add support for extended query device caps
Date: Tue, 4 Nov 2014 14:35:09 +0200 [thread overview]
Message-ID: <5458C7FD.7070400@mellanox.com> (raw)
In-Reply-To: <1415001766-8366-3-git-send-email-eli-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
On 03/11/2014 10:02, Eli Cohen wrote:
> +int ib_uverbs_ex_query_device(struct ib_uverbs_file *file,
> + struct ib_udata *ucore,
> + struct ib_udata *uhw)
> +{
> + struct ib_uverbs_ex_query_device_resp resp;
> + struct ib_uverbs_ex_query_device cmd;
> + struct ib_device_attr attr;
> + struct ib_device *device;
> + int err;
> +
> + device = file->device->ib_dev;
> + if (ucore->inlen < sizeof(cmd))
> + return -EINVAL;
> +
> + if (ucore->outlen < sizeof(resp))
> + return -ENOSPC;
This check may cause compatibility problems when running a newer kernel
with old userspace. The userspace code will have a smaller
ib_uverbs_ex_query_device_resp struct, so the verb will always fail. A
possible solution is to drop this check, and modify ib_copy_to_udata so
that it only copies up to ucore->outlen bytes.
> +
> + err = ib_copy_from_udata(&cmd, ucore, sizeof(cmd));
> + if (err)
> + return err;
> +
> + if (cmd.comp_mask)
> + return -EINVAL;
This check may make it difficult for userspace to use this verb. If
running an older kernel with a newer userspace, the userspace will need
to run the verb multiple times to find out which combination of
comp_mask bits is actually supported. I think a better way would be to
drop this check, and let userspace rely on the returned comp_mask in the
ib_uverbs_ex_query_device_resp struct to determine which features are
supported by the current kernel.
> +
> + err = device->query_device(device, &attr);
> + if (err)
> + return err;
> +
> + memset(&resp, 0, sizeof(resp));
> + copy_query_dev_fields(file, &resp.base, &attr);
> + resp.comp_mask = 0;
> +
> + err = ib_copy_to_udata(ucore, &resp, sizeof(resp));
> + if (err)
> + return err;
> +
> + return 0;
> +}
Regards,
Haggai
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2014-11-04 12:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-03 8:02 [PATCH for-next 0/5] Extended atomics enhancements Eli Cohen
[not found] ` <1415001766-8366-1-git-send-email-eli-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2014-11-03 8:02 ` [PATCH for-next 1/5] IB/mlx5: Fix sparse warnings Eli Cohen
2014-11-03 8:02 ` [PATCH for-next 2/5] IB/core: Add support for extended query device caps Eli Cohen
[not found] ` <1415001766-8366-3-git-send-email-eli-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2014-11-04 12:35 ` Haggai Eran [this message]
[not found] ` <5458C7FD.7070400-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2014-11-06 8:54 ` Eli Cohen
2014-11-03 8:02 ` [PATCH for-next 3/5] IB/core: Extend atomic operations Eli Cohen
2014-11-03 8:02 ` [PATCH for-next 4/5] IB/mlx5: Add extended atomic support Eli Cohen
2014-11-03 8:02 ` [PATCH for-next 5/5] IB/mlx4: Modify mlx4 to comply with extended atomic definitions Eli Cohen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5458C7FD.7070400@mellanox.com \
--to=haggaie-vpraknaxozvwk0htik3j/w@public.gmane.org \
--cc=eli-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org \
--cc=eli-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
--cc=roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=yevgenyp-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox