From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752148Ab3LSGOZ (ORCPT ); Thu, 19 Dec 2013 01:14:25 -0500 Received: from mail-gg0-f180.google.com ([209.85.161.180]:60240 "EHLO mail-gg0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750909Ab3LSGOY (ORCPT ); Thu, 19 Dec 2013 01:14:24 -0500 Date: Wed, 18 Dec 2013 22:14:20 -0800 (PST) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Vegard Nossum cc: linux-kernel@vger.kernel.org, Tommi Rantala , Ingo Molnar , "Eric W. Biederman" , Andy Lutomirski , Kees Cook , Daniel Vetter , Alan Cox , Greg Kroah-Hartman , Jason Wang , "David S. Miller" , Dan Carpenter , James Morris Subject: Re: [PATCH 1/9] Known exploit detection In-Reply-To: <1386867152-24072-1-git-send-email-vegard.nossum@oracle.com> Message-ID: References: <1386867152-24072-1-git-send-email-vegard.nossum@oracle.com> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 12 Dec 2013, vegard.nossum@oracle.com wrote: > diff --git a/security/exploit.c b/security/exploit.c > new file mode 100644 > index 0000000..a732613 > --- /dev/null > +++ b/security/exploit.c > @@ -0,0 +1,28 @@ > +#include > +#include > +#include > +#include > +#include > + > +void _exploit(const char *id) > +{ > + /* > + * This function needs to be super defensive/conservative, since > + * userspace can easily get to it from several different contexts. > + * We don't want it to become an attack vector in itself! > + * > + * We can assume that we're in process context, but spinlocks may > + * be held, etc. Not task_lock(current), though. > + */ > + > + struct task_struct *task = current; > + pid_t pid = task_pid_nr(task); > + uid_t uid = from_kuid(&init_user_ns, current_uid()); > + char comm[sizeof(task->comm)]; > + > + get_task_comm(comm, task); > + > + pr_warn_ratelimited("warning: possible %s exploit attempt by pid=%u uid=%u comm=%s\n", > + id, pid, uid, comm); > +} > +EXPORT_SYMBOL(_exploit);