All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/1] virt: acrn: Drop internal kernel type from ABI
@ 2021-10-01 13:56 Andy Shevchenko
  2021-10-01 14:01 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2021-10-01 13:56 UTC (permalink / raw)
  To: Reinette Chatre, Greg Kroah-Hartman, Shuo Liu, Zhi Wang,
	Andy Shevchenko, linux-kernel
  Cc: Fei Li

guid_t is internal type of the kernel which is mistakenly had been exposed
to the user space. Replace it with raw buffers.

Besides that it's obvious from the link in the sample code, that the real
use is of uuid_t type, but because uuid_t hasn't exposed, so should guid_t,
the code includes and uses wrong type.

Fixes: 5b06931d7f8b ("sample/acrn: Introduce a sample of HSM ioctl interface usage")
Fixes: 9c5137aedd11 ("virt: acrn: Introduce VM management interfaces")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/uapi/linux/acrn.h | 3 +--
 samples/acrn/vm-sample.c  | 5 ++++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/include/uapi/linux/acrn.h b/include/uapi/linux/acrn.h
index 353b2a2e4536..4312af1b8013 100644
--- a/include/uapi/linux/acrn.h
+++ b/include/uapi/linux/acrn.h
@@ -12,7 +12,6 @@
 #define _UAPI_ACRN_H
 
 #include <linux/types.h>
-#include <linux/uuid.h>
 
 #define ACRN_IO_REQUEST_MAX		16
 
@@ -198,7 +197,7 @@ struct acrn_vm_creation {
 	__u16	reserved0;
 	__u16	vcpu_num;
 	__u16	reserved1;
-	guid_t	uuid;
+	__u8	uuid[16];
 	__u64	vm_flag;
 	__u64	ioreq_buf;
 	__u64	cpu_affinity;
diff --git a/samples/acrn/vm-sample.c b/samples/acrn/vm-sample.c
index b2dad47a77a0..1639fcadc766 100644
--- a/samples/acrn/vm-sample.c
+++ b/samples/acrn/vm-sample.c
@@ -30,7 +30,10 @@ static struct acrn_io_request *io_req_buf = (struct acrn_io_request *)io_request
 __u16 vcpu_num;
 __u16 vmid;
 /* POST_STANDARD_VM_UUID1, refer to https://github.com/projectacrn/acrn-hypervisor/blob/master/hypervisor/include/common/vm_uuids.h */
-guid_t vm_uuid = GUID_INIT(0x385479d2, 0xd625, 0xe811, 0x86, 0x4e, 0xcb, 0x7a, 0x18, 0xb3, 0x46, 0x43);
+__u8 vm_uuid[16] = {
+	0xd2, 0x79, 0x54, 0x38, 0x25, 0xd6, 0x11, 0xe8,
+	0x86, 0x4e, 0xcb, 0x7a, 0x18, 0xb3, 0x46, 0x43,
+};
 
 int hsm_fd;
 int is_running = 1;
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 1/1] virt: acrn: Drop internal kernel type from ABI
  2021-10-01 13:56 [PATCH v1 1/1] virt: acrn: Drop internal kernel type from ABI Andy Shevchenko
@ 2021-10-01 14:01 ` Greg Kroah-Hartman
  2021-10-01 14:58   ` Andy Shevchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Greg Kroah-Hartman @ 2021-10-01 14:01 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Reinette Chatre, Shuo Liu, Zhi Wang, linux-kernel, Fei Li

On Fri, Oct 01, 2021 at 04:56:44PM +0300, Andy Shevchenko wrote:
> guid_t is internal type of the kernel which is mistakenly had been exposed
> to the user space. Replace it with raw buffers.

Wait, why is it a mistake to expose it to userspace?  What does this
conflict with?  Is it a namespace issue?  Or something else?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 1/1] virt: acrn: Drop internal kernel type from ABI
  2021-10-01 14:01 ` Greg Kroah-Hartman
@ 2021-10-01 14:58   ` Andy Shevchenko
  2021-10-01 15:10     ` Greg Kroah-Hartman
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2021-10-01 14:58 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Reinette Chatre, Shuo Liu, Zhi Wang, linux-kernel, Fei Li

On Fri, Oct 01, 2021 at 04:01:41PM +0200, Greg Kroah-Hartman wrote:
> On Fri, Oct 01, 2021 at 04:56:44PM +0300, Andy Shevchenko wrote:
> > guid_t is internal type of the kernel which is mistakenly had been exposed
> > to the user space. Replace it with raw buffers.
> 
> Wait, why is it a mistake to expose it to userspace?  What does this
> conflict with?  Is it a namespace issue?  Or something else?

It is the type which is defined solely for kernel use and what user space
should do is to use types defined by respective libraries, such as libuuid.

If you read the commit message to the end, you will notice that I have
mentioned the possible scenario what happened here. They seems misusing
guid_t as uuid_t, but the latter is not available for the users from
the kernel headers (and this is good). So this is an exact example why
guid_t shouldn't be exposed.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 1/1] virt: acrn: Drop internal kernel type from ABI
  2021-10-01 14:58   ` Andy Shevchenko
