[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1306218793.2298.10.camel@Joe-Laptop>
Date: Mon, 23 May 2011 23:33:13 -0700
From: Joe Perches <joe@...ches.com>
To: Eric Dumazet <eric.dumazet@...il.com>
Cc: David Miller <davem@...emloft.net>, akpm@...ux-foundation.org,
netdev@...r.kernel.org, drosenberg@...curity.com,
a.p.zijlstra@...llo.nl, eparis@...isplace.org,
eugeneteo@...nel.org, jmorris@...ei.org, kees.cook@...onical.com,
mingo@...e.hu, tgraf@...radead.org
Subject: Re: [patch 1/1] net: convert %p usage to %pK
On Tue, 2011-05-24 at 08:17 +0200, Eric Dumazet wrote:
> We probably need to extend this to inet_diag as well.
> Provide a mayber_hide_ptr() helper and use it in inet_diag to not
> disclose kernel pointers to user, with kptr_restrict logic :
> kptr_restrict = 0 : kernel pointers are not mangled
> kptr_restrict = 1 : if the current user does not have CAP_SYSLOG,
> kernel pointers are replaced by 0
> kptr_restrict = 2 : kernel pointers are replaced by 0
> Signed-off-by: Eric Dumazet <eric.dumazet@...il.com>
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
[]
> +void *maybe_hide_ptr(void *ptr)
> +{
> + if (!((kptr_restrict == 0) ||
> + (kptr_restrict == 1 &&
> + has_capability_noaudit(current, CAP_SYSLOG))))
> + ptr = NULL;
> + return ptr;
> +}
> +EXPORT_SYMBOL(maybe_hide_ptr);
Makes sense to me.
Maybe for clarity it'd be better to use a switch/case
or something like:
if (kptr_restrict == 0)
return ptr;
if (ptr_restrict == 1 &&
has_capability_noaudit(current, CAP_SYSLOG))
return ptr;
return NULL;
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists