* Leaking path or inconsistency LSM checking observed in fs/net
@ 2018-09-25 17:27 ` Tong Zhang
0 siblings, 0 replies; 13+ messages in thread
From: Tong Zhang @ 2018-09-25 17:27 UTC (permalink / raw)
To: mark, jlbec, keescook, davem, viro, dvlasenk, ccaulfie, teigland
Cc: linux-kernel, ocfs2-devel, cluster-devel, linux-security-module,
Wenbo Shen
Kernel Version: 4.18.5
Problem Description:
We found several leaking path or inconsistency LSM design issue in fs/net.
Currently we can only observe sock creation from kernel and all bind/listen/connect are not sent to LSM.
So, we think that those net/socket related stuff should all go through LSM check and being audited
even it is not a user thread or process.
Here’s an example where we have a check:
in fs/ocfs2/cluster/tcp.c:2035 o2net_open_listening_sock() a sock is created using sock_create(),
where a LSM check security_socket_create is called(net/socket.c:1242)
And where we don’t have a check
fs/ocfs2/cluster/tcp.c:2052 bind
fs/ocfs2/cluster/tcp.c:2059 listen
fs/dlm/lowcomms.c:1264 bind
fs/dlm/lowcomms.c:1278 listen
fs/dlm/lowcomms.c:1354 listen
several places that use kernel_bind/kernel_listen/kernel_connect
net/socket.c:3231 kernel_bind
net/socket.c:3237 kernel_listen
net/socket.c:3286 kernel_connect
- Tong
^ permalink raw reply [flat|nested] 13+ messages in thread
* Leaking path or inconsistency LSM checking observed in fs/net
@ 2018-09-25 17:27 ` Tong Zhang
0 siblings, 0 replies; 13+ messages in thread
From: Tong Zhang @ 2018-09-25 17:27 UTC (permalink / raw)
To: linux-security-module
Kernel Version: 4.18.5
Problem Description:
We found several leaking path or inconsistency LSM design issue in fs/net.
Currently we can only observe sock creation from kernel and all bind/listen/connect are not sent to LSM.
So, we think that those net/socket related stuff should all go through LSM check and being audited
even it is not a user thread or process.
Here?s an example where we have a check:
in fs/ocfs2/cluster/tcp.c:2035 o2net_open_listening_sock() a sock is created using sock_create(),
where a LSM check security_socket_create is called(net/socket.c:1242)
And where we don?t have a check
fs/ocfs2/cluster/tcp.c:2052 bind
fs/ocfs2/cluster/tcp.c:2059 listen
fs/dlm/lowcomms.c:1264 bind
fs/dlm/lowcomms.c:1278 listen
fs/dlm/lowcomms.c:1354 listen
several places that use kernel_bind/kernel_listen/kernel_connect
net/socket.c:3231 kernel_bind
net/socket.c:3237 kernel_listen
net/socket.c:3286 kernel_connect
- Tong
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Cluster-devel] Leaking path or inconsistency LSM checking observed in fs/net
@ 2018-09-25 17:27 ` Tong Zhang
0 siblings, 0 replies; 13+ messages in thread
From: Tong Zhang @ 2018-09-25 17:27 UTC (permalink / raw)
To: cluster-devel.redhat.com
Kernel Version: 4.18.5
Problem Description:
We found several leaking path or inconsistency LSM design issue in fs/net.
Currently we can only observe sock creation from kernel and all bind/listen/connect are not sent to LSM.
So, we think that those net/socket related stuff should all go through LSM check and being audited
even it is not a user thread or process.
Here?s an example where we have a check:
in fs/ocfs2/cluster/tcp.c:2035 o2net_open_listening_sock() a sock is created using sock_create(),
where a LSM check security_socket_create is called(net/socket.c:1242)
And where we don?t have a check
fs/ocfs2/cluster/tcp.c:2052 bind
fs/ocfs2/cluster/tcp.c:2059 listen
fs/dlm/lowcomms.c:1264 bind
fs/dlm/lowcomms.c:1278 listen
fs/dlm/lowcomms.c:1354 listen
several places that use kernel_bind/kernel_listen/kernel_connect
net/socket.c:3231 kernel_bind
net/socket.c:3237 kernel_listen
net/socket.c:3286 kernel_connect
- Tong
^ permalink raw reply [flat|nested] 13+ messages in thread
* Leaking path or inconsistency LSM checking observed in fs/net
2018-09-25 17:27 ` Tong Zhang
(?)
(?)
@ 2018-09-25 18:44 ` Stephen Smalley
-1 siblings, 0 replies; 13+ messages in thread
From: Stephen Smalley @ 2018-09-25 18:44 UTC (permalink / raw)
To: Tong Zhang, mark, jlbec, keescook, davem, viro, dvlasenk,
ccaulfie, teigland
Cc: linux-kernel, ocfs2-devel, cluster-devel, linux-security-module,
Wenbo Shen, Paul Moore
On 09/25/2018 01:27 PM, Tong Zhang wrote:
> Kernel Version: 4.18.5
>
> Problem Description:
>
> We found several leaking path or inconsistency LSM design issue in fs/net.
>
> Currently we can only observe sock creation from kernel and all bind/listen/connect are not sent to LSM.
> So, we think that those net/socket related stuff should all go through LSM check and being audited
> even it is not a user thread or process.
>
>
> Here’s an example where we have a check:
> in fs/ocfs2/cluster/tcp.c:2035 o2net_open_listening_sock() a sock is created using sock_create(),
> where a LSM check security_socket_create is called(net/socket.c:1242)
>
>
> And where we don’t have a check
>
> fs/ocfs2/cluster/tcp.c:2052 bind
> fs/ocfs2/cluster/tcp.c:2059 listen
>
> fs/dlm/lowcomms.c:1264 bind
> fs/dlm/lowcomms.c:1278 listen
> fs/dlm/lowcomms.c:1354 listen
>
> several places that use kernel_bind/kernel_listen/kernel_connect
>
> net/socket.c:3231 kernel_bind
> net/socket.c:3237 kernel_listen
> net/socket.c:3286 kernel_connect
That's intentional. LSM isn't trying to mediate kernel-internal
operations, and we do not want to apply permission checks against the
credentials of the current userspace process for such operations. ocfs2
should likely be using sock_create_kern.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Leaking path or inconsistency LSM checking observed in fs/net
@ 2018-09-25 18:44 ` Stephen Smalley
0 siblings, 0 replies; 13+ messages in thread
From: Stephen Smalley @ 2018-09-25 18:44 UTC (permalink / raw)
To: linux-security-module
On 09/25/2018 01:27 PM, Tong Zhang wrote:
> Kernel Version: 4.18.5
>
> Problem Description:
>
> We found several leaking path or inconsistency LSM design issue in fs/net.
>
> Currently we can only observe sock creation from kernel and all bind/listen/connect are not sent to LSM.
> So, we think that those net/socket related stuff should all go through LSM check and being audited
> even it is not a user thread or process.
>
>
> Here?s an example where we have a check:
> in fs/ocfs2/cluster/tcp.c:2035 o2net_open_listening_sock() a sock is created using sock_create(),
> where a LSM check security_socket_create is called(net/socket.c:1242)
>
>
> And where we don?t have a check
>
> fs/ocfs2/cluster/tcp.c:2052 bind
> fs/ocfs2/cluster/tcp.c:2059 listen
>
> fs/dlm/lowcomms.c:1264 bind
> fs/dlm/lowcomms.c:1278 listen
> fs/dlm/lowcomms.c:1354 listen
>
> several places that use kernel_bind/kernel_listen/kernel_connect
>
> net/socket.c:3231 kernel_bind
> net/socket.c:3237 kernel_listen
> net/socket.c:3286 kernel_connect
That's intentional. LSM isn't trying to mediate kernel-internal
operations, and we do not want to apply permission checks against the
credentials of the current userspace process for such operations. ocfs2
should likely be using sock_create_kern.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Ocfs2-devel] Leaking path or inconsistency LSM checking observed in fs/net
@ 2018-09-25 18:44 ` Stephen Smalley
0 siblings, 0 replies; 13+ messages in thread
From: Stephen Smalley @ 2018-09-25 18:44 UTC (permalink / raw)
To: linux-security-module
On 09/25/2018 01:27 PM, Tong Zhang wrote:
> Kernel Version: 4.18.5
>
> Problem Description:
>
> We found several leaking path or inconsistency LSM design issue in fs/net.
>
> Currently we can only observe sock creation from kernel and all bind/listen/connect are not sent to LSM.
> So, we think that those net/socket related stuff should all go through LSM check and being audited
> even it is not a user thread or process.
>
>
> Here?s an example where we have a check:
> in fs/ocfs2/cluster/tcp.c:2035 o2net_open_listening_sock() a sock is created using sock_create(),
> where a LSM check security_socket_create is called(net/socket.c:1242)
>
>
> And where we don?t have a check
>
> fs/ocfs2/cluster/tcp.c:2052 bind
> fs/ocfs2/cluster/tcp.c:2059 listen
>
> fs/dlm/lowcomms.c:1264 bind
> fs/dlm/lowcomms.c:1278 listen
> fs/dlm/lowcomms.c:1354 listen
>
> several places that use kernel_bind/kernel_listen/kernel_connect
>
> net/socket.c:3231 kernel_bind
> net/socket.c:3237 kernel_listen
> net/socket.c:3286 kernel_connect
That's intentional. LSM isn't trying to mediate kernel-internal
operations, and we do not want to apply permission checks against the
credentials of the current userspace process for such operations. ocfs2
should likely be using sock_create_kern.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Cluster-devel] Leaking path or inconsistency LSM checking observed in fs/net
@ 2018-09-25 18:44 ` Stephen Smalley
0 siblings, 0 replies; 13+ messages in thread
From: Stephen Smalley @ 2018-09-25 18:44 UTC (permalink / raw)
To: cluster-devel.redhat.com
On 09/25/2018 01:27 PM, Tong Zhang wrote:
> Kernel Version: 4.18.5
>
> Problem Description:
>
> We found several leaking path or inconsistency LSM design issue in fs/net.
>
> Currently we can only observe sock creation from kernel and all bind/listen/connect are not sent to LSM.
> So, we think that those net/socket related stuff should all go through LSM check and being audited
> even it is not a user thread or process.
>
>
> Here?s an example where we have a check:
> in fs/ocfs2/cluster/tcp.c:2035 o2net_open_listening_sock() a sock is created using sock_create(),
> where a LSM check security_socket_create is called(net/socket.c:1242)
>
>
> And where we don?t have a check
>
> fs/ocfs2/cluster/tcp.c:2052 bind
> fs/ocfs2/cluster/tcp.c:2059 listen
>
> fs/dlm/lowcomms.c:1264 bind
> fs/dlm/lowcomms.c:1278 listen
> fs/dlm/lowcomms.c:1354 listen
>
> several places that use kernel_bind/kernel_listen/kernel_connect
>
> net/socket.c:3231 kernel_bind
> net/socket.c:3237 kernel_listen
> net/socket.c:3286 kernel_connect
That's intentional. LSM isn't trying to mediate kernel-internal
operations, and we do not want to apply permission checks against the
credentials of the current userspace process for such operations. ocfs2
should likely be using sock_create_kern.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Leaking path or inconsistency LSM checking observed in fs/net
2018-09-25 18:44 ` Stephen Smalley
(?)
@ 2018-09-25 23:36 ` TongZhang
-1 siblings, 0 replies; 13+ messages in thread
From: TongZhang @ 2018-09-25 23:36 UTC (permalink / raw)
To: Stephen Smalley
Cc: mark, jlbec, keescook, davem, viro, dvlasenk, ccaulfie, teigland,
LKML, ocfs2-devel, cluster-devel, linux-security-module,
Wenbo Shen, Paul Moore
ocfs2 is using sock_create instead of sock_create_kern in kernel v4.18.5.
fs/ocfs2/cluster/tcp.c: 1636
https://elixir.bootlin.com/linux/v4.18.5/source/fs/ocfs2/cluster/tcp.c#L1636
>ret = sock_create(PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock);
fs/ocfs2/cluster/tcp.c: 2035
https://elixir.bootlin.com/linux/v4.18.5/source/fs/ocfs2/cluster/tcp.c#L2035
>ret = sock_create(PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock);
> On Sep 25, 2018, at 2:44 PM, Stephen Smalley <sds@tycho.nsa.gov> wrote:
>
> On 09/25/2018 01:27 PM, Tong Zhang wrote:
>> Kernel Version: 4.18.5
>> Problem Description:
>> We found several leaking path or inconsistency LSM design issue in fs/net.
>> Currently we can only observe sock creation from kernel and all bind/listen/connect are not sent to LSM.
>> So, we think that those net/socket related stuff should all go through LSM check and being audited
>> even it is not a user thread or process.
>> Here’s an example where we have a check:
>> in fs/ocfs2/cluster/tcp.c:2035 o2net_open_listening_sock() a sock is created using sock_create(),
>> where a LSM check security_socket_create is called(net/socket.c:1242)
>> And where we don’t have a check
>> fs/ocfs2/cluster/tcp.c:2052 bind
>> fs/ocfs2/cluster/tcp.c:2059 listen
>> fs/dlm/lowcomms.c:1264 bind
>> fs/dlm/lowcomms.c:1278 listen
>> fs/dlm/lowcomms.c:1354 listen
>> several places that use kernel_bind/kernel_listen/kernel_connect
>> net/socket.c:3231 kernel_bind
>> net/socket.c:3237 kernel_listen
>> net/socket.c:3286 kernel_connect
>
> That's intentional. LSM isn't trying to mediate kernel-internal operations, and we do not want to apply permission checks against the credentials of the current userspace process for such operations. ocfs2 should likely be using sock_create_kern.
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Leaking path or inconsistency LSM checking observed in fs/net
@ 2018-09-25 23:36 ` TongZhang
0 siblings, 0 replies; 13+ messages in thread
From: TongZhang @ 2018-09-25 23:36 UTC (permalink / raw)
To: linux-security-module
ocfs2 is using sock_create instead of sock_create_kern in kernel v4.18.5.
fs/ocfs2/cluster/tcp.c: 1636
https://elixir.bootlin.com/linux/v4.18.5/source/fs/ocfs2/cluster/tcp.c#L1636
>ret = sock_create(PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock);
fs/ocfs2/cluster/tcp.c: 2035
https://elixir.bootlin.com/linux/v4.18.5/source/fs/ocfs2/cluster/tcp.c#L2035
>ret = sock_create(PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock);
> On Sep 25, 2018, at 2:44 PM, Stephen Smalley <sds@tycho.nsa.gov> wrote:
>
> On 09/25/2018 01:27 PM, Tong Zhang wrote:
>> Kernel Version: 4.18.5
>> Problem Description:
>> We found several leaking path or inconsistency LSM design issue in fs/net.
>> Currently we can only observe sock creation from kernel and all bind/listen/connect are not sent to LSM.
>> So, we think that those net/socket related stuff should all go through LSM check and being audited
>> even it is not a user thread or process.
>> Here?s an example where we have a check:
>> in fs/ocfs2/cluster/tcp.c:2035 o2net_open_listening_sock() a sock is created using sock_create(),
>> where a LSM check security_socket_create is called(net/socket.c:1242)
>> And where we don?t have a check
>> fs/ocfs2/cluster/tcp.c:2052 bind
>> fs/ocfs2/cluster/tcp.c:2059 listen
>> fs/dlm/lowcomms.c:1264 bind
>> fs/dlm/lowcomms.c:1278 listen
>> fs/dlm/lowcomms.c:1354 listen
>> several places that use kernel_bind/kernel_listen/kernel_connect
>> net/socket.c:3231 kernel_bind
>> net/socket.c:3237 kernel_listen
>> net/socket.c:3286 kernel_connect
>
> That's intentional. LSM isn't trying to mediate kernel-internal operations, and we do not want to apply permission checks against the credentials of the current userspace process for such operations. ocfs2 should likely be using sock_create_kern.
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Cluster-devel] Leaking path or inconsistency LSM checking observed in fs/net
@ 2018-09-25 23:36 ` TongZhang
0 siblings, 0 replies; 13+ messages in thread
From: TongZhang @ 2018-09-25 23:36 UTC (permalink / raw)
To: cluster-devel.redhat.com
ocfs2 is using sock_create instead of sock_create_kern in kernel v4.18.5.
fs/ocfs2/cluster/tcp.c: 1636
https://elixir.bootlin.com/linux/v4.18.5/source/fs/ocfs2/cluster/tcp.c#L1636
>ret = sock_create(PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock);
fs/ocfs2/cluster/tcp.c: 2035
https://elixir.bootlin.com/linux/v4.18.5/source/fs/ocfs2/cluster/tcp.c#L2035
>ret = sock_create(PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock);
> On Sep 25, 2018, at 2:44 PM, Stephen Smalley <sds@tycho.nsa.gov> wrote:
>
> On 09/25/2018 01:27 PM, Tong Zhang wrote:
>> Kernel Version: 4.18.5
>> Problem Description:
>> We found several leaking path or inconsistency LSM design issue in fs/net.
>> Currently we can only observe sock creation from kernel and all bind/listen/connect are not sent to LSM.
>> So, we think that those net/socket related stuff should all go through LSM check and being audited
>> even it is not a user thread or process.
>> Here?s an example where we have a check:
>> in fs/ocfs2/cluster/tcp.c:2035 o2net_open_listening_sock() a sock is created using sock_create(),
>> where a LSM check security_socket_create is called(net/socket.c:1242)
>> And where we don?t have a check
>> fs/ocfs2/cluster/tcp.c:2052 bind
>> fs/ocfs2/cluster/tcp.c:2059 listen
>> fs/dlm/lowcomms.c:1264 bind
>> fs/dlm/lowcomms.c:1278 listen
>> fs/dlm/lowcomms.c:1354 listen
>> several places that use kernel_bind/kernel_listen/kernel_connect
>> net/socket.c:3231 kernel_bind
>> net/socket.c:3237 kernel_listen
>> net/socket.c:3286 kernel_connect
>
> That's intentional. LSM isn't trying to mediate kernel-internal operations, and we do not want to apply permission checks against the credentials of the current userspace process for such operations. ocfs2 should likely be using sock_create_kern.
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Leaking path or inconsistency LSM checking observed in fs/net
2018-09-25 23:36 ` TongZhang
(?)
@ 2018-09-26 13:09 ` Stephen Smalley
-1 siblings, 0 replies; 13+ messages in thread
From: Stephen Smalley @ 2018-09-26 13:09 UTC (permalink / raw)
To: TongZhang
Cc: keescook, davem, dvlasenk, ccaulfie, teigland, LKML, ocfs2-devel,
cluster-devel, linux-security-module, Wenbo Shen, Paul Moore
On 09/25/2018 07:36 PM, TongZhang wrote:
> ocfs2 is using sock_create instead of sock_create_kern in kernel v4.18.5.
>
> fs/ocfs2/cluster/tcp.c: 1636
> https://elixir.bootlin.com/linux/v4.18.5/source/fs/ocfs2/cluster/tcp.c#L1636
>> ret = sock_create(PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock);
>
> fs/ocfs2/cluster/tcp.c: 2035
> https://elixir.bootlin.com/linux/v4.18.5/source/fs/ocfs2/cluster/tcp.c#L2035
>> ret = sock_create(PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock);
Yes, I think that's the real bug here. Unless the socket is in fact
exposed for direct use by userspace, it ought to be using
sock_create_kern() or similar. I would suggest that you verify that the
socket is never returned to userspace, and then submit a patch switching
the code to using sock_create_kern().
>
>
>> On Sep 25, 2018, at 2:44 PM, Stephen Smalley <sds@tycho.nsa.gov> wrote:
>>
>> On 09/25/2018 01:27 PM, Tong Zhang wrote:
>>> Kernel Version: 4.18.5
>>> Problem Description:
>>> We found several leaking path or inconsistency LSM design issue in fs/net.
>>> Currently we can only observe sock creation from kernel and all bind/listen/connect are not sent to LSM.
>>> So, we think that those net/socket related stuff should all go through LSM check and being audited
>>> even it is not a user thread or process.
>>> Here’s an example where we have a check:
>>> in fs/ocfs2/cluster/tcp.c:2035 o2net_open_listening_sock() a sock is created using sock_create(),
>>> where a LSM check security_socket_create is called(net/socket.c:1242)
>>> And where we don’t have a check
>>> fs/ocfs2/cluster/tcp.c:2052 bind
>>> fs/ocfs2/cluster/tcp.c:2059 listen
>>> fs/dlm/lowcomms.c:1264 bind
>>> fs/dlm/lowcomms.c:1278 listen
>>> fs/dlm/lowcomms.c:1354 listen
>>> several places that use kernel_bind/kernel_listen/kernel_connect
>>> net/socket.c:3231 kernel_bind
>>> net/socket.c:3237 kernel_listen
>>> net/socket.c:3286 kernel_connect
>>
>> That's intentional. LSM isn't trying to mediate kernel-internal operations, and we do not want to apply permission checks against the credentials of the current userspace process for such operations. ocfs2 should likely be using sock_create_kern.
>>
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Leaking path or inconsistency LSM checking observed in fs/net
@ 2018-09-26 13:09 ` Stephen Smalley
0 siblings, 0 replies; 13+ messages in thread
From: Stephen Smalley @ 2018-09-26 13:09 UTC (permalink / raw)
To: linux-security-module
On 09/25/2018 07:36 PM, TongZhang wrote:
> ocfs2 is using sock_create instead of sock_create_kern in kernel v4.18.5.
>
> fs/ocfs2/cluster/tcp.c: 1636
> https://elixir.bootlin.com/linux/v4.18.5/source/fs/ocfs2/cluster/tcp.c#L1636
>> ret = sock_create(PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock);
>
> fs/ocfs2/cluster/tcp.c: 2035
> https://elixir.bootlin.com/linux/v4.18.5/source/fs/ocfs2/cluster/tcp.c#L2035
>> ret = sock_create(PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock);
Yes, I think that's the real bug here. Unless the socket is in fact
exposed for direct use by userspace, it ought to be using
sock_create_kern() or similar. I would suggest that you verify that the
socket is never returned to userspace, and then submit a patch switching
the code to using sock_create_kern().
>
>
>> On Sep 25, 2018, at 2:44 PM, Stephen Smalley <sds@tycho.nsa.gov> wrote:
>>
>> On 09/25/2018 01:27 PM, Tong Zhang wrote:
>>> Kernel Version: 4.18.5
>>> Problem Description:
>>> We found several leaking path or inconsistency LSM design issue in fs/net.
>>> Currently we can only observe sock creation from kernel and all bind/listen/connect are not sent to LSM.
>>> So, we think that those net/socket related stuff should all go through LSM check and being audited
>>> even it is not a user thread or process.
>>> Here?s an example where we have a check:
>>> in fs/ocfs2/cluster/tcp.c:2035 o2net_open_listening_sock() a sock is created using sock_create(),
>>> where a LSM check security_socket_create is called(net/socket.c:1242)
>>> And where we don?t have a check
>>> fs/ocfs2/cluster/tcp.c:2052 bind
>>> fs/ocfs2/cluster/tcp.c:2059 listen
>>> fs/dlm/lowcomms.c:1264 bind
>>> fs/dlm/lowcomms.c:1278 listen
>>> fs/dlm/lowcomms.c:1354 listen
>>> several places that use kernel_bind/kernel_listen/kernel_connect
>>> net/socket.c:3231 kernel_bind
>>> net/socket.c:3237 kernel_listen
>>> net/socket.c:3286 kernel_connect
>>
>> That's intentional. LSM isn't trying to mediate kernel-internal operations, and we do not want to apply permission checks against the credentials of the current userspace process for such operations. ocfs2 should likely be using sock_create_kern.
>>
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Cluster-devel] Leaking path or inconsistency LSM checking observed in fs/net
@ 2018-09-26 13:09 ` Stephen Smalley
0 siblings, 0 replies; 13+ messages in thread
From: Stephen Smalley @ 2018-09-26 13:09 UTC (permalink / raw)
To: cluster-devel.redhat.com
On 09/25/2018 07:36 PM, TongZhang wrote:
> ocfs2 is using sock_create instead of sock_create_kern in kernel v4.18.5.
>
> fs/ocfs2/cluster/tcp.c: 1636
> https://elixir.bootlin.com/linux/v4.18.5/source/fs/ocfs2/cluster/tcp.c#L1636
>> ret = sock_create(PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock);
>
> fs/ocfs2/cluster/tcp.c: 2035
> https://elixir.bootlin.com/linux/v4.18.5/source/fs/ocfs2/cluster/tcp.c#L2035
>> ret = sock_create(PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock);
Yes, I think that's the real bug here. Unless the socket is in fact
exposed for direct use by userspace, it ought to be using
sock_create_kern() or similar. I would suggest that you verify that the
socket is never returned to userspace, and then submit a patch switching
the code to using sock_create_kern().
>
>
>> On Sep 25, 2018, at 2:44 PM, Stephen Smalley <sds@tycho.nsa.gov> wrote:
>>
>> On 09/25/2018 01:27 PM, Tong Zhang wrote:
>>> Kernel Version: 4.18.5
>>> Problem Description:
>>> We found several leaking path or inconsistency LSM design issue in fs/net.
>>> Currently we can only observe sock creation from kernel and all bind/listen/connect are not sent to LSM.
>>> So, we think that those net/socket related stuff should all go through LSM check and being audited
>>> even it is not a user thread or process.
>>> Here?s an example where we have a check:
>>> in fs/ocfs2/cluster/tcp.c:2035 o2net_open_listening_sock() a sock is created using sock_create(),
>>> where a LSM check security_socket_create is called(net/socket.c:1242)
>>> And where we don?t have a check
>>> fs/ocfs2/cluster/tcp.c:2052 bind
>>> fs/ocfs2/cluster/tcp.c:2059 listen
>>> fs/dlm/lowcomms.c:1264 bind
>>> fs/dlm/lowcomms.c:1278 listen
>>> fs/dlm/lowcomms.c:1354 listen
>>> several places that use kernel_bind/kernel_listen/kernel_connect
>>> net/socket.c:3231 kernel_bind
>>> net/socket.c:3237 kernel_listen
>>> net/socket.c:3286 kernel_connect
>>
>> That's intentional. LSM isn't trying to mediate kernel-internal operations, and we do not want to apply permission checks against the credentials of the current userspace process for such operations. ocfs2 should likely be using sock_create_kern.
>>
>
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2018-09-26 13:09 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-25 17:27 Leaking path or inconsistency LSM checking observed in fs/net Tong Zhang
2018-09-25 17:27 ` [Cluster-devel] " Tong Zhang
2018-09-25 17:27 ` Tong Zhang
2018-09-25 18:44 ` Stephen Smalley
2018-09-25 18:44 ` [Cluster-devel] " Stephen Smalley
2018-09-25 18:44 ` [Ocfs2-devel] " Stephen Smalley
2018-09-25 18:44 ` Stephen Smalley
2018-09-25 23:36 ` TongZhang
2018-09-25 23:36 ` [Cluster-devel] " TongZhang
2018-09-25 23:36 ` TongZhang
2018-09-26 13:09 ` Stephen Smalley
2018-09-26 13:09 ` [Cluster-devel] " Stephen Smalley
2018-09-26 13:09 ` Stephen Smalley
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.