@ 2021-10-01 15:10     ` Greg Kroah-Hartman
  2021-12-13 20:18       ` Andy Shevchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Greg Kroah-Hartman @ 2021-10-01 15:10 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Reinette Chatre, Shuo Liu, Zhi Wang, linux-kernel, Fei Li

On Fri, Oct 01, 2021 at 05:58:49PM +0300, Andy Shevchenko wrote:
> On Fri, Oct 01, 2021 at 04:01:41PM +0200, Greg Kroah-Hartman wrote:
> > On Fri, Oct 01, 2021 at 04:56:44PM +0300, Andy Shevchenko wrote:
> > > guid_t is internal type of the kernel which is mistakenly had been exposed
> > > to the user space. Replace it with raw buffers.
> > 
> > Wait, why is it a mistake to expose it to userspace?  What does this
> > conflict with?  Is it a namespace issue?  Or something else?
> 
> It is the type which is defined solely for kernel use and what user space
> should do is to use types defined by respective libraries, such as libuuid.

But that does not work here.  We want to expose a common uuid type that
userspace can use in these structures, as well as the kernel.  Do you
really want to "open code" arrays all over the place?

> If you read the commit message to the end, you will notice that I have
> mentioned the possible scenario what happened here. They seems misusing
> guid_t as uuid_t, but the latter is not available for the users from
> the kernel headers (and this is good). So this is an exact example why
> guid_t shouldn't be exposed.

Then we should create a type that we can use here.  The kernel can not
use libuuid, so what is wrong with using the kernel variable type
namespace for this?  __guid?  __uuid?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 1/1] virt: acrn: Drop internal kernel type from ABI
  2021-10-01 15:10     ` Greg Kroah-Hartman
@ 2021-12-13 20:18       ` Andy Shevchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2021-12-13 20:18 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Reinette Chatre, Shuo Liu, Zhi Wang, linux-kernel, Fei Li

On Fri, Oct 01, 2021 at 05:10:10PM +0200, Greg Kroah-Hartman wrote:
> On Fri, Oct 01, 2021 at 05:58:49PM +0300, Andy Shevchenko wrote:
> > On Fri, Oct 01, 2021 at 04:01:41PM +0200, Greg Kroah-Hartman wrote:
> > > On Fri, Oct 01, 2021 at 04:56:44PM +0300, Andy Shevchenko wrote:
> > > > guid_t is internal type of the kernel which is mistakenly had been exposed
> > > > to the user space. Replace it with raw buffers.
> > > 
> > > Wait, why is it a mistake to expose it to userspace?  What does this
> > > conflict with?  Is it a namespace issue?  Or something else?
> > 
> > It is the type which is defined solely for kernel use and what user space
> > should do is to use types defined by respective libraries, such as libuuid.
> 
> But that does not work here.  We want to expose a common uuid type that
> userspace can use in these structures, as well as the kernel.  Do you
> really want to "open code" arrays all over the place?

It's not used "all over a place", the only code is recently added by this
driver.

> > If you read the commit message to the end, you will notice that I have
> > mentioned the possible scenario what happened here. They seems misusing
> > guid_t as uuid_t, but the latter is not available for the users from
> > the kernel headers (and this is good). So this is an exact example why
> > guid_t shouldn't be exposed.
> 
> Then we should create a type that we can use here.  The kernel can not
> use libuuid, so what is wrong with using the kernel variable type
> namespace for this?  __guid?  __uuid?

Why? "All over the place" except this code (okay and one more, i.e. MEI,
but this is another story) we use raw arrays in ABI. Why virt out of a
sudden need a special _kernel_ type for that? I think the author simply
missed this subtle detail that it's not supposed to be outside of the
kernel.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-12-13 20:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-01 13:56 [PATCH v1 1/1] virt: acrn: Drop internal kernel type from ABI Andy Shevchenko
2021-10-01 14:01 ` Greg Kroah-Hartman
2021-10-01 14:58   ` Andy Shevchenko
2021-10-01 15:10     ` Greg Kroah-Hartman
2021-12-13 20:18       ` Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.