netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH Resend] af_unix: dont send SCM_CREDENTIAL when dest socket is NULL
@ 2013-03-26  3:02 dingtianhong
  2013-03-26  4:38 ` Eric Dumazet
  0 siblings, 1 reply; 3+ messages in thread
From: dingtianhong @ 2013-03-26  3:02 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Li Zefan, Xinwei Hu, netdev

SCM_SCREDENTIALS should apply to write() syscalls only either source or destination
socket asserted SOCK_PASSCRED. The original implememtation in maybe_add_creds is wrong,
and breaks several LSB testcases ( i.e. /tset/LSB.os/netowkr/recvfrom/T.recvfrom).

Origionally-authored-by: Karel Srot <ksrot@redhat.com>
Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
---
 net/unix/af_unix.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 51be64f..99189fd 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -1413,8 +1413,8 @@ static void maybe_add_creds(struct sk_buff *skb, const struct socket *sock,
 	if (UNIXCB(skb).cred)
 		return;
 	if (test_bit(SOCK_PASSCRED, &sock->flags) ||
-	    !other->sk_socket ||
-	    test_bit(SOCK_PASSCRED, &other->sk_socket->flags)) {
+	    (other->sk_socket &&
+	    test_bit(SOCK_PASSCRED, &other->sk_socket->flags))) {
 		UNIXCB(skb).pid  = get_pid(task_tgid(current));
 		UNIXCB(skb).cred = get_current_cred();
 	}
-- 1.8.0

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

* Re: [PATCH Resend] af_unix: dont send SCM_CREDENTIAL when dest socket is NULL
  2013-03-26  3:02 [PATCH Resend] af_unix: dont send SCM_CREDENTIAL when dest socket is NULL dingtianhong
@ 2013-03-26  4:38 ` Eric Dumazet
  2013-03-26 16:34   ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2013-03-26  4:38 UTC (permalink / raw)
  To: dingtianhong; +Cc: David S. Miller, Eric Dumazet, Li Zefan, Xinwei Hu, netdev

On Tue, 2013-03-26 at 11:02 +0800, dingtianhong wrote:
> SCM_SCREDENTIALS should apply to write() syscalls only either source or destination
> socket asserted SOCK_PASSCRED. The original implememtation in maybe_add_creds is wrong,
> and breaks several LSB testcases ( i.e. /tset/LSB.os/netowkr/recvfrom/T.recvfrom).
> 
> Origionally-authored-by: Karel Srot <ksrot@redhat.com>
> Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
> ---
>  net/unix/af_unix.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
> index 51be64f..99189fd 100644
> --- a/net/unix/af_unix.c
> +++ b/net/unix/af_unix.c
> @@ -1413,8 +1413,8 @@ static void maybe_add_creds(struct sk_buff *skb, const struct socket *sock,
>  	if (UNIXCB(skb).cred)
>  		return;
>  	if (test_bit(SOCK_PASSCRED, &sock->flags) ||
> -	    !other->sk_socket ||
> -	    test_bit(SOCK_PASSCRED, &other->sk_socket->flags)) {
> +	    (other->sk_socket &&
> +	    test_bit(SOCK_PASSCRED, &other->sk_socket->flags))) {
>  		UNIXCB(skb).pid  = get_pid(task_tgid(current));
>  		UNIXCB(skb).cred = get_current_cred();
>  	}

Acked-by: Eric Dumazet <edumazet@google.com>

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

* Re: [PATCH Resend] af_unix: dont send SCM_CREDENTIAL when dest socket is NULL
  2013-03-26  4:38 ` Eric Dumazet
@ 2013-03-26 16:34   ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2013-03-26 16:34 UTC (permalink / raw)
  To: eric.dumazet; +Cc: dingtianhong, edumazet, lizefan, huxinwei, netdev

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Mon, 25 Mar 2013 21:38:07 -0700

> On Tue, 2013-03-26 at 11:02 +0800, dingtianhong wrote:
>> SCM_SCREDENTIALS should apply to write() syscalls only either source or destination
>> socket asserted SOCK_PASSCRED. The original implememtation in maybe_add_creds is wrong,
>> and breaks several LSB testcases ( i.e. /tset/LSB.os/netowkr/recvfrom/T.recvfrom).
>> 
>> Origionally-authored-by: Karel Srot <ksrot@redhat.com>
>> Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
>> ---
>>  net/unix/af_unix.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>> 
>> diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
>> index 51be64f..99189fd 100644
>> --- a/net/unix/af_unix.c
>> +++ b/net/unix/af_unix.c
>> @@ -1413,8 +1413,8 @@ static void maybe_add_creds(struct sk_buff *skb, const struct socket *sock,
>>  	if (UNIXCB(skb).cred)
>>  		return;
>>  	if (test_bit(SOCK_PASSCRED, &sock->flags) ||
>> -	    !other->sk_socket ||
>> -	    test_bit(SOCK_PASSCRED, &other->sk_socket->flags)) {
>> +	    (other->sk_socket &&
>> +	    test_bit(SOCK_PASSCRED, &other->sk_socket->flags))) {
>>  		UNIXCB(skb).pid  = get_pid(task_tgid(current));
>>  		UNIXCB(skb).cred = get_current_cred();
>>  	}
> 
> Acked-by: Eric Dumazet <edumazet@google.com>

Applied and queued up for -stable.

 

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

end of thread, other threads:[~2013-03-26 16:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-26  3:02 [PATCH Resend] af_unix: dont send SCM_CREDENTIAL when dest socket is NULL dingtianhong
2013-03-26  4:38 ` Eric Dumazet
2013-03-26 16:34   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).