All of lore.kernel.org
 help / color / mirror / Atom feed
* [Fix kernel crash in cipso_v4_sock_delattr ]
@ 2015-03-30 11:09 ` Maninder Singh
  0 siblings, 0 replies; 5+ messages in thread
From: Maninder Singh @ 2015-03-30 11:09 UTC (permalink / raw)
  To: Maninder Singh, paul, davem
  Cc: netdev, linux-kernel, Vaneet Narang, AJEET YADAV

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=windows-1252, Size: 2094 bytes --]


Dear All,
we found One Kernel Crash issue in cipso_v4_sock_delattr :-
As Cipso supports only inet sockets so cipso_v4_sock_delattr will crash when try to access
any other socket type.  cipso_v4_sock_delattr access sk_inet->inet_opt which may
contain not NULL but invalid address. we found this issue with netlink socket.(reproducible by trinity using sendto system call .)

Crash Logs :
[0-182.2400] [<c04c7fa4>] (cipso_v4_sock_delattr+0x0/0x74) from [<c0517b64>] (netlbl_sock_delattr+0x18/0x1c)
[0-182.2497]  r4:00000000 r3:c07872f8
[0-182.2531] [<c0517b4c>] (netlbl_sock_delattr+0x0/0x1c) from [<c027b2fc>] (smack_netlabel+0x88/0x9c)
[0-182.2622] [<c027b274>] (smack_netlabel+0x0/0x9c) from [<c027b43c>] (smack_netlabel_send+0x12c/0x144)
[0-182.2714]  r7 9ce9500 r6 7b67ef4 r5:c076f408 r4 8903dc0
[0-182.2770] [<c027b310>] (smack_netlabel_send+0x0/0x144) from [<c027b4a8>] (smack_socket_sendmsg+0x54/0x60)
[0-182.2866] [<c027b454>] (smack_socket_sendmsg+0x0/0x60) from [<c02789ec>] (security_socket_sendmsg+0x28/0x2c)
[0-182.2966] [<c02789c4>] (security_socket_sendmsg+0x0/0x2c) from [<c04343b0>] (sock_sendmsg+0x68/0xc0)
[0-182.3058] [<c0434348>] (sock_sendmsg+0x0/0xc0) from [<c04369e8>] (SyS_sendto+0xd8/0x110)
Signed-off-by: Vaneet Narang <v.narang@samsung.com>
Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
Reviewed-by : Ajeet Yadav <ajeet.y@samsung.com>
---
 net/netlabel/netlabel_kapi.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/net/netlabel/netlabel_kapi.c b/net/netlabel/netlabel_kapi.c
index 7c94aed..7a2c6f5 100755
--- a/net/netlabel/netlabel_kapi.c
+++ b/net/netlabel/netlabel_kapi.c
@@ -700,7 +700,13 @@ socket_setattr_return:
  */
 void netlbl_sock_delattr(struct sock *sk)
 {
- cipso_v4_sock_delattr(sk);
+ switch (sk->sk_family) {
+ case AF_INET:
+  cipso_v4_sock_delattr(sk);
+  break;
+ default:
+  break;
+ }
 }
 
 /**
-- 
1.7.9.5


Thanks and Regards,
Maninder Singhÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

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

* [Fix kernel crash in cipso_v4_sock_delattr ]
@ 2015-03-30 11:09 ` Maninder Singh
  0 siblings, 0 replies; 5+ messages in thread
From: Maninder Singh @ 2015-03-30 11:09 UTC (permalink / raw)
  To: Maninder Singh, paul, davem
  Cc: netdev, linux-kernel, Vaneet Narang, AJEET YADAV


Dear All,
we found One Kernel Crash issue in cipso_v4_sock_delattr :-
As Cipso supports only inet sockets so cipso_v4_sock_delattr will crash when try to access
any other socket type.  cipso_v4_sock_delattr access sk_inet->inet_opt which may
contain not NULL but invalid address. we found this issue with netlink socket.(reproducible by trinity using sendto system call .)

