Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1065971yba; Fri, 3 May 2019 15:28:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqzkNamHW9jTcmkFh0Q3CIbDkS4U5ACI0jsGFQg7HM/CYWfGPDONb9Z3GGcWA2gIxDXfRiik X-Received: by 2002:a63:2118:: with SMTP id h24mr14093955pgh.320.1556922487523; Fri, 03 May 2019 15:28:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556922487; cv=none; d=google.com; s=arc-20160816; b=KqcBJ33evbDX6wz2i9zWjZ6ZgZnRIcUwBQmvJ7FxcYWFjGUK5bB3jcL1HAAkLkdVLw +JimZ2irpHifLHekfCYkB1YkdQJz+p38ed6gCW/1G2WeNRitPvFg7f4xX7e1d/va5WLH CFsGEb+enMHfRsfsuqtEHT7klW23gUvVVYQ5v8E1vjnf+oGWggpVIO0SnjbFbp08ahvQ 2bUXl+m7Q2rzRJAQNpjYDBce6C5nz5E9IMzabMWSlehT1Kmbp5iw91DMYa+DA4NTIp3r 6LDxX9V7R6Z7F5J4srxUXeAAHS0ztpqSvx+8ovI4URIUXb8QF3dmMFJhMZh2TkscSAd6 XG0w== 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=Vw/WCoWJC8LG27VjrkL+CC1VMWeROo418tAMf4jQKGQ=; b=eaqfhnMd4z1/THOI3S7azH/HSmW/W+3DF1XphOhuzNDf9j7zA+bExGeBgjYvxZ2wW/ wHcMT6qtcvjM/9Ftk2ujRQHNuyztLcKx6v34KRqk74MweNs92yNYKyhaFvd+fDAxcSYA 3faI0RV3sLuoMGh1wQNncXclGZ4QwYr3aGmR5GxMWOFAcqCnm6aQ0t2NEHkb9n9w3ERd YlwIsDlnGFP+WSZSaQPBJrk5LgtKUuUZ9qAY5RvcDqBmKQQB3A/ntopiMWN2sN3gUH7J EP1ScHYWIMZK/rIjJ/uMU3b9z2v1d7b3xkHm8uoPXwHgL/KXNpYOKusNYb1WqBlMgNJY xaCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mdGH1SaH; 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 y19si4110153pgh.333.2019.05.03.15.27.52; Fri, 03 May 2019 15:28:07 -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=mdGH1SaH; 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 S1726976AbfECWZk (ORCPT + 99 others); Fri, 3 May 2019 18:25:40 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:38152 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726883AbfECWZe (ORCPT ); Fri, 3 May 2019 18:25:34 -0400 Received: by mail-pf1-f193.google.com with SMTP id 10so3563136pfo.5; Fri, 03 May 2019 15:25:33 -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=Vw/WCoWJC8LG27VjrkL+CC1VMWeROo418tAMf4jQKGQ=; b=mdGH1SaHShD+kgLt/Fx6BWhW6AJ0v4kausIuhDquzZhHChDRtQZM/OK/MHkvW4xUQl WCusueh03W4KqzU2NPxy/5BZ1p1pR6tOamo1uDRB+7/z4vXp6lMkNIuAMBmJnnFsAkFn 5XJ6Tmexbpzdv6RHSqiW8HjXN3PgtrZHoaCprVtCtYraLjgNZQ5xYxShCIAohXx3j44y LxPaIx2eMTv/5BY1O/mHjfPFoGSnGxAc8TrPWBlgspy7I/TGxEsszBrpcvku8euWSo2m o8fVgp5Uor0whNnbajXLVzVIR6VbGuze5KOX/L5k8eUiT8lwz+/nJLmxrshnhgti9jAI QRPg== 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=Vw/WCoWJC8LG27VjrkL+CC1VMWeROo418tAMf4jQKGQ=; b=nGp+dMHsrN93DsWxXY9qKayGNQx7Lc+5aghXnhOOKqCT4enu6zK/RV11B3oFKC0rJi O5S/QGWQ1VnjxR5twYvdCBYTeWY2v8/W0JXL3ybLRGmQASAxx3CrtKCTzyyXYrvJXFPQ y4kCueLjUr8EAGgSRPgRFnwFvX0x0o8I2APIVycgtmc1IhCiDwQIBASZz2SlcgmHY5ZZ 0mAAb3KlF9siqVcKWs2QDqT00qNFoRPmBesDdHFKawiS0BSa90YltzB6UN7JStrFwCRE Y2b3wC+Pg1dzVY54+IazZjAwaALoZ2WVQrvhIt2fOEEJF96aEVTYdJA0BJ8leWi2jq99 WD0A== X-Gm-Message-State: APjAAAVmE9NeROVQC/uP2Beb7JRNLmhE4Qa1dWZ6YYoJx/6+AKRnJsAl B2Y6sOwkPpRcApMxJqjJ7U0el+GIqQg= X-Received: by 2002:a62:5915:: with SMTP id n21mr14163364pfb.180.1556922333427; Fri, 03 May 2019 15:25:33 -0700 (PDT) Received: from prsriva-linux.corp.microsoft.com ([2001:4898:80e8:b:3170:1a6b:a13a:7ff]) by smtp.gmail.com with ESMTPSA id j22sm4314337pfi.139.2019.05.03.15.25.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 May 2019 15:25:32 -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, nramas@microsoft.com, prsriva@microsoft.com, Prakhar Srivastava Subject: [PATCH 4/5 v4] added LSM hook to call ima_buffer_check Date: Fri, 3 May 2019 15:25:22 -0700 Message-Id: <20190503222523.6294-5-prsriva02@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190503222523.6294-1-prsriva02@gmail.com> References: <20190503222523.6294-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 add a LAM hook for kexec_cmldine args to be made available to other LSMs. 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.20.1