From patchwork Tue Nov 19 07:33:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 21607 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f197.google.com (mail-ob0-f197.google.com [209.85.214.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7478323A4E for ; Tue, 19 Nov 2013 07:34:55 +0000 (UTC) Received: by mail-ob0-f197.google.com with SMTP id wp4sf18942559obc.0 for ; Mon, 18 Nov 2013 23:34:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=wEwQe9k9mieXUccHyOBffsv1hY+EsZ/EeLyaTpR4uPc=; b=lP1KA6vu3SQnHBlS9zju1alNsc+i/VrouLSAYJCHy/C54HVGjKDjmpaMjo63zTQvBg 9vyh9yDKqA2J64AuFdRIpP+xWnuc2bu3THfgZaIWli6bUO2BnFxhWAhlTUz9qDLZwRZ+ AndgN4ZAUcdNm+BTHfbRr7FgqYmCKrPxRzeGBUGBfR4N/pnpym8HGmfD1m/fT7zmsMET uqWYSLC3s2oBEHfDFwuWOYR3ScLaX0cUzApriJP9SqzV5kFnOPnK9W76E+mAYrRfG1wp HdO+W9VOHBbqBr/GWudh8ya0vrdzB7/y2wc5lTTqfxGJmuU5yewFq/nLK0MShqWwnmlM fQMQ== X-Gm-Message-State: ALoCoQlP5oCr6pUf2I+8nCee1eUamZfHCdhsUmKR/2GvgYal/Sn7PjduRtTvsCnej6p/g5BQsh14 X-Received: by 10.182.66.137 with SMTP id f9mr9471320obt.3.1384846494840; Mon, 18 Nov 2013 23:34:54 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.117.69 with SMTP id kc5ls3081670qeb.42.gmail; Mon, 18 Nov 2013 23:34:54 -0800 (PST) X-Received: by 10.52.64.143 with SMTP id o15mr16685822vds.16.1384846494760; Mon, 18 Nov 2013 23:34:54 -0800 (PST) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id ef6si7913079ved.123.2013.11.18.23.34.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 18 Nov 2013 23:34:54 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.181; Received: by mail-vc0-f181.google.com with SMTP id ks9so1887495vcb.26 for ; Mon, 18 Nov 2013 23:34:54 -0800 (PST) X-Received: by 10.220.253.66 with SMTP id mz2mr20119737vcb.10.1384846494660; Mon, 18 Nov 2013 23:34:54 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp258672vcz; Mon, 18 Nov 2013 23:34:54 -0800 (PST) X-Received: by 10.66.152.102 with SMTP id ux6mr24813728pab.79.1384846493621; Mon, 18 Nov 2013 23:34:53 -0800 (PST) Received: from mail-pb0-f46.google.com (mail-pb0-f46.google.com [209.85.160.46]) by mx.google.com with ESMTPS id dj6si11327222pad.90.2013.11.18.23.34.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 18 Nov 2013 23:34:53 -0800 (PST) Received-SPF: neutral (google.com: 209.85.160.46 is neither permitted nor denied by best guess record for domain of takahiro.akashi@linaro.org) client-ip=209.85.160.46; Received: by mail-pb0-f46.google.com with SMTP id md12so1506724pbc.33 for ; Mon, 18 Nov 2013 23:34:53 -0800 (PST) X-Received: by 10.68.203.73 with SMTP id ko9mr308897pbc.170.1384846493192; Mon, 18 Nov 2013 23:34:53 -0800 (PST) Received: from localhost.localdomain (KD182249084229.au-net.ne.jp. [182.249.84.229]) by mx.google.com with ESMTPSA id km1sm9312038pbd.23.2013.11.18.23.34.48 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 18 Nov 2013 23:34:52 -0800 (PST) From: AKASHI Takahiro To: linux-audit@redhat.com Cc: will.deacon@arm.com, dsaxena@linaro.org, patches@linaro.org, AKASHI Takahiro Subject: [RFC PATCH] audit: Add generic compat syscall support Date: Tue, 19 Nov 2013 16:33:51 +0900 Message-Id: <1384846431-5781-2-git-send-email-takahiro.akashi@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1384846431-5781-1-git-send-email-takahiro.akashi@linaro.org> References: <1384846431-5781-1-git-send-email-takahiro.akashi@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: takahiro.akashi@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , lib/audit.c provides a generic definition for auditing system calls. lib/compat_audit.c similarly adds compat syscall support for bi-architectures (32/64-bit). Each architecture must define audit_is_compat() in asm/audit.h. Signed-off-by: AKASHI Takahiro --- include/linux/audit.h | 3 +++ lib/Makefile | 3 +++ lib/audit.c | 10 ++++++++ lib/compat_audit.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+) create mode 100644 lib/compat_audit.c diff --git a/include/linux/audit.h b/include/linux/audit.h index 729a4d1..f6c8d18 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h @@ -75,6 +75,9 @@ struct audit_field { extern int __init audit_register_class(int class, unsigned *list); extern int audit_classify_syscall(int abi, unsigned syscall); +#ifdef CONFIG_COMPAT +extern int audit_classify_compat_syscall(int abi, unsigned syscall); +#endif extern int audit_classify_arch(int arch); /* audit_names->type values */ diff --git a/lib/Makefile b/lib/Makefile index f3bb2cb..5bb185a 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -96,6 +96,9 @@ obj-$(CONFIG_TEXTSEARCH_BM) += ts_bm.o obj-$(CONFIG_TEXTSEARCH_FSM) += ts_fsm.o obj-$(CONFIG_SMP) += percpu_counter.o obj-$(CONFIG_AUDIT_GENERIC) += audit.o +ifeq ($(CONFIG_COMPAT),y) +obj-$(CONFIG_AUDIT_GENERIC) += compat_audit.o +endif obj-$(CONFIG_SWIOTLB) += swiotlb.o obj-$(CONFIG_IOMMU_HELPER) += iommu-helper.o diff --git a/lib/audit.c b/lib/audit.c index 76bbed4..fa373bd 100644 --- a/lib/audit.c +++ b/lib/audit.c @@ -1,6 +1,7 @@ #include #include #include +#include #include static unsigned dir_class[] = { @@ -30,11 +31,20 @@ static unsigned signal_class[] = { int audit_classify_arch(int arch) { +#ifdef CONFIG_COMPAT + if (audit_is_compat(arch)) + return 1; +#endif return 0; } int audit_classify_syscall(int abi, unsigned syscall) { +#ifdef CONFIG_COMPAT + if (audit_is_compat(abi)) + return audit_classify_compat_syscall(abi, syscall); +#endif + switch(syscall) { #ifdef __NR_open case __NR_open: diff --git a/lib/compat_audit.c b/lib/compat_audit.c new file mode 100644 index 0000000..837a6e6 --- /dev/null +++ b/lib/compat_audit.c @@ -0,0 +1,64 @@ +#include +#include +#include +/* FIXME: this might be architecture dependent */ +#include + +static unsigned compat_dir_class[] = { +#include +~0U +}; + +static unsigned compat_read_class[] = { +#include +~0U +}; + +static unsigned compat_write_class[] = { +#include +~0U +}; + +static unsigned compat_chattr_class[] = { +#include +~0U +}; + +static unsigned compat_signal_class[] = { +#include +~0U +}; + +int audit_classify_compat_syscall(int abi, unsigned syscall) +{ + switch(syscall) { +#ifdef __NR_open + case __NR_open: + return 2; +#endif +#ifdef __NR_openat + case __NR_openat: + return 3; +#endif +#ifdef __NR_socketcall + case __NR_socketcall: + return 4; +#endif + case __NR_execve: + return 5; + default: + return 1; + } +} + +static int __init audit_compat_classes_init(void) +{ + audit_register_class(AUDIT_CLASS_WRITE, compat_write_class); + audit_register_class(AUDIT_CLASS_READ, compat_read_class); + audit_register_class(AUDIT_CLASS_DIR_WRITE, compat_dir_class); + audit_register_class(AUDIT_CLASS_CHATTR, compat_chattr_class); + audit_register_class(AUDIT_CLASS_SIGNAL, compat_signal_class); + return 0; +} + +__initcall(audit_compat_classes_init);