Re: [patch] vsock.7: Add missing structure element

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Mikhail,

On 11/19/19 6:31 PM, Mikhail Golubev wrote:
> The structure 'struct sockaddr_vm' has additional element 'unsigned char
> svm_zero[]' since version v3.9-rc1 (include/uapi/linux/vm_sockets.h).
> Linux kernel checks that this element is zeroed
> (net/vmw_vsock/vsock_addr.c). Reflect this on the vsock man page.
> 
> Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=205583
> Signed-off-by: Mikhail Golubev <Mikhail.Golubev@xxxxxxxxxxxxxxx>
> ---
>  man7/vsock.7 | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/man7/vsock.7 b/man7/vsock.7
> index 23c67548f..145057719 100644
> --- a/man7/vsock.7
> +++ b/man7/vsock.7
> @@ -95,6 +95,7 @@ struct sockaddr_vm {
>      unsigned short svm_reserved1;
>      unsigned int   svm_port;       /* Port # in host byte order */
>      unsigned int   svm_cid;        /* Address in host byte order */
> +    unsigned char  svm_zero[];
>  };
>  .EE
>  .in
> @@ -113,6 +114,8 @@ Only a process with the
>  capability may
>  .BR bind (2)
>  to these port numbers.
> +.I svm_zero
> +is always set to 0.
>  .PP
>  There are several special addresses:
>  .B VMADDR_CID_ANY

Thanks for the patch. I applied it, and tweaked the wording also.
In addition, I think we must describe the size of the field,
since the use of an open-ended array at the end of a struct
has a specific (different) meaning in C. So, in the end the change
looks as below.

Cheers,

Michael

diff --git a/man7/vsock.7 b/man7/vsock.7
index 23c67548f..1adc3084b 100644
--- a/man7/vsock.7
+++ b/man7/vsock.7
@@ -95,6 +95,11 @@ struct sockaddr_vm {
     unsigned short svm_reserved1;
     unsigned int   svm_port;       /* Port # in host byte order */
     unsigned int   svm_cid;        /* Address in host byte order */
+    unsigned char  svm_zero[sizeof(struct sockaddr) \-
+                            sizeof(sa_family_t) \-
+                            sizeof(unsigned short) \-
+                            sizeof(unsigned int) \-
+                            sizeof(unsigned int)];
 };
 .EE
 .in
@@ -113,6 +118,8 @@ Only a process with the
 capability may
 .BR bind (2)
 to these port numbers.
+.I svm_zero
+must be zero-filled.
 .PP
 There are several special addresses:
 .B VMADDR_CID_ANY



-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux