public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] statd: Teach nfs_compare_sockaddr() to handle NULL arguments.
@ 2010-01-25 16:59 Steve Dickson
       [not found] ` <4B5DCDEB.60708-AfCzQyP5zfLQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Steve Dickson @ 2010-01-25 16:59 UTC (permalink / raw)
  To: Linux NFS Mailing list

It seems the list of interfaces returned by getifaddrs()
can contain a null address pointer (ifa->ifa_addr) even though 
the interface is marked UP (this happens with the tun0 interface).

So this patch makes nfs_compare_sockaddr() return false
if either one of its arguments is null..

Author: Steve Dickson <steved@redhat.com>
Date:   Mon Jan 25 11:42:36 2010 -0500

    Teach nfs_compare_sockaddr() to handle NULL arguments.
    
    Signed-off-by: Steve Dickson <steved@redhat.com>

diff --git a/support/include/sockaddr.h b/support/include/sockaddr.h
index 732514b..9af2543 100644
--- a/support/include/sockaddr.h
+++ b/support/include/sockaddr.h
@@ -20,6 +20,7 @@
 #ifndef NFS_UTILS_SOCKADDR_H
 #define NFS_UTILS_SOCKADDR_H
 
+#include <libio.h>
 #include <stdbool.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
@@ -223,6 +224,9 @@ compare_sockaddr6(__attribute__ ((unused)) const struct sockaddr *sa1,
 static inline _Bool
 nfs_compare_sockaddr(const struct sockaddr *sa1, const struct sockaddr *sa2)
 {
+	if (sa1 == NULL || sa2 == NULL)
+		return false;
+
 	if (sa1->sa_family == sa2->sa_family)
 		switch (sa1->sa_family) {
 		case AF_INET:

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

* Re: [PATCH] statd: Teach nfs_compare_sockaddr() to handle NULL arguments.
       [not found] ` <4B5DCDEB.60708-AfCzQyP5zfLQT0dZR+AlfA@public.gmane.org>
@ 2010-01-25 18:05   ` Chuck Lever
  2010-01-25 18:18     ` Chuck Lever
  2010-01-25 18:10   ` Steve Dickson
  1 sibling, 1 reply; 4+ messages in thread
From: Chuck Lever @ 2010-01-25 18:05 UTC (permalink / raw)
  To: Steve Dickson; +Cc: Linux NFS Mailing list

On Jan 25, 2010, at 11:59 AM, Steve Dickson wrote:
> It seems the list of interfaces returned by getifaddrs()
> can contain a null address pointer (ifa->ifa_addr) even though
> the interface is marked UP (this happens with the tun0 interface).

It might be nice to document this quirk in from_local.c.

> So this patch makes nfs_compare_sockaddr() return false
> if either one of its arguments is null..
>
> Author: Steve Dickson <steved@redhat.com>
> Date:   Mon Jan 25 11:42:36 2010 -0500
>
>    Teach nfs_compare_sockaddr() to handle NULL arguments.
>
>    Signed-off-by: Steve Dickson <steved@redhat.com>

Reviewed-by: Chuck Lever <chuck.lever@oracle.com>

> diff --git a/support/include/sockaddr.h b/support/include/sockaddr.h
> index 732514b..9af2543 100644
> --- a/support/include/sockaddr.h
> +++ b/support/include/sockaddr.h
> @@ -20,6 +20,7 @@
> #ifndef NFS_UTILS_SOCKADDR_H
> #define NFS_UTILS_SOCKADDR_H
>
> +#include <libio.h>
> #include <stdbool.h>
> #include <sys/socket.h>
> #include <netinet/in.h>
> @@ -223,6 +224,9 @@ compare_sockaddr6(__attribute__ ((unused)) const  
> struct sockaddr *sa1,
> static inline _Bool
> nfs_compare_sockaddr(const struct sockaddr *sa1, const struct  
> sockaddr *sa2)
> {
> +	if (sa1 == NULL || sa2 == NULL)
> +		return false;
> +
> 	if (sa1->sa_family == sa2->sa_family)
> 		switch (sa1->sa_family) {
> 		case AF_INET:
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs"  
> in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Chuck Lever
chuck[dot]lever[at]oracle[dot]com





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

* Re: [PATCH] statd: Teach nfs_compare_sockaddr() to handle NULL arguments.
       [not found] ` <4B5DCDEB.60708-AfCzQyP5zfLQT0dZR+AlfA@public.gmane.org>
  2010-01-25 18:05   ` Chuck Lever
@ 2010-01-25 18:10   ` Steve Dickson
  1 sibling, 0 replies; 4+ messages in thread
From: Steve Dickson @ 2010-01-25 18:10 UTC (permalink / raw)
  To: Linux NFS Mailing list



On 01/25/2010 11:59 AM, Steve Dickson wrote:
> It seems the list of interfaces returned by getifaddrs()
> can contain a null address pointer (ifa->ifa_addr) even though 
> the interface is marked UP (this happens with the tun0 interface).
> 
> So this patch makes nfs_compare_sockaddr() return false
> if either one of its arguments is null..
> 
Committed...

steved.

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

* Re: [PATCH] statd: Teach nfs_compare_sockaddr() to handle NULL arguments.
  2010-01-25 18:05   ` Chuck Lever
@ 2010-01-25 18:18     ` Chuck Lever
  0 siblings, 0 replies; 4+ messages in thread
From: Chuck Lever @ 2010-01-25 18:18 UTC (permalink / raw)
  To: Steve Dickson; +Cc: Linux NFS Mailing List


On Jan 25, 2010, at 1:05 PM, Chuck Lever wrote:

> On Jan 25, 2010, at 11:59 AM, Steve Dickson wrote:
>> It seems the list of interfaces returned by getifaddrs()
>> can contain a null address pointer (ifa->ifa_addr) even though
>> the interface is marked UP (this happens with the tun0 interface).
>
> It might be nice to document this quirk in from_local.c.
>
>> So this patch makes nfs_compare_sockaddr() return false
>> if either one of its arguments is null..
>>
>> Author: Steve Dickson <steved@redhat.com>
>> Date:   Mon Jan 25 11:42:36 2010 -0500
>>
>>   Teach nfs_compare_sockaddr() to handle NULL arguments.
>>
>>   Signed-off-by: Steve Dickson <steved@redhat.com>
>
> Reviewed-by: Chuck Lever <chuck.lever@oracle.com>

Hrm.  On second thought....

Catching these in nfs_compare_sockaddr() will make it harder to find  
NULL pointer bugs in other parts of the code, I would think.  Instead,  
maybe you should trap these in from_local.c.  That way you document  
the quirk (as above) as well.

>> diff --git a/support/include/sockaddr.h b/support/include/sockaddr.h
>> index 732514b..9af2543 100644
>> --- a/support/include/sockaddr.h
>> +++ b/support/include/sockaddr.h
>> @@ -20,6 +20,7 @@
>> #ifndef NFS_UTILS_SOCKADDR_H
>> #define NFS_UTILS_SOCKADDR_H
>>
>> +#include <libio.h>
>> #include <stdbool.h>
>> #include <sys/socket.h>
>> #include <netinet/in.h>
>> @@ -223,6 +224,9 @@ compare_sockaddr6(__attribute__ ((unused))  
>> const struct sockaddr *sa1,
>> static inline _Bool
>> nfs_compare_sockaddr(const struct sockaddr *sa1, const struct  
>> sockaddr *sa2)
>> {
>> +	if (sa1 == NULL || sa2 == NULL)
>> +		return false;
>> +
>> 	if (sa1->sa_family == sa2->sa_family)
>> 		switch (sa1->sa_family) {
>> 		case AF_INET:
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux- 
>> nfs" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
> -- 
> Chuck Lever
> chuck[dot]lever[at]oracle[dot]com
>
>
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs"  
> in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Chuck Lever
chuck[dot]lever[at]oracle[dot]com





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

end of thread, other threads:[~2010-01-25 18:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-25 16:59 [PATCH] statd: Teach nfs_compare_sockaddr() to handle NULL arguments Steve Dickson
     [not found] ` <4B5DCDEB.60708-AfCzQyP5zfLQT0dZR+AlfA@public.gmane.org>
2010-01-25 18:05   ` Chuck Lever
2010-01-25 18:18     ` Chuck Lever
2010-01-25 18:10   ` Steve Dickson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox