Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp3523ybh; Tue, 21 Jul 2020 14:47:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGp/h6z0uKa5ime0cgXyZSf+l4kuwTLnQ6WrfEhL8FL4+yPV94TRmcvfdPb5sh/yFR/0aG X-Received: by 2002:a17:907:212b:: with SMTP id qo11mr26739008ejb.452.1595368037115; Tue, 21 Jul 2020 14:47:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595368037; cv=none; d=google.com; s=arc-20160816; b=XznryihleKySVJm8vH0WAZ1HBcUd1lZYBcZC3oX07yZBtVo4GLbVhUFP6KQDco5LOw uClJD1ZaTWFGytWxknof8oarTzN7+RuuL+IrSKWYVw+WEuln4WLqoLjDcHk0HMV6MapG aQA/K7Bi8jseEweN2VTMlF+KDSMAky5YyQqMiOAGtyy1woJy+1pZRw/7Lx2exPdvZxng MA+OgZjiV6KDMqMV9Fpnr7pLSFztd5Tz0lDmPO7uQH+Q1cx0EiEvBodVveQ6GBrDQZ2e VOiTZwCIFq05bPLZFmg5zg9DyMM9+F8gPR5DvBcfs2bMKAul4KlIxOUAvLBOGytuE9gQ t68Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=xi0hCpRkmcf6gK8tASFxK3aaOMPZtOr07eR1uGQZQ3Q=; b=S7+nrI1xVnG8iI5YdjZiJUXc4cmfwsmyl0/X7mzGvPRS5UIWDPjOz13+gAWUKjHr+4 8QF7ZoPllIzjq5+RI0r1E20P+8bGuL7lgv3dd3Hwmewgkq4MfoM/Yx/QvnL/iX1GcTiN SfwxhKYIDbGNR0/LBWUNt3Bvy3Hj5h/Al/FYDsUpfh5+Rv+cx06VUP09jy/JyTkQSxkr CntQF+3InOaPMPAp4QVVkq9Xx/MvB06DvnunQmgtdJUdwCW2Lb8r03pvZBO4yZjNZwEf J/Z7xTD+JS9mmW/p4jic2QndZOtfwHKqM6WUCoI+5cwqeBZuOvqtkICvYechpsqjpUhe PLGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=WyitzgLC; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id re8si11982092ejb.627.2020.07.21.14.46.52; Tue, 21 Jul 2020 14:47:17 -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=@broadcom.com header.s=google header.b=WyitzgLC; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731245AbgGUVn0 (ORCPT + 99 others); Tue, 21 Jul 2020 17:43:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731257AbgGUVnT (ORCPT ); Tue, 21 Jul 2020 17:43:19 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBC7EC0619DE for ; Tue, 21 Jul 2020 14:43:18 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id a6so3040226wmm.0 for ; Tue, 21 Jul 2020 14:43:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=xi0hCpRkmcf6gK8tASFxK3aaOMPZtOr07eR1uGQZQ3Q=; b=WyitzgLCPTotTvFyXBjJCUBLv9LTVIGuV0BLXP/t+rNxyFRvxJQhiYjVQxrxFWakWu 49H70+HEYP6PnW9KhlJ465HMbNOR6C7Be16Ag+Ttve3BCJ0H/uLHpyc9JTOy696ifuKV FDhgso1RDz81jzni2fNhhGBmN+KDfYXTEOgY4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=xi0hCpRkmcf6gK8tASFxK3aaOMPZtOr07eR1uGQZQ3Q=; b=VP/XFCkhebC9kDjim/KGig68kE6auNznSrEEhfUCMLw3VfeN5pPP/Fo8PYo6TqQ6xg J002Q7+MsVvd3ICAIDUAtlWFwfWs0B+1qELtszwHMsJSvJIwMigZtSRI59uqLJfLqjfL 7EQbxKx9ihuc4u44WZK8TJ7KHknNgVhqZthhuQiHrax74QMBHoAPzejtr15Yv6yMUVv8 vkWERsl+KzZsmVhJ3nb3a76VO0Ten9lC5a9uHyrNKjRpdKy3qvAhcIOi/P98/muj3cnC 37xzvb8qGbTXac0rj5jtR9mh/x2Qws1oyf3Rq7hmTyhCHhJSPhCAYgEhb7pTcnLgQLw4 c3iQ== X-Gm-Message-State: AOAM531zCb1LPeJevCubPzUVwrE4x3/5sntkKsa5TDk1tehMZh5uyPtY 8dPxGa78f9DbihWBU6Kiz/cUtr6eO7YBgdJouep/LMa1CPkZQqHLYIEYhJ9qhgeVZ9iKmucix/I bcA5ifSX8eqVZyPXYN0CsoI2jFfgbPaFy1Ios77JLZ38c4+YQcQEqlbW75t9ZkFh5p36zzEW4KL WlDyjZee3B X-Received: by 2002:a1c:2402:: with SMTP id k2mr5758664wmk.138.1595367797160; Tue, 21 Jul 2020 14:43:17 -0700 (PDT) Received: from [10.136.13.65] ([192.19.228.250]) by smtp.gmail.com with ESMTPSA id y11sm23591601wrs.80.2020.07.21.14.43.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Jul 2020 14:43:16 -0700 (PDT) Subject: Re: [PATCH 06/13] fs/kernel_read_file: Remove redundant size argument To: Kees Cook Cc: Mimi Zohar , Matthew Wilcox , James Morris , Luis Chamberlain , Greg Kroah-Hartman , "Rafael J. Wysocki" , Alexander Viro , Jessica Yu , Dmitry Kasatkin , "Serge E. Hallyn" , Casey Schaufler , "Eric W. Biederman" , Peter Zijlstra , Matthew Garrett , David Howells , Mauro Carvalho Chehab , Randy Dunlap , "Joel Fernandes (Google)" , KP Singh , Dave Olsthoorn , Hans de Goede , Peter Jones , Andrew Morton , Stephen Boyd , Paul Moore , Stephen Smalley , linux-security-module@vger.kernel.org, linux-integrity@vger.kernel.org, selinux@vger.kernel.org, linux-fsdevel@vger.kernel.org, kexec@lists.infradead.org, linux-kernel@vger.kernel.org References: <20200717174309.1164575-1-keescook@chromium.org> <20200717174309.1164575-7-keescook@chromium.org> From: Scott Branden Message-ID: Date: Tue, 21 Jul 2020 14:43:07 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200717174309.1164575-7-keescook@chromium.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Kees, On 2020-07-17 10:43 a.m., Kees Cook wrote: > In preparation for refactoring kernel_read_file*(), remove the redundant > "size" argument which is not needed: it can be included in the return > code, with callers adjusted. (VFS reads already cannot be larger than > INT_MAX.) > > Signed-off-by: Kees Cook > --- > drivers/base/firmware_loader/main.c | 8 ++++---- > fs/kernel_read_file.c | 20 +++++++++----------- > include/linux/kernel_read_file.h | 8 ++++---- > kernel/kexec_file.c | 13 ++++++------- > kernel/module.c | 7 +++---- > security/integrity/digsig.c | 5 +++-- > security/integrity/ima/ima_fs.c | 5 +++-- > 7 files changed, 32 insertions(+), 34 deletions(-) > > diff --git a/drivers/base/firmware_loader/main.c b/drivers/base/firmware_loader/main.c > index d4a413ea48ce..ea419c7d3d34 100644 > --- a/drivers/base/firmware_loader/main.c > +++ b/drivers/base/firmware_loader/main.c > @@ -462,7 +462,7 @@ fw_get_filesystem_firmware(struct device *device, struct fw_priv *fw_priv, > size_t in_size, > const void *in_buffer)) > { > - loff_t size; > + size_t size; > int i, len; > int rc = -ENOENT; > char *path; > @@ -494,10 +494,9 @@ fw_get_filesystem_firmware(struct device *device, struct fw_priv *fw_priv, > fw_priv->size = 0; > > /* load firmware files from the mount namespace of init */ > - rc = kernel_read_file_from_path_initns(path, &buffer, > - &size, msize, > + rc = kernel_read_file_from_path_initns(path, &buffer, msize, > READING_FIRMWARE); > - if (rc) { > + if (rc < 0) { > if (rc != -ENOENT) > dev_warn(device, "loading %s failed with error %d\n", > path, rc); > @@ -506,6 +505,7 @@ fw_get_filesystem_firmware(struct device *device, struct fw_priv *fw_priv, > path); > continue; > } > + size = rc; Change fails to return 0.  Need rc = 0; here. > dev_dbg(device, "Loading firmware from %s\n", path); > if (decompress) { > dev_dbg(device, "f/w decompressing %s\n", >