From patchwork Fri Jan 17 08:03:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 23285 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f199.google.com (mail-ob0-f199.google.com [209.85.214.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 30676202FA for ; Fri, 17 Jan 2014 08:04:04 +0000 (UTC) Received: by mail-ob0-f199.google.com with SMTP id vb8sf12720172obc.6 for ; Fri, 17 Jan 2014 00:04:03 -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=WRo9qD7snA/7s5BB9Uk+d3qxF9sDwOG+YzmQLkPHTZc=; b=SBWZLMVxQzal3EZJMG1w+adoVrzMDzX7G7b1vsqQqWGMQ2EpBCxCaav1LSFxEWzZ/4 8SX0o4743AEjjN01A26KxX6xk8wsPbQr+wFCPJUCGxvhlSZlx2qwRBBuvK77ZO6c32a6 Uc3H87DaTyqxLnGsrKOE5W5JWjPSLbNg3str+f2JxNNkjw4g0+v+zTrTjtdQ/I3C4uFs zg02xo13x+2Hc9hYO+uXYKwvFzkmYLuDxswOoEflZfOWKEb+fPiZIPrT8HR2dEkTf4Zp RbqQwM+ztpr8hxAvguG5jCgdvXiPXNeKFy0rLIRjtWzNbQSF35BguIZu74kogq2YHEl9 H1zQ== X-Gm-Message-State: ALoCoQnEokGpETh9G8cjXJVITrZZsybBaBoE7aFbvDj9IE/74Avt1qq9vaep7FUVeMkRJNAkd6Kj X-Received: by 10.43.4.4 with SMTP id oa4mr187329icb.2.1389945843311; Fri, 17 Jan 2014 00:04:03 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.0.174 with SMTP id 14ls1213023qef.5.gmail; Fri, 17 Jan 2014 00:04:03 -0800 (PST) X-Received: by 10.220.191.134 with SMTP id dm6mr239359vcb.16.1389945843198; Fri, 17 Jan 2014 00:04:03 -0800 (PST) Received: from mail-ve0-f175.google.com (mail-ve0-f175.google.com [209.85.128.175]) by mx.google.com with ESMTPS id sp7si4539038vdc.8.2014.01.17.00.04.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 17 Jan 2014 00:04:03 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.175; Received: by mail-ve0-f175.google.com with SMTP id jx11so1431812veb.20 for ; Fri, 17 Jan 2014 00:04:03 -0800 (PST) X-Received: by 10.58.119.161 with SMTP id kv1mr194074veb.21.1389945843128; Fri, 17 Jan 2014 00:04:03 -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.59.13.131 with SMTP id ey3csp1864ved; Fri, 17 Jan 2014 00:04:02 -0800 (PST) X-Received: by 10.68.229.36 with SMTP id sn4mr573259pbc.23.1389945842138; Fri, 17 Jan 2014 00:04:02 -0800 (PST) Received: from mail-pb0-f43.google.com (mail-pb0-f43.google.com [209.85.160.43]) by mx.google.com with ESMTPS id nu5si9407034pbc.358.2014.01.17.00.04.01 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 17 Jan 2014 00:04:02 -0800 (PST) Received-SPF: neutral (google.com: 209.85.160.43 is neither permitted nor denied by best guess record for domain of takahiro.akashi@linaro.org) client-ip=209.85.160.43; Received: by mail-pb0-f43.google.com with SMTP id md12so3800904pbc.30 for ; Fri, 17 Jan 2014 00:04:01 -0800 (PST) X-Received: by 10.68.66.103 with SMTP id e7mr617921pbt.120.1389945841724; Fri, 17 Jan 2014 00:04:01 -0800 (PST) Received: from localhost.localdomain (KD182250177246.au-net.ne.jp. [182.250.177.246]) by mx.google.com with ESMTPSA id tu3sm20518710pbc.40.2014.01.17.00.03.56 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 17 Jan 2014 00:04:00 -0800 (PST) From: AKASHI Takahiro To: viro@zeniv.linux.org.uk, eparis@redhat.com, rgb@redhat.com Cc: catalin.marinas@arm.com, will.deacon@arm.com, arndb@arndb.de, linux-arm-kernel@lists.infradead.org, linaro-kernel@lists.linaro.org, linux-kernel@ver.kernel.org, linux-audit@redhat.com, patches@linaro.org, AKASHI Takahiro Subject: [PATCH v3] audit: Add generic compat syscall support Date: Fri, 17 Jan 2014 17:03:15 +0900 Message-Id: <1389945795-4255-2-git-send-email-takahiro.akashi@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1389945795-4255-1-git-send-email-takahiro.akashi@linaro.org> References: <1384854235-6567-1-git-send-email-takahiro.akashi@linaro.org> <1389945795-4255-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.128.175 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. This patch extends it for compat syscall support on bi-architectures (32/64-bit) by adding lib/compat_audit.c when CONFIG_COMPAT enabled. Each architecture that wants to use this must define audit_is_compat() in asm/audit.h. Signed-off-by: AKASHI Takahiro --- include/linux/audit.h | 9 +++++++++ lib/Makefile | 3 +++ lib/audit.c | 17 +++++++++++++++++ lib/compat_audit.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ 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 bf1ef22..3d71949 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h @@ -78,6 +78,15 @@ extern int is_audit_feature_set(int which); extern int __init audit_register_class(int class, unsigned *list); extern int audit_classify_syscall(int abi, unsigned syscall); extern int audit_classify_arch(int arch); +#if defined(CONFIG_AUDIT_GENERIC) && defined(CONFIG_COMPAT) +extern unsigned compat_write_class[]; +extern unsigned compat_read_class[]; +extern unsigned compat_dir_class[]; +extern unsigned compat_chattr_class[]; +extern unsigned compat_signal_class[]; + +extern int audit_classify_compat_syscall(int abi, unsigned syscall); +#endif /* audit_names->type values */ #define AUDIT_TYPE_UNKNOWN 0 /* we don't know yet */ diff --git a/lib/Makefile b/lib/Makefile index a459c31..73ea908 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -93,6 +93,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..e29ba82 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: @@ -57,6 +67,13 @@ int audit_classify_syscall(int abi, unsigned syscall) static int __init audit_classes_init(void) { +#ifdef CONFIG_COMPAT + audit_register_class(AUDIT_CLASS_WRITE_32, compat_write_class); + audit_register_class(AUDIT_CLASS_READ_32, compat_read_class); + audit_register_class(AUDIT_CLASS_DIR_WRITE_32, compat_dir_class); + audit_register_class(AUDIT_CLASS_CHATTR_32, compat_chattr_class); + audit_register_class(AUDIT_CLASS_SIGNAL_32, compat_signal_class); +#endif audit_register_class(AUDIT_CLASS_WRITE, write_class); audit_register_class(AUDIT_CLASS_READ, read_class); audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class); diff --git a/lib/compat_audit.c b/lib/compat_audit.c new file mode 100644 index 0000000..94f6480 --- /dev/null +++ b/lib/compat_audit.c @@ -0,0 +1,51 @@ +#include +#include +/* FIXME: this might be architecture dependent */ +#include + +unsigned compat_dir_class[] = { +#include +~0U +}; + +unsigned compat_read_class[] = { +#include +~0U +}; + +unsigned compat_write_class[] = { +#include +~0U +}; + +unsigned compat_chattr_class[] = { +#include +~0U +}; + +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; + } +}