Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1487954ybh; Thu, 16 Jul 2020 13:38:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwq4eLeQCUNa4JQTH+LaNrvNxOsf+pTQXqReBBfdeD468m06cjT1IYoVUOl9g6qy8iklrKZ X-Received: by 2002:a17:907:2654:: with SMTP id ar20mr5182417ejc.62.1594931925840; Thu, 16 Jul 2020 13:38:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594931925; cv=none; d=google.com; s=arc-20160816; b=Mv/4R3qpAV1bEaXS45KWPDDmQSDuD21aBwCGpnVa87YegCnJD2qyxvpqNFeQAM6+QD YFV0ZNef7udbq40dZD44+bNUwRKB0OLe2aUr6fIEG5OoI3nMgELupbqnrN3yKL5NZh4C OlQjYy5Da1l6CER6ZllhRtgkRxSj/c5YJaA6Q8DyUTcJFw2urYmOhdTwekwp/1Cnh1qv bu2kQWw6Qhh+xfSsLu45cIc7MyzXf6ztRB4+y6bJw50yh/jzmXD9zPjXDQIfhoBJ+2yW jsXZe+QTfhYtHQgUEDyBKWeHP6MIVbh9jjEbKcuTwhH/PQzKqKGC08uW6QGw1dUvz3+G tKYg== 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=9KKssZ/dTd5jFWuQk++quPFGpJEaxp++vXeRWFCVTYg=; b=FdvGuYNIVCB76wtij+6Kh0UatSuv4D12h2hTdrEhrEEXwtKxTvIcS2iJO2PM7aKM+O UX07Cncf0BtE161MiMaklIXrkvd0TI6jlYdkZHV6rIjxJqbfj0LrFixBfUN0f7HxyBv7 M5X+3rKjfNf/wn8UZvjuBfeBaBv3mbmUSOjrQGDeeF0Z2cWBKLixGR/36fBZ8aT+Cblp bhDza2394nApad6Ld4L9Dj+3S+0XYzEZamTmaek56ppYUHMZI1VQW+hUuZvcQv3iM4Fo Bh+mfuqrpK5D7jef1dDAnYnEfzbzS/2It9sowLQjrwGNMTdZ5+7F18xtaZF93/Smezi3 QczQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b="TcYH/jHU"; 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 jz19si1596473ejb.34.2020.07.16.13.38.22; Thu, 16 Jul 2020 13:38:45 -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="TcYH/jHU"; 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 S1726694AbgGPUfk (ORCPT + 99 others); Thu, 16 Jul 2020 16:35:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726784AbgGPUf3 (ORCPT ); Thu, 16 Jul 2020 16:35:29 -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 BC637C08C5C0 for ; Thu, 16 Jul 2020 13:35:28 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id c80so11571747wme.0 for ; Thu, 16 Jul 2020 13:35:28 -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=9KKssZ/dTd5jFWuQk++quPFGpJEaxp++vXeRWFCVTYg=; b=TcYH/jHU1RmQBPJCKXiG0zbJbk6t8T+p4WR/fKwsA07BAUPP4VqbUfrlpPWqF+0UiM aslyup07dAKKGj1vxS9qXutKQzsMcEXQbXq4CTy9RwVdw9DdCJS0Ahbtc/p7cV6ngjeI rh6Q8XL8U+5dtOZTRfteBdf+eio7fNkRoMQr8= 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=9KKssZ/dTd5jFWuQk++quPFGpJEaxp++vXeRWFCVTYg=; b=PR20OalsT261MAMLCkKhylrhjA7ASrKKtOKy5wXpZJAds1mQ61X7J+jsckY48oe69q qjudQ/NLio1JlyoArv9aBEz27fc6aBysJ1CCdABlBQl4evsCGh54YnwvSD68gfaqaIT/ Qshy6m1UOsFkDkzXhBk0XDKSSkb8dzHle0H2l3i4JWyldrkqiCD5z+UWVCpi0YBYXVDw 1Nq6dKxVJFpY4tYXFanCaTF/+rSKdvZxgz+cwHQ+gjnKsw93tyNYOA26X4nAsI9asIyT 6tkz0zIT/eUbAs66vqFfooHzWgYa2fO5MQ/CF5JYNSOAxw1/a5/DCOquoSpAMEeGt9z9 H2lg== X-Gm-Message-State: AOAM530n2YowOi0FSTaN8n77Yfe3TW5dq1wutIN7J5Ng5gr04ZlxZ3F+ i/U9OTWAeWTVY9/f1TFDx9ipqw== X-Received: by 2002:a05:600c:2182:: with SMTP id e2mr5761554wme.186.1594931727116; Thu, 16 Jul 2020 13:35:27 -0700 (PDT) Received: from [10.136.13.65] ([192.19.228.250]) by smtp.gmail.com with ESMTPSA id 14sm10031229wmk.19.2020.07.16.13.35.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 Jul 2020 13:35:26 -0700 (PDT) Subject: Re: [PATCH 2/4] fs: Remove FIRMWARE_PREALLOC_BUFFER from kernel_read_file() enums To: Kees Cook Cc: Matthew Wilcox , James Morris , Luis Chamberlain , Mimi Zohar , 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 , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org References: <20200707081926.3688096-1-keescook@chromium.org> <20200707081926.3688096-3-keescook@chromium.org> <3fdb3c53-7471-14d8-ce6a-251d8b660b8a@broadcom.com> <20200710220411.GR12769@casper.infradead.org> <128120ca-7465-e041-7481-4c5d53f639dd@broadcom.com> <202007101543.912633AA73@keescook> From: Scott Branden Message-ID: <9ba08503-e515-6761-63de-a3b611720b1b@broadcom.com> Date: Thu, 16 Jul 2020 13:35:17 -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: <202007101543.912633AA73@keescook> 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-10 3:44 p.m., Kees Cook wrote: > On Fri, Jul 10, 2020 at 03:10:25PM -0700, Scott Branden wrote: >> >> On 2020-07-10 3:04 p.m., Matthew Wilcox wrote: >>> On Fri, Jul 10, 2020 at 02:00:32PM -0700, Scott Branden wrote: >>>>> @@ -950,8 +951,8 @@ int kernel_read_file(struct file *file, void **buf, loff_t *size, >>>>> goto out; >>>>> } >>>>> - if (id != READING_FIRMWARE_PREALLOC_BUFFER) >>>>> - *buf = vmalloc(i_size); >>>>> + if (!*buf) >>>> The assumption that *buf is always NULL when id != >>>> READING_FIRMWARE_PREALLOC_BUFFER doesn't appear to be correct. >>>> I get unhandled page faults due to this change on boot. >>> Did it give you a stack backtrace? >> Yes, but there's no requirement that *buf need to be NULL when calling this >> function. >> To fix my particular crash I added the following locally: >> >> --- a/kernel/module.c >> +++ b/kernel/module.c >> @@ -3989,7 +3989,7 @@ SYSCALL_DEFINE3(finit_module, int, fd, const char >> __user *, uargs, int, flags) >>  { >>      struct load_info info = { }; >>      loff_t size; >> -    void *hdr; >> +    void *hdr = NULL; >>      int err; >> >>      err = may_init_module(); > Thanks for the diagnosis and fix! I haven't had time to cycle back > around to this series yet. Hopefully soon. :) > In order to assist in your patchset I have combined it with my patch series here: https://github.com/sbranden/linux/tree/kernel_read_file_for_kees Please let me know if this matches your expectations for my patches or if there is something else I need to change. Thanks, Scott