Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1684058ybi; Wed, 17 Jul 2019 20:05:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqwHm2skW3gakbcRUc4KxuEG3AgODPuVyMJtpkBv2CyNZwZiVZJJSFxbcweTkF9hEi9bXBb9 X-Received: by 2002:a17:90a:3548:: with SMTP id q66mr48775798pjb.17.1563419111354; Wed, 17 Jul 2019 20:05:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563419111; cv=none; d=google.com; s=arc-20160816; b=r/nHaxWvV65a2wiExJGEES62c9eIXSGmUweSFy12KG/h5YSnljtMqBvKVl9Qj5Z18g sETuQv8pR0SWX0XCGUGs6j8NnO+jYLTjm2zjzWg6uvv5N1XI8NvelMizDYHzgf4hCjzR 4amsd2gZaHsebH044/G/WoVtRfvm+Rd1t4UJTcwmnSMut1rTYAmzhsh6mEeGWHfZRzLM ptrlSL1dxFjTSzFzJvm8pdnpKsmXRk4KgTkTgHp70Ia6Z393hj3uT6kpw+1fA4qSzF3+ WuWVZUNI6/qIBzkUTNGZw//6cTXiVyFsampPymo4hnL70wRAVZHsEG2gkYJ0ICeqcX+K klJA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zuY/PVhcAf8Vhl9tB+IZVpFFguhFSb7gYsg/Fx4MbX4=; b=LH2JgdwFg7bgMjDGDMWX2iw2w9NaeAKBF/SQugeQkS/5CblpGnSMY4wjF56xKs+bYC 2U25S8Z3ha4NAO9CVOnxbZO2SSi1t1EwQnhpv1LlZXANSLFwLtyKUcOqNruUW2U1XqW7 ewROY9Fjq0hnjuN9Wjtqij+hnxqaBMPMv7YgF69nudNfIaCMiygh/myXCTCTel9O2YlN warJSrjTqRm8OcALeN9BzHwMTfsp20AO2u+E9BzV5JdM6Aa3jTN8dNDAULmZ/GqV0QcS //XERuxMHl5RCBLpbbd9yZz1frI7UDxfiu9Ld6IdEisoi+m/esY4wiu5ge4XjNu4rpcS fM9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nzoifOEN; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 60si19138542plf.398.2019.07.17.20.04.54; Wed, 17 Jul 2019 20:05: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=@kernel.org header.s=default header.b=nzoifOEN; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389339AbfGRDD2 (ORCPT + 99 others); Wed, 17 Jul 2019 23:03:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:34104 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389318AbfGRDD0 (ORCPT ); Wed, 17 Jul 2019 23:03:26 -0400 Received: from localhost (115.42.148.210.bf.2iij.net [210.148.42.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D010721849; Thu, 18 Jul 2019 03:03:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563419006; bh=XZdhTy0JEJZY3lK6Jn/I1noxcLUvIqAh9WQXu1Larbs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nzoifOENBshaVXw5HuNO8fDSqPvcl+hTtd6DPS+WRrUOEDqCD6eSEnPaG3JhdUH7y 41g1GrXnN1iC7kMf8hdt3nl12kjayaU4z0rCDWwjiKPtsd4Vr2DVmBWxEC3WY/NzzC GDUIrqzzLRb3oQm3fLZchPJvMF9WN9kUwfZRSv7c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, Luis Chamberlain Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mimi Zohar , Kees Cook , "Rafael J. Wysocki" , Sven Van Asbroeck , Mimi Zohar Subject: [PATCH 5.2 06/21] firmware: improve LSM/IMA security behaviour Date: Thu, 18 Jul 2019 12:01:24 +0900 Message-Id: <20190718030031.805647808@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190718030030.456918453@linuxfoundation.org> References: <20190718030030.456918453@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sven Van Asbroeck commit 2472d64af2d3561954e2f05365a67692bb852f2a upstream. The firmware loader queries if LSM/IMA permits it to load firmware via the sysfs fallback. Unfortunately, the code does the opposite: it expressly permits sysfs fw loading if security_kernel_load_data( LOADING_FIRMWARE) returns -EACCES. This happens because a zero-on-success return value is cast to a bool that's true on success. Fix the return value handling so we get the correct behaviour. Fixes: 6e852651f28e ("firmware: add call to LSM hook before firmware sysfs fallback") Cc: Stable Cc: Mimi Zohar Cc: Kees Cook To: Luis Chamberlain Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Cc: linux-kernel@vger.kernel.org Signed-off-by: Sven Van Asbroeck Reviewed-by: Mimi Zohar Signed-off-by: Greg Kroah-Hartman --- drivers/base/firmware_loader/fallback.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/base/firmware_loader/fallback.c +++ b/drivers/base/firmware_loader/fallback.c @@ -659,7 +659,7 @@ static bool fw_run_sysfs_fallback(enum f /* Also permit LSMs and IMA to fail firmware sysfs fallback */ ret = security_kernel_load_data(LOADING_FIRMWARE); if (ret < 0) - return ret; + return false; return fw_force_sysfs_fallback(opt_flags); }