public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leonro@nvidia.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Saeed Mahameed <saeed@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	<linux-kernel@vger.kernel.org>, Jason Gunthorpe <jgg@nvidia.com>,
	Jiri Pirko <jiri@nvidia.com>, Saeed Mahameed <saeedm@nvidia.com>
Subject: Re: [PATCH 3/5] misc: mlx5ctl: Add info ioctl
Date: Wed, 18 Oct 2023 13:08:23 +0300	[thread overview]
Message-ID: <20231018100823.GH5392@unreal> (raw)
In-Reply-To: <6fb88a6a-dd66-4368-8da9-596f384fe5bc@app.fastmail.com>

On Wed, Oct 18, 2023 at 11:02:00AM +0200, Arnd Bergmann wrote:
> On Wed, Oct 18, 2023, at 10:19, Saeed Mahameed wrote:
> 
> > Implement INFO ioctl to return the allocated UID and the capability flags
> > and some other useful device information such as the underlying ConnectX
> > device.
> 
> I'm commenting on the ABI here, ignoring everything for the moment.
> 
> >  static const struct file_operations mlx5ctl_fops = {
> >  	.owner = THIS_MODULE,
> >  	.open = mlx5ctl_open,
> >  	.release = mlx5ctl_release,
> > +	.unlocked_ioctl = mlx5ctl_ioctl,
> >  };
> 
> There should be a .compat_ioctl entry as well, to allow 32-bit
> tasks to use the same interface.

Even for new code as well?

Both kernel and userspace code is new, not released yet.

>  
> >  static int mlx5ctl_probe(struct auxiliary_device *adev,
> > diff --git a/include/uapi/misc/mlx5ctl.h b/include/uapi/misc/mlx5ctl.h
> > new file mode 100644
> > index 000000000000..81d89cd285fc
> > --- /dev/null
> > +++ b/include/uapi/misc/mlx5ctl.h
> > @@ -0,0 +1,24 @@
> > +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB WITH Linux-syscall-note */
> > +/* Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */
> > +
> > +#ifndef __MLX5CTL_IOCTL_H__
> > +#define __MLX5CTL_IOCTL_H__
> > +
> > +struct mlx5ctl_info {
> > +	__aligned_u64 flags;
> > +	__u32 size;
> > +	__u8 devname[64]; /* underlaying ConnectX device */
> > +	__u16 uctx_uid; /* current process allocated UCTX UID */
> 
> I don't know what a UCTX UID is, but if this is related to
> uid_t, it has to be 32 bit wide.

UCTX UID is mlx5 hardware index, it is not uid_t.

> 
> > +	__u16 reserved1;
> > +	__u32 uctx_cap; /* current process effective UCTX cap */
> > +	__u32 dev_uctx_cap; /* device's UCTX capabilities */
> > +	__u32 ucap; /* process user capability */
> > +	__u32 reserved2[4];
> > +};
> 
> If I'm counting right, this structure has a size of
> 108 bytes but an alignment of 8 bytes, so you end up with
> a 4-byte hole at the end, which introduces a risk of
> leaking kernel data. Maybe give it an extra reserved word?

I think that he needs to delete __u32 reserved2[4]; completely.

Thanks

> 
>      Arnd

  reply	other threads:[~2023-10-18 10:08 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-18  8:19 [PATCH 0/5] mlx5 ConnectX diagnostic misc driver Saeed Mahameed
2023-10-18  8:19 ` [PATCH 1/5] mlx5: Add aux dev for ctl interface Saeed Mahameed
2023-10-18  8:19 ` [PATCH 2/5] misc: mlx5ctl: Add mlx5ctl misc driver Saeed Mahameed
2023-10-18  8:30   ` Greg Kroah-Hartman
2023-10-18  8:49     ` Leon Romanovsky
2023-10-18  8:55       ` Greg Kroah-Hartman
2023-10-18 10:00         ` Leon Romanovsky
2023-10-18 11:52           ` Greg Kroah-Hartman
2023-10-18 18:01     ` Jason Gunthorpe
2023-10-18 18:22       ` Greg Kroah-Hartman
2023-10-18 18:56         ` Jason Gunthorpe
2023-10-19 17:21           ` Greg Kroah-Hartman
2023-10-19 19:00             ` Jason Gunthorpe
2023-10-19 19:46               ` Greg Kroah-Hartman
2023-10-19 23:49                 ` Jason Gunthorpe
2023-10-20 20:17                   ` Greg Kroah-Hartman
2023-10-19 21:50             ` Dual licensing [was: [PATCH 2/5] misc: mlx5ctl: Add mlx5ctl misc driver] Jonathan Corbet
2023-10-20 19:30               ` Dave Airlie
2023-10-20 20:07               ` Greg Kroah-Hartman
2023-10-18  8:30   ` [PATCH 2/5] misc: mlx5ctl: Add mlx5ctl misc driver Greg Kroah-Hartman
2023-10-18  8:19 ` [PATCH 3/5] misc: mlx5ctl: Add info ioctl Saeed Mahameed
2023-10-18  9:02   ` Arnd Bergmann
2023-10-18 10:08     ` Leon Romanovsky [this message]
2023-10-18 11:02       ` Arnd Bergmann
2023-10-22  1:46   ` kernel test robot
2023-10-22 11:27   ` kernel test robot
2023-10-18  8:19 ` [PATCH 4/5] misc: mlx5ctl: Add command rpc ioctl Saeed Mahameed
2023-10-18  8:19 ` [PATCH 5/5] misc: mlx5ctl: Add umem reg/unreg ioctl Saeed Mahameed
2023-10-18  8:33   ` Greg Kroah-Hartman
2023-11-19  9:49     ` Saeed Mahameed
2023-10-18  9:30   ` Arnd Bergmann
2023-10-18 11:51     ` Jason Gunthorpe
2023-11-19  9:44     ` Saeed Mahameed
2023-10-18  8:31 ` [PATCH 0/5] mlx5 ConnectX diagnostic misc driver Greg Kroah-Hartman
2023-10-18 12:00   ` Jason Gunthorpe
2023-10-18 12:11     ` Greg Kroah-Hartman

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=20231018100823.GH5392@unreal \
    --to=leonro@nvidia.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=jgg@nvidia.com \
    --cc=jiri@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=saeed@kernel.org \
    --cc=saeedm@nvidia.com \
    /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