Re: How to print out socket related data in the kernel?

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

 



Hello.

Ye ilho wrote:
>            err = sys_getsockname(a0,(struct sockaddr __user *)a1, (int __user *)a[2]);
Verify sys_getsockname() has succeeded
because printing *a1 is meaningless if sys_getsockname() has failed.

>  #define ILHO_IP_NUMS(x)  (x)&0xff, ((x)>>8)&0xff, ((x)>>16)&0xff, (x)>>24
Why not use NIPQUAD or HIPQUAD macro?

>                  struct sockaddr_in *name = (struct sockaddr __user*)a1;
Verify the address type is AF_INET
because all address types (for example, AF_INET6) can be passed to
this socket syscall. Printing in_addr field of AF_INET address is valid,
but printing in_addr field of non-AF_INET address is invalid.

You can't access *a1 directly because it is __user area.
You need to use copy_from_user() to read *a1.
Better place to insert your code may be in the sys_getsockname().

Thanks.

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux