[PATCH] ath5k: debugfs: NULL-terminate strings

2013-08-25 Thread Djalal Harouni
Avoid processing garbage data by NULL terminating the strings. Signed-off-by: Djalal Harouni --- Patch compile tested only. drivers/net/wireless/ath/ath5k/debug.c | 24 ++-- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/ath/ath5k

[PATCH 1/2] procfs: restore 0400 permissions on /proc/*/{syscall,stack,personality}

2013-08-26 Thread Djalal Harouni
Avoid giving an fd on privileged files for free by switching these files to 0400 mode. This patch restores the old mode which was 0400 Signed-off-by: Djalal Harouni --- fs/proc/base.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/proc/base.c b/fs/proc

[PATCH 2/2] procfs: restore 0400 permissions on /proc/*/pagemap

2013-08-26 Thread Djalal Harouni
Do not give an fd on privileged /proc/*/pagemap files for free. Restore the previous 0400 mode Signed-off-by: Djalal Harouni --- fs/proc/base.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/proc/base.c b/fs/proc/base.c index 6b162cd..93a1c89 100644 --- a/fs/proc

Re: [PATCH 1/2] procfs: restore 0400 permissions on /proc/*/{syscall,stack,personality}

2013-08-26 Thread Djalal Harouni
On Mon, Aug 26, 2013 at 09:49:48AM -0700, Eric W. Biederman wrote: > Djalal Harouni writes: > > > Avoid giving an fd on privileged files for free by switching these > > files to 0400 mode. > > This seems to be a revert of Al's patch in March of 2011 based on broke

Re: [PATCH 1/2] procfs: restore 0400 permissions on /proc/*/{syscall,stack,personality}

2013-08-27 Thread Djalal Harouni
o why not restore the old behaviour and block a process from getting an fd on /proc/*/stack files that belong to other processes? The original thread that added the /proc/*/stack feature: https://lkml.org/lkml/2008/11/7/109 They noted that it should be under 0400 permissions So why remov

Re: [PATCH 1/2] procfs: restore 0400 permissions on /proc/*/{syscall,stack,personality}

2013-08-28 Thread Djalal Harouni
Cc'ed more people, On Tue, Aug 27, 2013 at 06:24:06PM +0100, Djalal Harouni wrote: > Hi Al, > > On Mon, Aug 26, 2013 at 06:20:55PM +0100, Al Viro wrote: > > On Mon, Aug 26, 2013 at 09:49:48AM -0700, Eric W. Biederman wrote: > > > > > How does changing the per

Re: [PATCH 1/2] procfs: restore 0400 permissions on /proc/*/{syscall,stack,personality}

2013-08-28 Thread Djalal Harouni
On Wed, Aug 28, 2013 at 01:49:06PM -0700, Kees Cook wrote: > On Wed, Aug 28, 2013 at 1:11 PM, Djalal Harouni wrote: [...] > >> 2) > >> The commit log says also: > >> "if you open a file before the target does suid-root exec, you'll be still > >> a

Re: [PATCH 1/2] procfs: restore 0400 permissions on /proc/*/{syscall,stack,personality}

2013-08-29 Thread Djalal Harouni
hey are correct. Perhaps you didn't take a closer look Thanks Eric -- Djalal Harouni http://opendz.org -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/

[PATCH v2 0/9] procfs: protect /proc//* files with file->f_cred

2013-10-01 Thread Djalal Harouni
s task [PATCH v2 3/9] procfs: Document the proposed solution to protect procfs entries - Patchset cleaned Version 1 was discussed here: https://lkml.org/lkml/2013/9/25/459 The following series tries to implement what I describe. Djalal Harouni (9): procfs: add proc_same_open_cred() to check

[PATCH v2 1/9] procfs: add proc_same_open_cred() to check if the cred have changed

2013-10-01 Thread Djalal Harouni
changed which means that perhaps we have gain or lost the privileges of processing the /proc file descriptor. So add proc_same_open_cred() to check if the cred have changed. Cc: Kees Cook Suggested-by: Eric W. Biederman Signed-off-by: Djalal Harouni --- fs/proc/base.c | 29

[PATCH v2 2/9] procfs: add proc_allow_access() to check if file's opener may access task

2013-10-01 Thread Djalal Harouni
c entries. This function should be used with the ptrace_may_access() check. Cc: Kees Cook Suggested-by: Eric W. Biederman Signed-off-by: Djalal Harouni --- fs/proc/base.c | 56 ++ fs/proc/internal.h | 2 ++ 2 files changed, 58 insertion

[PATCH v2 3/9] procfs: Document the proposed solution to protect procfs entries

2013-10-01 Thread Djalal Harouni
Note the proposed solution to protect sensitive procfs entries as code comment. Cc: Kees Cook Suggested-by: Eric W. Biederman Signed-off-by: Djalal Harouni --- fs/proc/base.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/fs/proc/base.c b/fs/proc/base.c index c29eeae

[PATCH v2 4/9] procfs: make /proc/*/{stack,syscall} 0400

2013-10-01 Thread Djalal Harouni
ptrace checks. Cc: Eric W. Biederman Acked-by: Kees Cook Signed-off-by: Djalal Harouni --- fs/proc/base.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/proc/base.c b/fs/proc/base.c index 8d21316..54e926a 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -2682,7

[PATCH v2 5/9] procfs: make /proc entries that use seq files able to access file->f_cred

2013-10-01 Thread Djalal Harouni
single_open() so it will be stored in seq_file->private in seq_open(). This way these entries are able to continue to use seq files, and access the file->f_cred easily. This is also a preparation for the following patches which will check the corresponding file->f_cred. Signed-off-

[PATCH v2 6/9] procfs: add permission checks on the file's opener of /proc/*/stat

2013-10-01 Thread Djalal Harouni
data. The patch also adds a previously missing signal->cred_guard_mutex lock. This patch does not break userspace since it only hides the fields that were supposed to be protected. Cc: Kees Cook Cc: Eric W. Biederman Signed-off-by: Djalal Harouni --- fs/proc/array.c | 16 ++--

[PATCH v2 7/9] procfs: add permission checks on the file's opener of /proc/*/personality

2013-10-01 Thread Djalal Harouni
If current's cred have changed between ->open() and ->read(), then call proc_allow_access() to check if the original file's opener had enough permissions to access the /proc/*/personality entry during ->read(). Cc: Kees Cook Cc: Eric W. Biederman Signed-off-by: Djalal Ha

[PATCH v2 8/9] procfs: improve permission checks on /proc/*/stack

2013-10-01 Thread Djalal Harouni
t the stack trace of a task. Cc: Kees Cook Cc: Eric W. Biederman Signed-off-by: Djalal Harouni --- fs/proc/base.c | 87 ++ 1 file changed, 75 insertions(+), 12 deletions(-) diff --git a/fs/proc/base.c b/fs/proc/base.c index 77f5b84..b80588a

[PATCH v2 9/9] procfs: improve permission checks on /proc/*/syscall

2013-10-01 Thread Djalal Harouni
unction which is used to get the syscall entries of the task. Cc: Kees Cook Cc: Eric W. Biederman Signed-off-by: Djalal Harouni --- fs/proc/base.c | 93 -- 1 file changed, 84 insertions(+), 9 deletions(-) diff --git a/fs/proc/base.c b/fs/p

Re: [PATCH v2 0/9] procfs: protect /proc//* files with file->f_cred

2013-10-02 Thread Djalal Harouni
On Tue, Oct 01, 2013 at 06:40:41PM -0700, Andy Lutomirski wrote: > On 10/01/2013 01:26 PM, Djalal Harouni wrote: > > /proc//* entries varies at runtime, appropriate permission checks > > need to happen during each system call. > > > > Currently some of these sensiti

Re: [PATCH v2 2/9] procfs: add proc_allow_access() to check if file's opener may access task

2013-10-02 Thread Djalal Harouni
On Tue, Oct 01, 2013 at 06:36:34PM -0700, Andy Lutomirski wrote: > On 10/01/2013 01:26 PM, Djalal Harouni wrote: > > Since /proc entries varies at runtime, permission checks need to happen > > during each system call. > > > > However even with that /proc file descript

Re: [PATCH v2 6/9] procfs: add permission checks on the file's opener of /proc/*/stat

2013-10-02 Thread Djalal Harouni
On Tue, Oct 01, 2013 at 06:39:00PM -0700, Andy Lutomirski wrote: > On 10/01/2013 01:26 PM, Djalal Harouni wrote: > > Some fields of the /proc/*/stat are sensitive fields that need > > appropriate protection. > > > > However, /proc file descriptors can be passed to a

Re: [PATCH v2 0/9] procfs: protect /proc//* files with file->f_cred

2013-10-02 Thread Djalal Harouni
On Wed, Oct 02, 2013 at 05:51:15PM +0100, Andy Lutomirski wrote: > On Wed, Oct 2, 2013 at 3:37 PM, Djalal Harouni wrote: > > On Tue, Oct 01, 2013 at 06:40:41PM -0700, Andy Lutomirski wrote: > >> On 10/01/2013 01:26 PM, Djalal Harouni wrote: > >> > /proc//* entries

Re: [PATCH v2 0/9] procfs: protect /proc//* files with file->f_cred

2013-10-02 Thread Djalal Harouni
On Wed, Oct 02, 2013 at 10:48:55AM -0700, Kees Cook wrote: > On Wed, Oct 2, 2013 at 9:51 AM, Andy Lutomirski wrote: > > On Wed, Oct 2, 2013 at 3:37 PM, Djalal Harouni wrote: > >> On Tue, Oct 01, 2013 at 06:40:41PM -0700, Andy Lutomirski wrote: > >>> On 10/01/2013

Re: [PATCH v2 0/9] procfs: protect /proc//* files with file->f_cred

2013-10-02 Thread Djalal Harouni
On Wed, Oct 02, 2013 at 11:00:26AM -0700, Andy Lutomirski wrote: > On Wed, Oct 2, 2013 at 10:48 AM, Kees Cook wrote: > > On Wed, Oct 2, 2013 at 9:51 AM, Andy Lutomirski wrote: > >> On Wed, Oct 2, 2013 at 3:37 PM, Djalal Harouni wrote: > >>> On Tue, Oct 01,

Re: [PATCH v2 0/9] procfs: protect /proc//* files with file->f_cred

2013-10-02 Thread Djalal Harouni
On Wed, Oct 02, 2013 at 07:26:43PM +0100, Djalal Harouni wrote: > On Wed, Oct 02, 2013 at 11:00:26AM -0700, Andy Lutomirski wrote: > > On Wed, Oct 2, 2013 at 10:48 AM, Kees Cook wrote: > > > I think revoking the fd would be great. Does that mechanism exist? > > > >

Re: [PATCH v2 0/9] procfs: protect /proc//* files with file->f_cred

2013-10-02 Thread Djalal Harouni
On Wed, Oct 02, 2013 at 11:35:45AM -0700, Kees Cook wrote: > On Wed, Oct 2, 2013 at 11:22 AM, Djalal Harouni wrote: > > On Wed, Oct 02, 2013 at 10:48:55AM -0700, Kees Cook wrote: > >> On Wed, Oct 2, 2013 at 9:51 AM, Andy Lutomirski > >> wrote: > >> >

Re: [PATCH v2 6/9] procfs: add permission checks on the file's opener of /proc/*/stat

2013-10-02 Thread Djalal Harouni
On Wed, Oct 02, 2013 at 05:46:19PM +0100, Andy Lutomirski wrote: > On Wed, Oct 2, 2013 at 4:14 PM, Djalal Harouni wrote: > > On Tue, Oct 01, 2013 at 06:39:00PM -0700, Andy Lutomirski wrote: > >> On 10/01/2013 01:26 PM, Djalal Harouni wrote: > >> > Some fields of

Re: [PATCH v2 0/9] procfs: protect /proc//* files with file->f_cred

2013-10-03 Thread Djalal Harouni
On Thu, Oct 03, 2013 at 08:12:44AM +0200, Ingo Molnar wrote: > > * Djalal Harouni wrote: > > > > Regardless, glibc uses /proc/self/maps, which would be fine here, right? > > > > I did not touch /proc/self/maps and others, but I'm planning to fix the

Re: [PATCH v2 0/9] procfs: protect /proc//* files with file->f_cred

2013-10-03 Thread Djalal Harouni
On Thu, Oct 03, 2013 at 08:22:56AM +0200, Ingo Molnar wrote: > > * Djalal Harouni wrote: > > > * You can't do it for /proc/*/stat otherwise you will break userspace > > "ps"..., ps must access /proc/1/stat etc... so the proposed solution > > w

Re: [PATCH v2 2/9] procfs: add proc_allow_access() to check if file's opener may access task

2013-10-03 Thread Djalal Harouni
On Wed, Oct 02, 2013 at 05:44:17PM +0100, Andy Lutomirski wrote: > On Wed, Oct 2, 2013 at 3:55 PM, Djalal Harouni wrote: > > On Tue, Oct 01, 2013 at 06:36:34PM -0700, Andy Lutomirski wrote: > >> On 10/01/2013 01:26 PM, Djalal Harouni wrote: > >> > Since /proc entries

Re: [PATCH v2 0/9] procfs: protect /proc//* files with file->f_cred

2013-10-03 Thread Djalal Harouni
On Thu, Oct 03, 2013 at 04:15:43PM +0100, Andy Lutomirski wrote: > On Thu, Oct 3, 2013 at 1:29 PM, Djalal Harouni wrote: > > On Thu, Oct 03, 2013 at 08:12:44AM +0200, Ingo Molnar wrote: > >> Now procfs might be special, as by its nature of a pseudofilesystem it's > >

Re: [PATCH v2 0/9] procfs: protect /proc//* files with file->f_cred

2013-10-03 Thread Djalal Harouni
(Andy sorry for the delay, real life...) On Thu, Oct 03, 2013 at 04:50:54PM +0100, Andy Lutomirski wrote: > On Thu, Oct 3, 2013 at 4:40 PM, Djalal Harouni wrote: > > On Thu, Oct 03, 2013 at 04:15:43PM +0100, Andy Lutomirski wrote: > >> On Thu, Oct 3, 2013 at 1:29 PM, Dja

Re: [PATCH v2 2/9] procfs: add proc_allow_access() to check if file's opener may access task

2013-10-03 Thread Djalal Harouni
On Thu, Oct 03, 2013 at 04:12:37PM +0100, Andy Lutomirski wrote: > On Thu, Oct 3, 2013 at 3:36 PM, Djalal Harouni wrote: > > On Wed, Oct 02, 2013 at 05:44:17PM +0100, Andy Lutomirski wrote: > >> On Wed, Oct 2, 2013 at 3:55 PM, Djalal Harouni wrote: > >> > On Tue, Oc

Re: [PATCH v2 2/9] procfs: add proc_allow_access() to check if file's opener may access task

2013-10-03 Thread Djalal Harouni
On Thu, Oct 03, 2013 at 12:37:49PM -0700, Andy Lutomirski wrote: > On Thu, Oct 3, 2013 at 12:29 PM, Djalal Harouni wrote: > > On Thu, Oct 03, 2013 at 04:12:37PM +0100, Andy Lutomirski wrote: > >> On Thu, Oct 3, 2013 at 3:36 PM, Djalal Harouni wrote: > >> > On W

Re: [PATCH v2 2/9] procfs: add proc_allow_access() to check if file's opener may access task

2013-10-04 Thread Djalal Harouni
On Thu, Oct 03, 2013 at 02:09:55PM -0700, Andy Lutomirski wrote: > On Thu, Oct 3, 2013 at 1:13 PM, Djalal Harouni wrote: > > On Thu, Oct 03, 2013 at 12:37:49PM -0700, Andy Lutomirski wrote: > >> On Thu, Oct 3, 2013 at 12:29 PM, Djalal Harouni wrote: > >> > On T

Re: [PATCH v2 0/9] procfs: protect /proc//* files with file->f_cred

2013-10-04 Thread Djalal Harouni
d file_ns_capable() is that proc_allow_access() will check if it's absolutely the same user, otherwise fallback to security_capable() which is the heart of file_ns_capable() So it's already been done and proposed! this is an easy solution to detect if current's cred have changed.

Re: [PATCH v2 2/9] procfs: add proc_allow_access() to check if file's opener may access task

2013-10-04 Thread Djalal Harouni
On Fri, Oct 04, 2013 at 04:40:01PM +0100, Andy Lutomirski wrote: > On Fri, Oct 4, 2013 at 9:59 AM, Djalal Harouni wrote: > > On Thu, Oct 03, 2013 at 02:09:55PM -0700, Andy Lutomirski wrote: > >> On Thu, Oct 3, 2013 at 1:13 PM, Djalal Harouni wrote: > >> > On Thu, Oc

Re: [PATCH v2 2/9] procfs: add proc_allow_access() to check if file's opener may access task

2013-10-04 Thread Djalal Harouni
On Fri, Oct 04, 2013 at 07:34:08PM +0100, Andy Lutomirski wrote: > On Fri, Oct 4, 2013 at 7:23 PM, Djalal Harouni wrote: > > On Fri, Oct 04, 2013 at 04:40:01PM +0100, Andy Lutomirski wrote: > >> On Fri, Oct 4, 2013 at 9:59 AM, Djalal Harouni wrote: > >> > On Thu, Oc

Re: [PATCH v2 2/9] procfs: add proc_allow_access() to check if file's opener may access task

2013-10-04 Thread Djalal Harouni
On Fri, Oct 04, 2013 at 12:16:26PM -0700, Andy Lutomirski wrote: > On Fri, Oct 4, 2013 at 12:11 PM, Djalal Harouni wrote: > > On Fri, Oct 04, 2013 at 07:34:08PM +0100, Andy Lutomirski wrote: > >> On Fri, Oct 4, 2013 at 7:23 PM, Djalal Harouni wrote: > >> > On F

Re: [PATCH v2 2/9] procfs: add proc_allow_access() to check if file's opener may access task

2013-10-04 Thread Djalal Harouni
On Fri, Oct 04, 2013 at 12:32:09PM -0700, Andy Lutomirski wrote: > On Fri, Oct 4, 2013 at 12:27 PM, Djalal Harouni wrote: > > On Fri, Oct 04, 2013 at 12:16:26PM -0700, Andy Lutomirski wrote: > >> On Fri, Oct 4, 2013 at 12:11 PM, Djalal Harouni wrote: > >> > On F

Re: [PATCH v2 2/9] procfs: add proc_allow_access() to check if file's opener may access task

2013-10-05 Thread Djalal Harouni
On Fri, Oct 04, 2013 at 03:17:08PM -0700, Andy Lutomirski wrote: > On Fri, Oct 4, 2013 at 12:41 PM, Djalal Harouni wrote: > > On Fri, Oct 04, 2013 at 12:32:09PM -0700, Andy Lutomirski wrote: > >> On Fri, Oct 4, 2013 at 12:27 PM, Djalal Harouni wrote: > >> > On F

Re: [PATCH 1/2] procfs: restore 0400 permissions on /proc/*/{syscall,stack,personality}

2013-09-11 Thread Djalal Harouni
Hi Eric, (Sorry for the delay, please see below) On Sat, Aug 31, 2013 at 06:44:39PM -0700, Eric W. Biederman wrote: > Djalal Harouni writes: [...] > > Yes Kees, > > > > I did try a year ago to adapt the exec_id from grsecurity and failed > > (and failed again to re

Re: [PATCH v2 2/9] procfs: add proc_allow_access() to check if file's opener may access task

2013-10-09 Thread Djalal Harouni
On Fri, Oct 04, 2013 at 05:35:22PM -0700, Eric W. Biederman wrote: > Andy Lutomirski writes: > > > On Fri, Oct 4, 2013 at 3:55 PM, Eric W. Biederman > > wrote: > >> Andy Lutomirski writes: > >> > >>> On Fri, Oct 4, 2013 at 12:41 PM, Djalal Haro

Re: [PATCH v2 2/9] procfs: add proc_allow_access() to check if file's opener may access task

2013-10-09 Thread Djalal Harouni
On Mon, Oct 07, 2013 at 02:41:33PM -0700, Andy Lutomirski wrote: > On Sat, Oct 5, 2013 at 6:23 AM, Djalal Harouni wrote: > > On Fri, Oct 04, 2013 at 03:17:08PM -0700, Andy Lutomirski wrote: > >> > >> Exactly. Hence the NAK. > > But Having two LSM Hooks there i

Re: [PATCH v2 2/9] procfs: add proc_allow_access() to check if file's opener may access task

2013-10-09 Thread Djalal Harouni
On Wed, Oct 09, 2013 at 11:54:02AM +0100, Djalal Harouni wrote: > On Mon, Oct 07, 2013 at 02:41:33PM -0700, Andy Lutomirski wrote: > > On Sat, Oct 5, 2013 at 6:23 AM, Djalal Harouni wrote: > > > On Fri, Oct 04, 2013 at 03:17:08PM -0700, Andy Lutomirski wrote: > > >>

Re: [PATCH 1/2] procfs: restore 0400 permissions on /proc/*/{syscall,stack,personality}

2013-08-31 Thread Djalal Harouni
(Sorry for my late response) On Thu, Aug 29, 2013 at 03:14:32PM -0700, Kees Cook wrote: > On Thu, Aug 29, 2013 at 2:11 AM, Djalal Harouni wrote: > > Hi Eric, > > > > On Wed, Aug 28, 2013 at 05:26:56PM -0700, Eric W. Biederman wrote: > >> > >> I have take

Re: [PATCH 04/12] seq_file: Make seq_file able to access the file's opener cred

2013-09-27 Thread Djalal Harouni
On Wed, Sep 25, 2013 at 05:22:51PM -0700, Linus Torvalds wrote: > On Wed, Sep 25, 2013 at 1:14 PM, Djalal Harouni wrote: > > > > Therefor add the f_cred field to the seq_file struct and a helper > > seq_f_cred() to return it. > > I hate how you've split up t

Re: [PATCH 04/12] seq_file: Make seq_file able to access the file's opener cred

2013-09-27 Thread Djalal Harouni
On Thu, Sep 26, 2013 at 04:02:54AM +0100, Al Viro wrote: > On Wed, Sep 25, 2013 at 05:22:51PM -0700, Linus Torvalds wrote: > > On Wed, Sep 25, 2013 at 1:14 PM, Djalal Harouni wrote: > > > > > > Therefor add the f_cred field to the seq_file struct and a helper >

Re: [PATCH 06/12] procfs: make /proc/*/stack 0400

2013-09-28 Thread Djalal Harouni
On Thu, Sep 26, 2013 at 03:43:24PM -0500, Kees Cook wrote: > On Wed, Sep 25, 2013 at 3:14 PM, Djalal Harouni wrote: > > The /proc/*/stack contains sensitive information and currently its mode > > is 0444. Change this to 0400 so the VFS will be able to block > > unprivileged

Re: [PATCH 04/12] seq_file: Make seq_file able to access the file's opener cred

2013-09-28 Thread Djalal Harouni
On Thu, Sep 26, 2013 at 04:02:54AM +0100, Al Viro wrote: > On Wed, Sep 25, 2013 at 05:22:51PM -0700, Linus Torvalds wrote: > > On Wed, Sep 25, 2013 at 1:14 PM, Djalal Harouni wrote: > > > > > > Therefor add the f_cred field to the seq_file struct and a helper >

Re: [PATCH 06/12] procfs: make /proc/*/stack 0400

2013-09-29 Thread Djalal Harouni
On Thu, Sep 26, 2013 at 03:43:24PM -0500, Kees Cook wrote: > On Wed, Sep 25, 2013 at 3:14 PM, Djalal Harouni wrote: > > The /proc/*/stack contains sensitive information and currently its mode > > is 0444. Change this to 0400 so the VFS will be able to block > > unprivileged

[PATCH 0/12] procfs: protect /proc//* files with file->f_cred

2013-09-25 Thread Djalal Harouni
ecks on /proc/*/syscall 8) Finally the last patch is user_ns and seq_file cleaning. Thanks! [1] https://lkml.org/lkml/2013/8/26/354 [2] https://lkml.org/lkml/2013/8/31/209 Djalal Harouni (12): procfs: add proc_same_open_cred() to check if the cred have changed procfs: add proc_allow_access() t

[PATCH 01/12] procfs: add proc_same_open_cred() to check if the cred have changed

2013-09-25 Thread Djalal Harouni
changed which means that perhaps we have gain or lost the privileges of processing the /proc file descriptor. So add proc_same_open_cred() to check if the cred have changed. Cc: Kees Cook Cc: Eric W. Biederman Signed-off-by: Djalal Harouni --- fs/proc/base.c | 29

[PATCH 02/12] procfs: add proc_allow_access() to check if file's opener may access task

2013-09-25 Thread Djalal Harouni
c entries. This function should be used with the ptrace_may_access() check. Cc: Kees Cook Cc: Eric W. Biederman Signed-off-by: Djalal Harouni --- fs/proc/base.c | 56 ++ fs/proc/internal.h | 2 ++ 2 files changed, 58 insertions(+) diff

[PATCH 03/12] procfs: Document the proposed solution to protect procfs entries

2013-09-25 Thread Djalal Harouni
Note the proposed solution to protect sensitive procfs entries as code comment. Cc: Kees Cook Cc: Eric W. Biederman Signed-off-by: Djalal Harouni --- fs/proc/base.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/fs/proc/base.c b/fs/proc/base.c index c29eeae..8d21316 100644

[PATCH 04/12] seq_file: Make seq_file able to access the file's opener cred

2013-09-25 Thread Djalal Harouni
a helper seq_f_cred() to return it. Cc: Kees Cook Cc: Eric W. Biederman Signed-off-by: Djalal Harouni --- include/linux/seq_file.h | 7 +++ 1 file changed, 7 insertions(+) diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h index 4e32edc..ec07709 100644 --- a/include/linux/seq_file

[PATCH 05/12] seq_file: set the seq_file->f_cred during seq_open()

2013-09-25 Thread Djalal Harouni
each system call. Set the seq_file->f_cred to file->f_cred during seq_open(). Cc: Kees Cook Cc: Eric W. Biederman Signed-off-by: Djalal Harouni --- fs/seq_file.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/seq_file.c b/fs/seq_file.c index 3135c25..a5e5b98 100644 --- a/fs/seq_file

[PATCH 06/12] procfs: make /proc/*/stack 0400

2013-09-25 Thread Djalal Harouni
Eric W. Biederman Signed-off-by: Djalal Harouni --- fs/proc/base.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/proc/base.c b/fs/proc/base.c index 8d21316..bb90171 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -2710,7 +2710,7 @@ static const struct pid

[PATCH 07/12] procfs: add permission checks on the file's opener of /proc/*/stack

2013-09-25 Thread Djalal Harouni
(e.g. a suid-exec). Cc: Kees Cook Cc: Eric W. Biederman Signed-off-by: Djalal Harouni --- fs/proc/base.c | 26 +++--- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/fs/proc/base.c b/fs/proc/base.c index bb90171..d6a17b3 100644 --- a/fs/proc/base.c +++ b

[PATCH 08/12] procfs: add permission checks on the file's opener of /proc/*/personality

2013-09-25 Thread Djalal Harouni
If current's cred have changed between ->open() and ->read(), then call proc_allow_access() to check if the original file's opener had enough permissions to access the /proc/*/personality entry during ->read(). Cc: Kees Cook Cc: Eric W. Biederman Signed-off-by: Djalal Ha

[PATCH 09/12] procfs: add permission checks on the file's opener of /proc/*/stat

2013-09-25 Thread Djalal Harouni
pener had enough permissions to read these sensitive fields. The patch also adds a previously missing signal->cred_guard_mutex lock. This patch does not break userspace since it only hides the fields that were supposed to be protected. Cc: Kees Cook Cc: Eric W. Biederman Signed-off-by: Djalal Ha

[PATCH 10/12] procfs: move PROC_BLOCK_SIZE declaration up to make it visible

2013-09-25 Thread Djalal Harouni
Move PROC_BLOCK_SIZE declaraiton up, so new code can use it. Signed-off-by: Djalal Harouni --- fs/proc/base.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/proc/base.c b/fs/proc/base.c index ed8e3f7..fe02ee4 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -150,6

[PATCH 11/12] procfs: improve permission checks on /proc/*/syscall

2013-09-25 Thread Djalal Harouni
t the syscall entries of the task. This patch also makes /proc/*/syscall 0400 so that the VFS will block any unprivilged access right away. Cc: Kees Cook Cc: Eric W. Biederman Signed-off-by: Djalal Harouni --- fs/proc/base.c | 87 +

[PATCH 12/12] user_ns: seq_file: use the user_ns that is embedded in the f_cred struct

2013-09-25 Thread Djalal Harouni
ed-off-by: Djalal Harouni --- fs/seq_file.c| 3 --- include/linux/seq_file.h | 6 ++ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/fs/seq_file.c b/fs/seq_file.c index a5e5b98..ee1c36d 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c @@ -58,9 +58,6 @@ int seq_open(st

Re: [PATCH 5/6] kthread: avoid parsing names as format strings

2013-06-12 Thread Djalal Harouni
thd_name); > > if (IS_ERR(dd->mtip_svc_handler)) { > dev_err(&dd->pdev->dev, "service thread failed to start\n"); Thanks! -- Djalal Harouni http://opendz.org -- To unsubscribe from this list: send the line "unsubscribe linux-kern

Re: [PATCH 1/2] Input: cyttsp - fix memcpy size param

2013-06-17 Thread Djalal Harouni
cmd); > -- > 1.7.9.5 I was going to send a patch and found that it was just fixed in todays next-20130617 Anyway, will this overflow fix go for the next -rc? Thanks in advance Dmitry! -- Djalal Harouni http://opendz.org -- To unsubscribe from this list: send the line "u

[PATCH] Btrfs: do not ignore errors when truncating the free space cache inode

2013-06-18 Thread Djalal Harouni
btrfs_check_trunc_cache_free_space() tries to check if there is enough space for cache inode truncation but it fails. Currently this function always returns success even if there is no enough space. Fix this by returning the -ENOSPC error code. Signed-off-by: Djalal Harouni --- Totally untested

[PATCH v2] iwlwifi: mvm: make debugfs write() operations write up to count bytes

2013-08-24 Thread Djalal Harouni
-off-by: Djalal Harouni Cc: "Berg, Johannes" --- Patch compile tested only. v2 Clean patch and use min_t() as noted by Berg Johannes drivers/net/wireless/iwlwifi/mvm/debugfs.c | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/mvm

[PATCH] iwlwifi: mvm: make debugfs write() operations write up to count bytes

2013-08-11 Thread Djalal Harouni
initializer from 'char buf[x] = {}' to the explicit memset() as it is done in other places of the same file. Cc: sta...@vger.kernel.org Signed-off-by: Djalal Harouni --- Patch compile tested only. Dual BSD/GPLv2 license: Ok drivers/net/wireless/iwlwifi/mvm/debu

Re: [PATCH] iwlwifi: mvm: make debugfs write() operations write up to count bytes

2013-08-12 Thread Djalal Harouni
es > -- > > Intel GmbH > Dornacher Strasse 1 > 85622 Feldkirchen/Muenchen, Deutschland > Sitz der Gesellschaft: Feldkirchen bei Muenchen > Geschaeftsfuehrer: Christian Lamprechter, Hannes Schwaderer, Douglas Lusk > Registergericht: Muenchen HRB 47456 > Ust.-IdNr./VAT

[PATCH] proc: do not allow negative offsets on /proc//environ

2012-07-22 Thread Djalal Harouni
ot a security issue, but we should not be able to abuse it. Signed-off-by: Djalal Harouni --- New kernels include mm->env_start in /proc//stat To dump .text area: lseek() to 0x0040 - mm->env_start fs/proc/base.c |9 ++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git

Re: [PATCH] proc: do not allow negative offsets on /proc//environ

2012-07-22 Thread Djalal Harouni
Hi Oleg, On Sun, Jul 22, 2012 at 10:00:49PM +0200, Oleg Nesterov wrote: > On 07/22, Djalal Harouni wrote: > > > > __mem_open() which is called by both /proc//environ and > > /proc//mem ->open() handlers will allow the use of negative offsets. > > /proc//mem has

Re: [PATCH] proc: do not allow negative offsets on /proc//environ

2012-07-23 Thread Djalal Harouni
On Mon, Jul 23, 2012 at 05:49:27PM +0200, Oleg Nesterov wrote: > Hi Djalal, > > On 07/23, Djalal Harouni wrote: > > > > Hi Oleg, > > > > On Sun, Jul 22, 2012 at 10:00:49PM +0200, Oleg Nesterov wrote: > > > > > > Probablt the patc

[PATCH v2 0/2] proc: /proc//environ offset fixes