Crash Logs :
[0-182.2400] [<c04c7fa4>] (cipso_v4_sock_delattr+0x0/0x74) from [<c0517b64>] (netlbl_sock_delattr+0x18/0x1c)
[0-182.2497]  r4:00000000 r3:c07872f8
[0-182.2531] [<c0517b4c>] (netlbl_sock_delattr+0x0/0x1c) from [<c027b2fc>] (smack_netlabel+0x88/0x9c)
[0-182.2622] [<c027b274>] (smack_netlabel+0x0/0x9c) from [<c027b43c>] (smack_netlabel_send+0x12c/0x144)
[0-182.2714]  r7 9ce9500 r6 7b67ef4 r5:c076f408 r4 8903dc0
[0-182.2770] [<c027b310>] (smack_netlabel_send+0x0/0x144) from [<c027b4a8>] (smack_socket_sendmsg+0x54/0x60)
[0-182.2866] [<c027b454>] (smack_socket_sendmsg+0x0/0x60) from [<c02789ec>] (security_socket_sendmsg+0x28/0x2c)
[0-182.2966] [<c02789c4>] (security_socket_sendmsg+0x0/0x2c) from [<c04343b0>] (sock_sendmsg+0x68/0xc0)
[0-182.3058] [<c0434348>] (sock_sendmsg+0x0/0xc0) from [<c04369e8>] (SyS_sendto+0xd8/0x110)
Signed-off-by: Vaneet Narang <v.narang@samsung.com>
Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
Reviewed-by : Ajeet Yadav <ajeet.y@samsung.com>
---
 net/netlabel/netlabel_kapi.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/net/netlabel/netlabel_kapi.c b/net/netlabel/netlabel_kapi.c
