Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp471927pxf; Wed, 17 Mar 2021 08:50:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqPuj2g4rLvQupKDV9/QMPqsiIirvgDzx1jjpO23XeRYe9QsX6ix/6o8Xu4Jk3FjuRRvhK X-Received: by 2002:a05:6402:2070:: with SMTP id bd16mr42558836edb.133.1615996207735; Wed, 17 Mar 2021 08:50:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615996207; cv=none; d=google.com; s=arc-20160816; b=ZfK1ZK0q1BbwSNiu7+I4TkS7Yo6HNuoIEoLvKXcIDmwJPAQwCy4Q1IHsIr1+OxAcse sCqZ30lg1/DNjuwBauoqbbRqlvE+adqiXrQSWbwDzoxxdi73NiEXbIevz/1w3Lh68HkR RQ0D0UZEpUz+g0kbRIloBa2JokCyZqFiVlq14rTGpOfIlG6qih1h9G2ael1SnNZiz9il VJ6mjeHXRg4Yb0iUmfLr5LUVyhCU86hA7flJcI7b9WABLUFEznrs4VCEmQcFG4TYY4QU hsRxw7Sg8OY6Tj0JoYwhdlMnBJipH6opFgfJfBloPeL02S0bvz/xv95RL0vPUoscpHPY TPeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=btiCGAjBA+oTgNvFWaiwkJdxvkvB5M3EHBf3slgWcEs=; b=LXdBQOzmVq8EEkBDb+Spcpu76AqeLdtMj45PnRJ63GpGAr/Uu+QVvtow6V82CDngbw zwC/tTqtJseg5UBengrplUVXiZPP0Rb9hakjREC5PIpqNRRVXNKvYL2UdH8L1xM5hrYQ GOmP9mYxhHDpG6widNkojWoNkdi2PCgOqGwozare375OGz9Rafp4iqqQC7X65TpBoObo VL/Nd0IzBAiYY2wo93t67mmQ9hlioniNUxv0GQn/nD1DmbubGxUnS/XRLLmaGifnBnhr nnOFlvbMg34m00sZKPu1K5UreNzs4uegZd1UXNULr3aD6gQ9Px3GvqAHFzNvz0xAWv/J x/vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b="XSVK/Iiy"; 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=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rl3si17101464ejb.86.2021.03.17.08.49.43; Wed, 17 Mar 2021 08:50:07 -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=@suse.com header.s=susede1 header.b="XSVK/Iiy"; 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=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232255AbhCQPsy (ORCPT + 99 others); Wed, 17 Mar 2021 11:48:54 -0400 Received: from mx2.suse.de ([195.135.220.15]:58602 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232464AbhCQPsN (ORCPT ); Wed, 17 Mar 2021 11:48:13 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1615994453; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=btiCGAjBA+oTgNvFWaiwkJdxvkvB5M3EHBf3slgWcEs=; b=XSVK/Iiy0jAUmkNHsP4RIvYQjP02KLonGBsFLEgOhG6aqrR2X8maT/j4ZoVaVjnqQ2gXvH wopF8k8fk3AEZrCO4QDIBw+anURxIWREEWxeCY+ig+7rnE65ksqmeQAAP/IyUxFbkaeUZu PeuLwFlpOvU8jyORIiEgk9ADrbDJSN0= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 39B7FAD74; Wed, 17 Mar 2021 15:20:53 +0000 (UTC) Date: Wed, 17 Mar 2021 16:20:52 +0100 From: Michal Hocko To: Greg Kroah-Hartman Cc: Kees Cook , Andrew Morton , Alexey Dobriyan , Lee Duncan , Chris Leech , Adam Nichols , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-hardening@vger.kernel.org, Uladzislau Rezki Subject: Re: [PATCH v2] seq_file: Unconditionally use vmalloc for buffer Message-ID: References: <20210315174851.622228-1-keescook@chromium.org> <202103161205.B2181BDE38@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 17-03-21 15:56:44, Greg KH wrote: > On Wed, Mar 17, 2021 at 03:44:16PM +0100, Michal Hocko wrote: > > On Wed 17-03-21 14:34:27, Greg KH wrote: > > > On Wed, Mar 17, 2021 at 01:08:21PM +0100, Michal Hocko wrote: > > > > Btw. I still have problems with the approach. seq_file is intended to > > > > provide safe way to dump values to the userspace. Sacrificing > > > > performance just because of some abuser seems like a wrong way to go as > > > > Al pointed out earlier. Can we simply stop the abuse and disallow to > > > > manipulate the buffer directly? I do realize this might be more tricky > > > > for reasons mentioned in other emails but this is definitely worth > > > > doing. > > > > > > We have to provide a buffer to "write into" somehow, so what is the best > > > way to stop "abuse" like this? > > > > What is wrong about using seq_* interface directly? > > Right now every show() callback of sysfs would have to be changed :( Is this really the case? Would it be too ugly to have an intermediate buffer and then seq_puts it into the seq file inside sysfs_kf_seq_show. Sure one copy more than necessary but it this shouldn't be a hot path or even visible on small strings. So that might be worth destroying an inherently dangerous seq API (seq_get_buf). -- Michal Hocko SUSE Labs