2012-07-24 Thread Djalal Harouni
ve the current 'mm' for next operations. Djalal Harouni (2): proc: environ_read() make sure offset points to environment address range proc: do not allow negative offsets on /proc//environ fs/proc/base.c | 22 +- 1 files changed, 13 insertions(+), 9 deletions(-) V

[PATCH v2 1/2] proc: environ_read() make sure offset points to environment address range

2012-07-24 Thread Djalal Harouni
ue and we can not depend on it. For kernels that have commit b409e578d9a4ec95913e06d8f which adds the appropriate ptrace check and saves the 'mm' at ->open() time, this is not a security issue. This patch is taken from the grsecurity patch since it was just made available. Cc: Oleg Nesterov Cc

[PATCH v2 2/2] proc: do not allow negative offsets on /proc//environ

2012-07-24 Thread Djalal Harouni
only on /proc//mem. Cc: Oleg Nesterov Signed-off-by: Djalal Harouni --- fs/proc/base.c |9 ++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/fs/proc/base.c b/fs/proc/base.c index 39ee093..1b6c84c 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -695,8 +695,6

Re: [GIT PULL] kdbus for 4.1-rc1

2015-04-16 Thread Djalal Harouni
icy(7). The concept of a name policy originates from dbus1 [1], however we simplified it substantially, removing features which we believe rather belong into userspace. [1] http://dbus.freedesktop.org/doc/dbus-daemon.1.html -- Djalal Harouni http://opendz.org -- To unsubscribe from this list: s

Re: Sharing credentials in general (Re: [GIT PULL] kdbus for 4.1-rc1)

2015-04-27 Thread Djalal Harouni
el, what if a suid program takes some input, constructs objects/structs based on that, and makes a direct syscall or one through a library into another part of the kernel ? I don't see why it is a problem for kdbus since this supposed problem can affect every major part of the kernel.

Re: [PATCH 0/3] kdbus: minor readability improvements

2015-06-17 Thread Djalal Harouni
e if statements in kdbus_conn_disconnect() Thanks for the patches! all good. > ipc/kdbus/connection.c | 15 +++ > ipc/kdbus/reply.c | 22 +- > 2 files changed, 16 insertions(+), 21 deletions(-) > > -- > 1.8.3.1 > -- Djalal Harouni h

Re: [PATCH 0/3] kdbus: minor readability improvements

2015-06-17 Thread Djalal Harouni
e if statements in kdbus_conn_disconnect() All three patches: Reviewed-by: Djalal Harouni Thanks! > ipc/kdbus/connection.c | 15 +++ > ipc/kdbus/reply.c | 22 +- > 2 files changed, 16 insertions(+), 21 deletions(-) > > -- > 1.8.3.1 > --

Re: [PATCH] kdbus: Delete an unnecessary check before the function call "kdbus_domain_unref"

2015-06-24 Thread Djalal Harouni
t; > static int fs_super_set(struct super_block *sb, void *data) > -- > 2.4.4 > Reviewed-by: Djalal Harouni -- Djalal Harouni http://opendz.org -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.ker

Re: [GIT PULL] kdbus cleanups for 4.2

2015-06-03 Thread Djalal Harouni
st.h| 2 - > tools/testing/selftests/kdbus/test-attach-flags.c | 750 > -- > tools/testing/selftests/kdbus/test-connection.c | 34 +- > tools/testing/selftests/kdbus/test-endpoint.c | 13 +- > 24 files changed, 347 insertions(+), 1079 deletio

Re: [GIT PULL] kdbus cleanups for 4.2

2015-06-03 Thread Djalal Harouni
On Thu, Jun 04, 2015 at 05:45:11AM +0900, Greg Kroah-Hartman wrote: > On Wed, Jun 03, 2015 at 09:28:56PM +0100, Djalal Harouni wrote: > > > > I also have a question is someone of you guys planning to submit a talk > > to future Linux events about kdbus and sdbus ? I ha

Re: [PATCH v2 2/9] procfs: add proc_allow_access() to check if file's opener may access task

2013-10-13 Thread Djalal Harouni
On Wed, Oct 09, 2013 at 06:27:22PM +0100, Andy Lutomirski wrote: > On Wed, Oct 9, 2013 at 11:54 AM, Djalal Harouni wrote: > > On Mon, Oct 07, 2013 at 02:41:33PM -0700, Andy Lutomirski wrote: > >> On Sat, Oct 5, 2013 at 6:23 AM, Djalal Harouni wrote: > >> > On F

Re: [PATCH v3a] vsprintf: Check real user/group id for %pK

2013-10-14 Thread Djalal Harouni
should fail. If this will break userspace then allow open() and cache result for read() Can you emulate the behaviour of kptr_restrict=1 ? If so: 1) perform check during open() and cache data 2) during read() check kptr_restrict==1 check the cached value and if opener had CAP_SYSLOG if so:

Re: [PATCH v3a] vsprintf: Check real user/group id for %pK

2013-10-14 Thread Djalal Harouni
On Mon, Oct 14, 2013 at 11:17:06AM +0100, Djalal Harouni wrote: > On Fri, Oct 11, 2013 at 02:19:14PM +1100, Ryan Mallon wrote: > > On 11/10/13 13:20, Eric W. Biederman wrote: > > > Joe Perches writes: > > > > > >> Some setuid binaries will allow reading of

[PATCH 2/2] procfs: make /proc/*/pagemap 0400

2013-12-15 Thread Djalal Harouni
The /proc/*/pagemap contain sensitive information and currently its mode is 0444. Change this to 0400, so the VFS will prevent unprivileged processes from getting file descriptors on arbitrary privileged /proc/*/pagemap files. Cc: Eric W. Biederman Cc: Kees Cook Signed-off-by: Djalal Harouni

[Resend] [PATCH 0/2] procfs: make /proc/*/{stack,syscall,pagemap} 0400

2013-12-15 Thread Djalal Harouni
eneral aggreemnt, so I'm resending again but _only_ those two patches. At least we have a VFS protection for now. Djalal Harouni (2): procfs: make /proc/*/{stack,syscall,personality} 0400 procfs: make /proc/*/pagemap 0400 fs/proc/base.c | 16 1 file changed, 8 inser

[PATCH 1/2] procfs: make /proc/*/{stack,syscall,personality} 0400

2013-12-15 Thread Djalal Harouni
Cook Signed-off-by: Djalal Harouni --- fs/proc/base.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/proc/base.c b/fs/proc/base.c index 5150706..e69df4b 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -2587,7 +2587,7 @@ static const struct pid_entry

[PATCH v2 1/2] procfs: make /proc/*/pagemap 0400

2014-03-22 Thread Djalal Harouni
protecting already running processes. Cc: Eric W. Biederman Acked-by: Kees Cook Acked-by: Andy Lutomirski Signed-off-by: Djalal Harouni --- fs/proc/base.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/proc/base.c b/fs/proc/base.c index e69df4b..081d055 100644 --- a/fs

[PATCH v2 1/2] procfs: make /proc/*/{stack,syscall,personality} 0400

2014-03-22 Thread Djalal Harouni
and bypasses by protecting already running processes. Cc: Eric W. Biederman Acked-by: Kees Cook Acked-by: Andy Lutomirski Signed-off-by: Djalal Harouni --- fs/proc/base.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/proc/base.c b/fs/proc/base.c index

[PATCH resend - v2 0/2] procfs: make /proc/*/{stack,syscall,pagemap} 0400

2014-03-22 Thread Djalal Harouni
nd came up with another scheme. It will protect *already running* processes, but first I need to get this simple series accepted! Thanks! Djalal Harouni (2): procfs: make /proc/*/{stack,syscall,personality} 0400 procfs: make /proc/*/pagemap 0400 fs/proc/base.c | 16 1 file chan

Re: [PATCH v2 1/2] procfs: make /proc/*/{stack,syscall,personality} 0400

2014-03-25 Thread Djalal Harouni
of things, and I missed that one. So there is the ptrace check that will just block cases where users do _not_ play tricks with the fd. I'll send another v3 with that included. Thanks! -- Djalal Harouni http://opendz.org -- To unsubscribe from this list: send the line "unsubsc

Re: [PATCH v2 1/2] procfs: make /proc/*/{stack,syscall,personality} 0400

2014-04-15 Thread Djalal Harouni
On Fri, Mar 28, 2014 at 03:32:31PM -0700, Andrew Morton wrote: > On Sat, 22 Mar 2014 14:37:39 +0100 Djalal Harouni wrote: > > > These procfs files contain sensitive information and currently their > > mode is 0444. Change this to 0400, so the VFS will be able to block > >

[PATCH 4/9] procfs: improve /proc//wchan protection

2014-05-26 Thread Djalal Harouni
off-by: Djalal Harouni --- fs/proc/base.c | 55 +-- 1 file changed, 49 insertions(+), 6 deletions(-) diff --git a/fs/proc/base.c b/fs/proc/base.c index efe2a11..ef35544 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -273,21 +273,64 @@ static

[PATCH 5/9] procfs: improve /proc//syscall protection

2014-05-26 Thread Djalal Harouni
Convert syscall from an INF entry to a REG one. This way we can perform and cache the permission checks during ->open(). The ptrace capability is only cached, it will be re-checked during ->read(). If the opener did not have enough privileges then fail. Signed-off-by: Djalal Harouni -

[PATCH 6/9] procfs: add pid_seq_private struct to handle /proc//{stat|stack}

2014-05-26 Thread Djalal Harouni
nge. Signed-off-by: Djalal Harouni --- fs/proc/internal.h | 11 +++ 1 file changed, 11 insertions(+) diff --git a/fs/proc/internal.h b/fs/proc/internal.h index f5c452c..f28e4f01 100644 --- a/fs/proc/internal.h +++ b/fs/proc/internal.h @@ -78,6 +78,17 @@ struct proc_inode { str

[PATCH 7/9] procfs: add pid_entry_show() helper to handle /proc//{stat|stack}

2014-05-26 Thread Djalal Harouni
contains the inode and the cached permission checks. Signed-off-by: Djalal Harouni --- fs/proc/base.c | 21 + fs/proc/internal.h | 3 +++ 2 files changed, 24 insertions(+) diff --git a/fs/proc/base.c b/fs/proc/base.c index f0ce94a..b40345b 100644 --- a/fs/proc/b

[PATCH 8/9] procfs: improve /proc//stat protection

2014-05-26 Thread Djalal Harouni
tive data will notice that fields are zeroed. Signed-off-by: Djalal Harouni --- fs/proc/array.c| 90 ++ fs/proc/base.c | 4 +-- fs/proc/internal.h | 6 ++-- 3 files changed, 88 insertions(+), 12 deletions(-) diff --git a/fs/proc/array.c

[PATCH 9/9] procfs: improve /proc//stack protection

2014-05-26 Thread Djalal Harouni
t have enough privileges then fail. Signed-off-by: Djalal Harouni --- fs/proc/base.c | 59 +- 1 file changed, 54 insertions(+), 5 deletions(-) diff --git a/fs/proc/base.c b/fs/proc/base.c index d98ce15..6786878 100644 --- a/fs/proc/base.c ++

  1   2   3   >