Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp903555ybt; Fri, 10 Jul 2020 15:45:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzozn4yNf0/FSwjQXZG4240aNtK3skbz9wyHW4b3duadaXXyZ5Kvqtnrnq7kLuW1FIXvolo X-Received: by 2002:a17:906:9244:: with SMTP id c4mr62296154ejx.60.1594421103519; Fri, 10 Jul 2020 15:45:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594421103; cv=none; d=google.com; s=arc-20160816; b=N6XiXM0oAfNQa0Jt+5HjbzG0ZAFihJIQSy3m6yQfx8DJc71wQZVtdC9f8VbT6rbype 1B+cWSFPbjNeHRShOMXfxbW6/S2A4kIMgjNIFJes4s/oHS6qjJPP+jROY7jYJSat9Guh uwt0WxfYlsx0UBVt4U6hp7gMdEMYSWOXW1NdFAHwAn6aAM1Yu52YXnizl9HHjY9bL3a/ zXPJEybs3HX94PxQJoFR7lnrrP9ISIzVFtZ0Pt0K5NxVH5nPa2bGHprHt309y4qxHA+S pBHqv0BngL/kgdAk2Y9l3e4a3ruZOFox+TcFoeaSXDbSPfjBNepnEnOuxexk/DWk24on ZjfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=TjEJpib1IL5htaIPNtgXZReDUQ6slE49xFUwHakVlH0=; b=SEGn+BcCajh//cQRsEJ0nDF6jPQWU/tJXhfwtW5AlrVQFFXRY3tGgAZqKTxGp4t8Rs BFZqCtLKkVSYoTEy4VvVy64TwRvCWtNnDK9JJoE/SWSIbWexU62XaZ0KuVKzUX/L4DsU LGsgQ/XzItQpshIWjQueVAS9LlrCzVntk7PcRCpuVbZDoP5XgEcQXFdW/loHWE4kRSIi nDhsIwENDZie4h9s5LXcZ1mDgYTP2Kj99guqcdqeyaY84p/Y94ZvZSrJrIOxPkFuZXZ6 n88CqWBHDjEbTa9/cYoUbtpIRVVssxk1WBBTbtaKuNIa/c+JGasdfO+U0pNRqjKaQkGX 0fFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=SO1xAbaP; 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 j18si5105527edp.389.2020.07.10.15.44.40; Fri, 10 Jul 2020 15:45:03 -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=SO1xAbaP; 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 S1726709AbgGJWoK (ORCPT + 99 others); Fri, 10 Jul 2020 18:44:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726769AbgGJWoK (ORCPT ); Fri, 10 Jul 2020 18:44:10 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3263C08E763 for ; Fri, 10 Jul 2020 15:44:09 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id mn17so3206582pjb.4 for ; Fri, 10 Jul 2020 15:44:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=TjEJpib1IL5htaIPNtgXZReDUQ6slE49xFUwHakVlH0=; b=SO1xAbaPN5JafN9toT/S+WneSLZasNKIViJUdCc3GKTm5RREBz48J7iN1ANJD4rGJC oLJy5cqcDy+SDN0nvcAXoX0qVGw0sHTomDkxRemFAupDhPw+xCwT01Lz1nYiaZNCU99V rJrNVo6yLJNpmhg0DMRwUu5W0ig+vMBotm3/c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=TjEJpib1IL5htaIPNtgXZReDUQ6slE49xFUwHakVlH0=; b=WiPWhyzw+Z0+PiR9as8FnfKuRSpEsUBmuHoo44o8l91Pf6+b6ZEU+PgTHpLVJs1C5i Xh+DfotooBVDC64W7dEqfVefs/lm/XTa0C4+NQvWa+SgvTuW645DjeqRzgNeIdBEy4/2 4UvMC5N1OEp8QiMUluPUwJtvhIKqRzc8/6xpvaVdDNTpPQpq2+Wg+rxMsXTwCx2JEMSO A4KsrIgFkLxHhUJwKXmI2Gz2sSFosf+rIzUjj6rkD1FhpRhIZxVitz2mRLwNBHDRHOwi e+wtsITEgHY7czd5391WCD14Aojto5uVpj9OeHxvfYsFn4ISZg4wiAfT/cAHptzeJqdW j26g== X-Gm-Message-State: AOAM530JlrSPp9I3VJvXRCbVdZ4i6V37v/ruWNj2StUjvjBvMDZT+eUW ndip1aQtEs+tjb0EmBTq7gVOsw== X-Received: by 2002:a17:90b:338d:: with SMTP id ke13mr7916117pjb.60.1594421049223; Fri, 10 Jul 2020 15:44:09 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id b128sm6195291pfg.114.2020.07.10.15.44.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jul 2020 15:44:08 -0700 (PDT) Date: Fri, 10 Jul 2020 15:44:06 -0700 From: Kees Cook To: Scott Branden 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 Subject: Re: [PATCH 2/4] fs: Remove FIRMWARE_PREALLOC_BUFFER from kernel_read_file() enums Message-ID: <202007101543.912633AA73@keescook> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <128120ca-7465-e041-7481-4c5d53f639dd@broadcom.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. :) -- Kees Cook