index 7c94aed..7a2c6f5 100755
--- a/net/netlabel/netlabel_kapi.c
+++ b/net/netlabel/netlabel_kapi.c
@@ -700,7 +700,13 @@ socket_setattr_return:
  */
 void netlbl_sock_delattr(struct sock *sk)
 {
- cipso_v4_sock_delattr(sk);
+ switch (sk->sk_family) {
+ case AF_INET:
+  cipso_v4_sock_delattr(sk);
+  break;
+ default:
+  break;
+ }
 }
 
 /**
-- 
1.7.9.5


Thanks and Regards,
Maninder Singh

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

* Re: [Fix kernel crash in cipso_v4_sock_delattr ]
  2015-03-30 11:09 ` Maninder Singh
  (?)
@ 2015-03-30 11:32 ` Paul Moore
  2015-03-30 17:25   ` Casey Schaufler
  -1 siblings, 1 reply; 5+ messages in thread
From: Paul Moore @ 2015-03-30 11:32 UTC (permalink / raw)
  To: maninder1.s; +Cc: davem, netdev, linux-kernel, Vaneet Narang, AJEET YADAV

On Monday, March 30, 2015 11:09:00 AM Maninder Singh wrote:
> Dear All,
> we found One Kernel Crash issue in cipso_v4_sock_delattr :-
> As Cipso supports only inet sockets so cipso_v4_sock_delattr will crash when
> try to access any other socket type.  cipso_v4_sock_delattr access
> sk_inet->inet_opt which may contain not NULL but invalid address. we found
> this issue with netlink socket.(reproducible by trinity using sendto system
> call .) 

Hello,

First, please go read the Documentation/SubmittingPatches from the kernel 
sources; your patch needs to be resubmitted and the instructions in that file 
will show you how to do it correctly next time.

Second, this appears to only affect Smack based systems, yes?  SELinux based 
systems should have the proper checking in place to prevent this (the checks 
are handled in the LSM).  That said, it probably wouldn't hurt to add the 
extra checking to netlbl_sock_delattr().  If you properly resubmit your patch 
I'll ACK it.

-Paul

-- 
paul moore
www.paul-moore.com


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

* Re: [Fix kernel crash in cipso_v4_sock_delattr ]
  2015-03-30 11:32 ` Paul Moore
@ 2015-03-30 17:25   ` Casey Schaufler
  0 siblings, 0 replies; 5+ messages in thread
From: Casey Schaufler @ 2015-03-30 17:25 UTC (permalink / raw)
  To: Paul Moore, maninder1.s
  Cc: davem, netdev, linux-kernel, Vaneet Narang, AJEET YADAV, Casey Schaufler

On 3/30/2015 4:32 AM, Paul Moore wrote:
> On Monday, March 30, 2015 11:09:00 AM Maninder Singh wrote:
>> Dear All,
>> we found One Kernel Crash issue in cipso_v4_sock_delattr :-
>> As Cipso supports only inet sockets so cipso_v4_sock_delattr will crash when
>> try to access any other socket type.  cipso_v4_sock_delattr access
>> sk_inet->inet_opt which may contain not NULL but invalid address. we found
>> this issue with netlink socket.(reproducible by trinity using sendto system
>> call .) 
> Hello,
>
> First, please go read the Documentation/SubmittingPatches from the kernel 
> sources; your patch needs to be resubmitted and the instructions in that file 
> will show you how to do it correctly next time.
>
> Second, this appears to only affect Smack based systems, yes?  SELinux based 
> systems should have the proper checking in place to prevent this (the checks 
> are handled in the LSM).

This looks like a problem that was fixed some time ago.
The current Smack code clearly checks for this. What kernel
version are you testing against?

> That said, it probably wouldn't hurt to add the 
> extra checking to netlbl_sock_delattr().  If you properly resubmit your patch 
> I'll ACK it.
>
> -Paul
>


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

* Re: [Fix kernel crash in cipso_v4_sock_delattr ]
  2015-03-31  5:09 Maninder Singh
@ 2015-03-31 17:52 ` Casey Schaufler
  0 siblings, 0 replies; 5+ messages in thread
From: Casey Schaufler @ 2015-03-31 17:52 UTC (permalink / raw)
  To: maninder1.s, Paul Moore
  Cc: davem, netdev, linux-kernel, Vaneet Narang, AJEET YADAV, Casey Schaufler

On 3/30/2015 10:09 PM, Maninder Singh wrote:
> We are currently using 3.10.58 kernel and  we are facing this issue for samck enabled system.
> and as we can check in other APIs like netlbl_sock_getattr and netlbl_conn_setattr have this preventive check so we added this check for netlbl_sock_delattr also.
>
> And regarding patch re-submission, actually we have run checkpatch.pl before submission(successfull)  But when we submit the patch our editor changes tabs into space, we will resubmitt the patch ASAP.

Further review shows that the Smack code in 3.10.72 (I don't believe it changed
after 3.10.58) already checks for the address family being AF_INET. This would indicate
that the netlink code is sending garbage to security_socket_sendmsg().

Can you provide a more specific test case? I would like to see if this problem is
present in newer kernels.

>
> Maninder Singh
> ------- Original Message -------
> Sender : Casey Schaufler<casey@schaufler-ca.com>
> Date : Mar 31, 2015 02:25 (GMT+09:00)
> Title : Re: [Fix kernel crash in cipso_v4_sock_delattr ]
>
> On 3/30/2015 4:32 AM, Paul Moore wrote:
>> On Monday, March 30, 2015 11:09:00 AM Maninder Singh wrote:
>>> Dear All,
>>> we found One Kernel Crash issue in cipso_v4_sock_delattr :-
>>> As Cipso supports only inet sockets so cipso_v4_sock_delattr will crash when
>>> try to access any other socket type.  cipso_v4_sock_delattr access
>>> sk_inet->inet_opt which may contain not NULL but invalid address. we found
>>> this issue with netlink socket.(reproducible by trinity using sendto system
>>> call .) 
>> Hello,
>>
>> First, please go read the Documentation/SubmittingPatches from the kernel 
>> sources; your patch needs to be resubmitted and the instructions in that file 
>> will show you how to do it correctly next time.
>>
>> Second, this appears to only affect Smack based systems, yes?  SELinux based 
>> systems should have the proper checking in place to prevent this (the checks 
>> are handled in the LSM).
> This looks like a problem that was fixed some time ago.
> The current Smack code clearly checks for this. What kernel
> version are you testing against?
>
>> That said, it probably wouldn't hurt to add the 
>> extra checking to netlbl_sock_delattr().  If you properly resubmit your patch 
>> I'll ACK it.
>>
>> -Paul
>> N‹§²æìr¸›yúèšØb²X¬¶Ç§vØ^–)Þº{.nÇ+‰·¥Š{±‘êçzX§¶\x17›¡Ü¨}©ž²Æ zÚ&j:+v‰¨¾\a«‘êçzZ+€Ê+zf£¢·hšˆ§~†­†Ûiÿûàz¹\x1e®w¥¢¸?™¨è­Ú&¢)ߢ^[f”ù^jÇ«y§m…á@A«a¶Ú\x7fÿ\f0¶ìh®\x0få’i\x7f


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

end of thread, other threads:[~2015-03-31 17:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-30 11:09 [Fix kernel crash in cipso_v4_sock_delattr ] Maninder Singh
2015-03-30 11:09 ` Maninder Singh
2015-03-30 11:32 ` Paul Moore
2015-03-30 17:25   ` Casey Schaufler
2015-03-31  5:09 Maninder Singh
2015-03-31 17:52 ` Casey Schaufler

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.