Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4157031yba; Mon, 29 Apr 2019 14:49:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqxhkuQvMevZziLcOjAAY9uo+ewE7N5Ig3ffKBq0AXcsaC5CjM94Lcf1x0sR3vG64PlSz68J X-Received: by 2002:a63:b305:: with SMTP id i5mr61772128pgf.274.1556574551596; Mon, 29 Apr 2019 14:49:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556574551; cv=none; d=google.com; s=arc-20160816; b=QhI1yCZ9IydVfMdxwSQUPkNiT6w/NuRXWzPPvkqYo0qvY47tShALjkqLm4e+uGr11e 6R2fXorAhUR6JARrbgf/JBC74th52nV1QPssyjHxfZZ3yFYcKX5NDic1ZnWWsk5luKRu ogeyaxBBa+01t8rfHL7NAlOOIoG7uXmYNNB0aT/8S+oSwIqgS3cRDU/mWoA/hhNYjC8z TxIPnpU0SKAgH6ooip61qGz5YPjhiGEdvJNFCgbgjN0CWSEH89HGS8kI/IvU1r/0xsOK r2B8AOFaT6SBAR75MHVKfwj7qtN1ESrLdSTRU8Y4PTXFaINpOnl/fGxnVACXefUZZuZb keWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vC2GXHNilPvXhdB73Lv0ZCT32JKOSQmVgBIM8AzGRek=; b=Cwg04hGcZaiDqlaZewgISm19Gcw1MrbB8AU1JyEoJGNn27l4s8ZTeUsTHv7+33T2PX Xz+DmBecZB8moxIeLAHQ6eKLsQ/hH/zaVc4EIA0tQkjmrE3ngHt6PNj1/RHkPfoQhKa3 5KRT3KwB+t3wd6thydraBaNQW7UUj/1pIFb9wtdGda4nxmtHzD3hZhO2xb+ThEe4XnWo LeZ6vC7TPcn+/goL77JWpLvIPfNuW0uwKojmsUk5aLJoHrrVnxJMyKN0JjFsHXkPA1Jo zFIwUcjaKjKFtjIAiIcCTjYFIXk/Eus3S5L/Rhvob6GDfWYDEY/tmHBRuZ+9W56CAn4c v8pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dFjhYTdw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z29si2069955pgl.584.2019.04.29.14.48.56; Mon, 29 Apr 2019 14:49:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dFjhYTdw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729569AbfD2Vr6 (ORCPT + 99 others); Mon, 29 Apr 2019 17:47:58 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:44274 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729561AbfD2Vr4 (ORCPT ); Mon, 29 Apr 2019 17:47:56 -0400 Received: by mail-pl1-f196.google.com with SMTP id l2so2940000plt.11; Mon, 29 Apr 2019 14:47:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vC2GXHNilPvXhdB73Lv0ZCT32JKOSQmVgBIM8AzGRek=; b=dFjhYTdwh18s7b32WrTelepOdhNieNtMScS26bG9wWe6fkjHx971LFmOwEhBD6Y+7l KaXpTnPW9xJWYTQzPrkNG3UMF9vBuBEpjfixDTT52IhwuR03dqdiSxS6ffSBYLjJvx27 RUVsWBFNiqpQ/a4ekoYKDVIu+h2lzsMfCT0BDFsqsqM+uuqQbPiL+VWTQD6H1XcGJ1+J FdASScm1XtCCPGWmk1cZ7mH0VIXiemTTUDOhnZVVg6eZgudcTNQSG3LGCzTXuPM74cUB yvmgre00dbHOx4MNPkhNKTLP1HgP3RmrflHlENmYgplaimDQjWkrLZc23u69LU1syRNS v5fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vC2GXHNilPvXhdB73Lv0ZCT32JKOSQmVgBIM8AzGRek=; b=BstKEjW1BNrOpEWFg+RYCwdhFp04GcFx4sabA6+LLr1QiihJoZb/fCaqdhvSnxqany zzxYOZpU0IiR0G3JRqJHhJGdc7aDqPPLa7FpxmCY03XjCmhZSJE6Z+PE2JTjKAm7y3qL v3JxnhztPvmpgonFwR5T7+EVGVvJvFxTcgZzpkHHAVGXnNg3vbyE+/28imqD1OAuble8 8Gf01Dm/dnHkjjqP/se9E/Lt290k+EAtICZ3Ha/9Z8n1OU/ZVrTbK9fbupoxkmByI3am KmhmcwFvdvZFjiuc2Q3RZmFv9UzYdhBnNN2nI5KpkhmV+PUHX+OewFjHbNZPPt92jiOO yMog== X-Gm-Message-State: APjAAAUcf2TtFmCt9d5aZlMmNcccpElg4OWqaXPW6Vw+ebPFkYiFG2RL LuJCpTeyfLmmW7s91Bx74SLliZMK3Gk= X-Received: by 2002:a17:902:6b:: with SMTP id 98mr49167313pla.271.1556574475155; Mon, 29 Apr 2019 14:47:55 -0700 (PDT) Received: from prsriva-linux.corp.microsoft.com ([2001:4898:80e8:9:445d:9822:2ddb:fb8c]) by smtp.gmail.com with ESMTPSA id f66sm1941623pfg.55.2019.04.29.14.47.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Apr 2019 14:47:54 -0700 (PDT) From: Prakhar Srivastava X-Google-Original-From: Prakhar Srivastava To: linux-integrity@vger.kernel.org, linux-secuirty-module@vger.kernel.org, linux-kernel@vger.kernel.org Cc: zohar@linux.ibm.com, ebiederm@xmission.com, vgoyal@redhat.com, nayna@linux.ibm.com, Prakhar Srivastava Subject: [PATCH v3 4/4] added LSM hook to call ima_buffer_check Date: Mon, 29 Apr 2019 14:47:43 -0700 Message-Id: <20190429214743.4625-5-prsriva02@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190429214743.4625-1-prsriva02@gmail.com> References: <20190429214743.4625-1-prsriva02@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Prakhar Srivastava added LSM hook to call ima_buffer_check Signed-off-by: Prakhar Srivastava --- include/linux/lsm_hooks.h | 3 +++ include/linux/security.h | 3 +++ kernel/kexec_internal.h | 4 +++- security/security.c | 6 ++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h index a240a3fc5fc4..f18562c1eb24 100644 --- a/include/linux/lsm_hooks.h +++ b/include/linux/lsm_hooks.h @@ -1672,6 +1672,8 @@ union security_list_options { int (*inode_setsecctx)(struct dentry *dentry, void *ctx, u32 ctxlen); int (*inode_getsecctx)(struct inode *inode, void **ctx, u32 *ctxlen); + int (*buffer_check)(const void *buff, int size, const char *eventname); + #ifdef CONFIG_SECURITY_NETWORK int (*unix_stream_connect)(struct sock *sock, struct sock *other, struct sock *newsk); @@ -1945,6 +1947,7 @@ struct security_hook_heads { struct hlist_head inode_notifysecctx; struct hlist_head inode_setsecctx; struct hlist_head inode_getsecctx; + struct hlist_head buffer_check; #ifdef CONFIG_SECURITY_NETWORK struct hlist_head unix_stream_connect; struct hlist_head unix_may_send; diff --git a/include/linux/security.h b/include/linux/security.h index 49f2685324b0..8dece6da0dda 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -388,6 +388,7 @@ void security_inode_invalidate_secctx(struct inode *inode); int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen); int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen); int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen); +void security_buffer_measure(const void *buff, int size, char *eventname); #else /* CONFIG_SECURITY */ static inline int call_lsm_notifier(enum lsm_event event, void *data) @@ -1188,6 +1189,8 @@ static inline int security_inode_getsecctx(struct inode *inode, void **ctx, u32 { return -EOPNOTSUPP; } +static inline void security_buffer_measure(const void *buff, int size, char *eventname) +{ } #endif /* CONFIG_SECURITY */ #ifdef CONFIG_SECURITY_NETWORK diff --git a/kernel/kexec_internal.h b/kernel/kexec_internal.h index 48aaf2ac0d0d..9f967fbb5aa0 100644 --- a/kernel/kexec_internal.h +++ b/kernel/kexec_internal.h @@ -12,7 +12,9 @@ int kimage_load_segment(struct kimage *image, struct kexec_segment *segment); void kimage_terminate(struct kimage *image); int kimage_is_destination_range(struct kimage *image, unsigned long start, unsigned long end); - +int kexec_cmdline_prepend_img_name(char **outbuf, int kernel_fd, + const char *cmdline_ptr, + unsigned long cmdline_len); extern struct mutex kexec_mutex; #ifdef CONFIG_KEXEC_FILE diff --git a/security/security.c b/security/security.c index 23cbb1a295a3..2b575a40470e 100644 --- a/security/security.c +++ b/security/security.c @@ -754,6 +754,12 @@ int security_bprm_check(struct linux_binprm *bprm) return ima_bprm_check(bprm); } +void security_buffer_measure(const void *buff, int size, char *eventname) +{ + call_void_hook(buffer_check, buff, size, eventname); + return ima_buffer_check(buff, size, eventname); +} + void security_bprm_committing_creds(struct linux_binprm *bprm) { call_void_hook(bprm_committing_creds, bprm); -- 2.19.1