Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp1319765ybg; Wed, 29 Jul 2020 11:01:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVl0U4BLZZ6CkZxKt+riXy8p2+1XDEKQYYiBZeNQidR/jue5xfZGXRx8f2HzV1pYshQobi X-Received: by 2002:a17:907:444c:: with SMTP id on20mr30607891ejb.77.1596045713476; Wed, 29 Jul 2020 11:01:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596045713; cv=none; d=google.com; s=arc-20160816; b=w97rOyeM62NLkLa5ouel5mGi3ZXC+HjkHtm0CMQrhzgfr5tFkofzrqrnoH7dfrtR+y /+7/HHCfnzr2tEYVX8SU3h7PQ0TLFzuOZEHWCZt1S/tSHgarL4mqujUuFU+fFRBT0Hvb Qyb6SdLCmnFtssveZRe4LFSnC4o9scSFkf1avjLkW5pS3cwnSb/QG1/fvyst13VEvi75 LBpQQpNoHLQ/WoQ/QWTjSz1PqDh6y1stp0coFxj7B4D44iF1Gaez5SUZE606TmLPScyR vgCYYFNgAkS0MrSiXgksFfb6GDgmY5jPwTv+S5DYwdR/HFM7WlVUgndmGh+keljfucGa MJ4Q== 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=2dckHYDBSef92hBk0hdLw37DCCWMtjung/PzGLRIGlQ=; b=0xRopTxZ3/UcB9heybIX0Hepw2oIdiQuoaNP2tj4vlOd224dIEC2SclaBlsza/2mz8 JXypPa6YMVMZBSxnP19NL+wB2nVl+44bZhq4zFqBBF4MLT5thqmubChJJXx8G4CjuI6P YB5Q4rQViifxunW28OFWerjUzgNCBN36L7VZ8qVFy6Sw+IoIv6+vfH7nBK4QaA9vwUzi TG9qob9OU1gSpLk3oOMYlzV+kp1dcbqjstLJnVO7qkahEAbGt17cthz0H9z5Y42iVbqD ov4hj5nJSuR05dAwWlnk6fr6j17i6dbPIuhsOFn/zWej+Do9xAibMHnx6RqbpBXm+TH6 pL6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PeYr3jVB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f1si1760630edw.580.2020.07.29.11.01.31; Wed, 29 Jul 2020 11:01:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PeYr3jVB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727928AbgG2R7K (ORCPT + 99 others); Wed, 29 Jul 2020 13:59:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727918AbgG2R7G (ORCPT ); Wed, 29 Jul 2020 13:59:06 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1ECBFC0619DD for ; Wed, 29 Jul 2020 10:59:05 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id t6so14687233pgq.1 for ; Wed, 29 Jul 2020 10:59:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2dckHYDBSef92hBk0hdLw37DCCWMtjung/PzGLRIGlQ=; b=PeYr3jVB7W6UcW212/oJZmLRi4czVPcQjfijK3aeH7rdxGYPMC62JtlyIoOxj7gwy5 c2dWpHJMjKgNg5+GOs7lE5ptFlJbitvkjzFCMkK2BuSsglPWQHHRYHbZXOmZVOOvVeL9 AXbaJuHNrbC7ktjkX3HyAY7OqVwqAjEvn/WKk= 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=2dckHYDBSef92hBk0hdLw37DCCWMtjung/PzGLRIGlQ=; b=K90GYkXSwn5SdTywgEJMq6Nez/qixGC3a2W2XO8wr1be36jJ9Yv1dnCfmC1LADce1v ouLJS59DamMl8+I+qymBSttMkeD8IEHwm4zaKFaUzFEMTim473M1ugZmfe9MiKthCmxT SZI+4f88pNoGmM2KBVW1ncOIUx7x2E9PCxQhokNq/KmfUYKqx1eGhy+w9xhfZZBWIW+Q aRWi1w0SxWdH42USYCDjtPBmqrizTxwMhYr43l/kcyJKCcSLG5Dva94GyG4wyTOCZ2jQ BPAb9FJJvpR6jXw70FhujL3elDjSZxH6svTMaMkVnhJcyZnJrCd6sLJ/CmyxmoPzlr+C bH2w== X-Gm-Message-State: AOAM532QcqtNMlfrhSwBQecARNQ8FykgQI6jxBa8KgYtv1h+0uMsiY5x Te6emS3gOJ+wolKsJ1oUWhee3w== X-Received: by 2002:a65:64c5:: with SMTP id t5mr30425186pgv.28.1596045544724; Wed, 29 Jul 2020 10:59:04 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id t73sm3172293pfc.78.2020.07.29.10.58.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jul 2020 10:58:58 -0700 (PDT) From: Kees Cook To: Greg Kroah-Hartman Cc: Kees Cook , Jessica Yu , Scott Branden , Mimi Zohar , Luis Chamberlain , Takashi Iwai , SeongJae Park , KP Singh , linux-efi@vger.kernel.org, linux-security-module@vger.kernel.org, linux-integrity@vger.kernel.org, selinux@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 11/17] module: Call security_kernel_post_load_data() Date: Wed, 29 Jul 2020 10:58:39 -0700 Message-Id: <20200729175845.1745471-12-keescook@chromium.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200729175845.1745471-1-keescook@chromium.org> References: <20200729175845.1745471-1-keescook@chromium.org> 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 Now that there is an API for checking loaded contents for modules loaded without a file, call into the LSM hooks. Cc: Jessica Yu Signed-off-by: Kees Cook --- kernel/module.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/kernel/module.c b/kernel/module.c index d773f32f8dfd..72e33e25d7b9 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -2970,7 +2970,7 @@ static int copy_module_from_user(const void __user *umod, unsigned long len, if (info->len < sizeof(*(info->hdr))) return -ENOEXEC; - err = security_kernel_load_data(LOADING_MODULE, false); + err = security_kernel_load_data(LOADING_MODULE, true); if (err) return err; @@ -2980,11 +2980,17 @@ static int copy_module_from_user(const void __user *umod, unsigned long len, return -ENOMEM; if (copy_chunked_from_user(info->hdr, umod, info->len) != 0) { - vfree(info->hdr); - return -EFAULT; + err = -EFAULT; + goto out; } - return 0; + err = security_kernel_post_load_data((char *)info->hdr, info->len, + LOADING_MODULE); +out: + if (err) + vfree(info->hdr); + + return err; } static void free_copy(struct load_info *info) -- 2.25.1