All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maninder Singh <maninder1.s@samsung.com>
To: Casey Schaufler <casey@schaufler-ca.com>,
	Maninder Singh <maninder1.s@samsung.com>,
	Paul Moore <paul@paul-moore.com>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Vaneet Narang <v.narang@samsung.com>,
	AJEET YADAV <ajeet.y@samsung.com>
Subject: Re: Re: [Fix kernel crash in cipso_v4_sock_delattr ]
Date: Wed, 01 Apr 2015 13:07:20 +0000 (GMT)	[thread overview]
Message-ID: <1233624800.241631427893638492.JavaMail.weblogic@epmlwas09b> (raw)

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

We have run trinity tool on smack enable system. like below:-

#./trinity -c sendto --dangerous
After some time we are able to crash the kernel:-

[<c04c8084>] (cipso_v4_sock_delattr+0x0/0x74) from [<c0517c44>] (netlbl_sock_delattr+0x18/0x1c)
 r4:00000000 r3:c07872f8
[<c0517c2c>] (netlbl_sock_delattr+0x0/0x1c) from [<c027b3e0>] (smack_netlabel+0x88/0x9c)
[<c027b358>] (smack_netlabel+0x0/0x9c) from [<c027b520>] (smack_netlabel_send+0x12c/0x144)
 r7:d9cee3c0 r6:d7b01ef4 r5:c076f408 r4:d88c84c0
[<c027b3f4>] (smack_netlabel_send+0x0/0x144) from [<c027b58c>] (smack_socket_sendmsg+0x54/0x60)
[<c027b538>] (smack_socket_sendmsg+0x0/0x60) from [<c0278ad0>] (security_socket_sendmsg+0x28/0x2c)
[<c0278aa8>] (security_socket_sendmsg+0x0/0x2c) from [<c0434490>] (sock_sendmsg+0x68/0xc0)
[<c0434428>] (sock_sendmsg+0x0/0xc0) from [<c0436ac8>] (SyS_sendto+0xd8/0x110)
 r7:01400118 r6:0000007f r5:da308a00 r4:c076f408
[<c04369f0>] (SyS_sendto+0x0/0x110) from [<c0012280>] (ret_fast_syscall+0x0/0x48)
Code: e5903200 e1a04000 e3530000 089da818 (e5d33016)
[SELP] while loop ... please attach T32...

And after further debugging we find this crash always come with Netlink socket.
And except thi API "netlbl_sock_delattr"  all other related Netlabel APIs have check to validate socket family.
Thats why we added socket family check for this API "netlbl_sock_delattr" and resolves our issue.

Thanks 
Maninder Singh

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
> 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Ç+‰·Ÿ®‰­†+%ŠËÿ±éݶ\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¥

WARNING: multiple messages have this Message-ID (diff)
From: Maninder Singh <maninder1.s@samsung.com>
To: Casey Schaufler <casey@schaufler-ca.com>,
	Maninder Singh <maninder1.s@samsung.com>,
	Paul Moore <paul@paul-moore.com>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Vaneet Narang <v.narang@samsung.com>,
	AJEET YADAV <ajeet.y@samsung.com>
Subject: Re: Re: [Fix kernel crash in cipso_v4_sock_delattr ]
Date: Wed, 01 Apr 2015 13:07:20 +0000 (GMT)	[thread overview]
Message-ID: <1233624800.241631427893638492.JavaMail.weblogic@epmlwas09b> (raw)

We have run trinity tool on smack enable system. like below:-

#./trinity -c sendto --dangerous
After some time we are able to crash the kernel:-

[<c04c8084>] (cipso_v4_sock_delattr+0x0/0x74) from [<c0517c44>] (netlbl_sock_delattr+0x18/0x1c)
 r4:00000000 r3:c07872f8
[<c0517c2c>] (netlbl_sock_delattr+0x0/0x1c) from [<c027b3e0>] (smack_netlabel+0x88/0x9c)
[<c027b358>] (smack_netlabel+0x0/0x9c) from [<c027b520>] (smack_netlabel_send+0x12c/0x144)
 r7:d9cee3c0 r6:d7b01ef4 r5:c076f408 r4:d88c84c0
[<c027b3f4>] (smack_netlabel_send+0x0/0x144) from [<c027b58c>] (smack_socket_sendmsg+0x54/0x60)
[<c027b538>] (smack_socket_sendmsg+0x0/0x60) from [<c0278ad0>] (security_socket_sendmsg+0x28/0x2c)
[<c0278aa8>] (security_socket_sendmsg+0x0/0x2c) from [<c0434490>] (sock_sendmsg+0x68/0xc0)
[<c0434428>] (sock_sendmsg+0x0/0xc0) from [<c0436ac8>] (SyS_sendto+0xd8/0x110)
 r7:01400118 r6:0000007f r5:da308a00 r4:c076f408
[<c04369f0>] (SyS_sendto+0x0/0x110) from [<c0012280>] (ret_fast_syscall+0x0/0x48)
Code: e5903200 e1a04000 e3530000 089da818 (e5d33016)
[SELP] while loop ... please attach T32...

And after further debugging we find this crash always come with Netlink socket.
And except thi API "netlbl_sock_delattr"  all other related Netlabel APIs have check to validate socket family.
Thats why we added socket family check for this API "netlbl_sock_delattr" and resolves our issue.

Thanks 
Maninder Singh

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
> 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

             reply	other threads:[~2015-04-01 13:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-01 13:07 Maninder Singh [this message]
2015-04-01 13:07 ` Re: [Fix kernel crash in cipso_v4_sock_delattr ] Maninder Singh
  -- strict thread matches above, loose matches on Subject: below --
2015-03-31  5:09 Maninder Singh
2015-03-31  5:09 ` Maninder Singh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1233624800.241631427893638492.JavaMail.weblogic@epmlwas09b \
    --to=maninder1.s@samsung.com \
    --cc=ajeet.y@samsung.com \
    --cc=casey@schaufler-ca.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=paul@paul-moore.com \
    --cc=v.narang@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.