Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1687977ybi; Wed, 17 Jul 2019 20:09:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqwaPGDdy6Lz5v0udikUWGouB8Cg5FhhS0Oj+FuyWNGltpgSqSlXNSYZ2PgtTLCQRP9ssPNM X-Received: by 2002:a63:2148:: with SMTP id s8mr44169303pgm.336.1563419352346; Wed, 17 Jul 2019 20:09:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563419352; cv=none; d=google.com; s=arc-20160816; b=QLj0M3Gh9Z+kuKZok3qgdGcHIwX4cGqmATcKZiDc5ca2uNN39fE8y+izxKVezdmiHp wru0erJBN7wMYPHqNwFWmIWD5Ux73uNyUmpWUaPY5nKegfixeMIxPlMM7Zy0YtjsbJdL KMl9G5+UEg4mc2gN0k+fXjd0F/8SBS9OuryQgcuc6VzCY3vkocgR1HKwIJP9JZoHsAyL 4HKaRkDg6XCEyFKbgo8FJQ22iMXBOv9J9CkDiwiqoT+HLK2zZQcBYqf+BVb2vgyIm3wP AVFQi/mrwx5Jd3fAXiwMAfO7H15SwhP7nFHScqiRy0aEhIZ1oLTEMIBsaJ93v6PYCMnX Gz6g== 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=bApCpyk64IZbYEWQ+Ppw8pcW20GDOCM/ybtHMwjgKRQUam2cH38bKIZ4YVGECM0Cl7 awCAaEzbYZWcxUVcqU2COQpkfpK53qvK50z8oiScQPGEpcPg5YRIteTnZGysmG11B0O7 Uaz0pw/60DVj/Lk/eKNAEnoYmgwU0kBuiROR3Q2xRzD6DDXlaMzceponYhotRW6w35IA /QTIL7QPAW8yptWVDwaDB3Hy/PjtXzZmxYlDLoo0xJbFNN2ajaL/AfgH6pDcIURFlVSa RjXSEX2FDrXoWNgQQAuFpEwL5qaOs/q7qMoKFKXSGs8aut0SHstUjLwYTOc9m67KXYBv gkzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xX3wnqLd; 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 em9si1281980pjb.37.2019.07.17.20.08.56; Wed, 17 Jul 2019 20:09:12 -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=xX3wnqLd; 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 S2390297AbfGRDGq (ORCPT + 99 others); Wed, 17 Jul 2019 23:06:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:38072 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389172AbfGRDGo (ORCPT ); Wed, 17 Jul 2019 23:06:44 -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 42A9D204EC; Thu, 18 Jul 2019 03:06:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563419204; bh=XZdhTy0JEJZY3lK6Jn/I1noxcLUvIqAh9WQXu1Larbs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xX3wnqLd9UZqgHoQcx+R8D5QGob0mu7IE9kQ2sbs+eUgnme2H3fynkqEjhAZ0CmS0 4hMfYp69O2zGM73fr7Tr8FQbNKYW/J+KhgA8xV8k6mGKdjXRW+nFujt9659BfjdRTN kg2ll2p3bPVKEI1QAw8KPuErStKRRugjqIItOjGc= 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 4.19 06/47] firmware: improve LSM/IMA security behaviour Date: Thu, 18 Jul 2019 12:01:20 +0900 Message-Id: <20190718030048.929280831@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190718030045.780672747@linuxfoundation.org> References: <20190718030045.780672747@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); }