From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD83EC433E6 for ; Sat, 13 Mar 2021 08:55:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8F6E664F2D for ; Sat, 13 Mar 2021 08:55:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232702AbhCMIya (ORCPT ); Sat, 13 Mar 2021 03:54:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:56892 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230380AbhCMIyZ (ORCPT ); Sat, 13 Mar 2021 03:54:25 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 854D164F18; Sat, 13 Mar 2021 08:54:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615625665; bh=sY82OmhyeTVt+rmWnctmosWs3YKi5+djuGVMlXHeWD4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=CvnvXOeAJ1QkK+8jqwJl2KUclrmhKLISPsciGwDa8j4hVvmb8T9B4fHn7qEF+2eJf 3bI2L6PYVEnO0oKwC9IEZWCzv+99MTxWb2JefNmohBuy63+SkYuujni5Y/dMoTtPuS bvJcU4DJYFJ1pX9EHuqrpMO6oezRt/O0yxeeU60Y= Date: Sat, 13 Mar 2021 09:54:21 +0100 From: Greg Kroah-Hartman To: Kees Cook Cc: Andrew Morton , Michal Hocko , Alexey Dobriyan , Lee Duncan , Chris Leech , Adam Nichols , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] seq_file: Unconditionally use vmalloc for buffer Message-ID: References: <20210312205558.2947488-1-keescook@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210312205558.2947488-1-keescook@chromium.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 12, 2021 at 12:55:58PM -0800, Kees Cook wrote: > The sysfs interface to seq_file continues to be rather fragile, as seen > with some recent exploits[1]. Move the seq_file buffer to the vmap area > (while retaining the accounting flag), since it has guard pages that > will catch and stop linear overflows. This seems justified given that > seq_file already uses kvmalloc(), that allocations are normally short > lived, and that they are not normally performance critical. > > [1] https://blog.grimm-co.com/2021/03/new-old-bugs-in-linux-kernel.html > > Signed-off-by: Kees Cook > --- > fs/seq_file.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/fs/seq_file.c b/fs/seq_file.c > index cb11a34fb871..ad78577d4c2c 100644 > --- a/fs/seq_file.c > +++ b/fs/seq_file.c > @@ -32,7 +32,7 @@ static void seq_set_overflow(struct seq_file *m) > > static void *seq_buf_alloc(unsigned long size) > { > - return kvmalloc(size, GFP_KERNEL_ACCOUNT); > + return __vmalloc(size, GFP_KERNEL_ACCOUNT); Maybe a small comment here like: /* use vmalloc as it has good bounds checking */ so we know why this is being used instead of kmalloc() or anything else? Other than that, no objection from me: Reviewed-by: Greg Kroah-Hartman