Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1563820pxf; Fri, 2 Apr 2021 14:26:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzaCx4yEQUUNmEIJ3SA8LAiqon5xbJsnoflII/+UjeUW5t8oWy405EUD5HLMD/RmskvtG1e X-Received: by 2002:a17:906:f1c8:: with SMTP id gx8mr16394770ejb.385.1617398809582; Fri, 02 Apr 2021 14:26:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617398809; cv=none; d=google.com; s=arc-20160816; b=s79TFtitJww0Rg5D/NjH8u4Hgtqoe4/jNJi0pX0vNFRpnxy5xJb0hwLoQ13UwFGzHn Q9PTmCToYSADyDWqj24B0TUOo60eMt+vscRDmn9kH98G9r86PoOML507vB/ZyYgzjpJs wB8UEkQVgYZbVyDwfGeB16H8zvqfRZyn46IAyeljg83zOig2JgG/CMn1LwFiVofNLW0g Nj0eTY36yXLlrMZaqeHudouxDI/mb5g7/QG+7tRabW0n74e6EhuxJYOdJ3tGVvU6Zon0 lUzfwiyEJDDylmLEhsbZh/pfLE43tm3/TRay9k87B3CMtmGuSdnN2QYHP9bhLkqjKAhP CtXQ== 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=08HQieGvJ5s4z39bQ9/VIsRPK3KWDyfUJY19CVcTpoA=; b=eTywvnyVAOIlChdGflTCTYi/LV+BntKddxXHbhu7Wt4puaDd7/KbivOEXw0nPGdvkT /Bb6FlIJL+UX0ErqLXgE5SCpQm7W6kgbGn1rgp3O/MSUfsAAto2Qde/q6ka9IO+LqH7A rE+IDtGw19swkrxxrhOzZfz4Wka3b/CM29gqOMnLYr0bw8xkpnly2Hm2M35oiSxY12kH nfWByhqUjtYykweVlN8lD0mbB7N1raHRdDlYTMtmyNU1XsjsEYjGWn8y2MDaKF1spH+5 ZWNPtXWm7u5nLNLSC802Qp56SlgCJZIu+pRUn8DeAoK+X1GlX3WnWTIwBOuOz8Egr0+U xvcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ZZHUC404; 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 d20si7236747eds.530.2021.04.02.14.26.25; Fri, 02 Apr 2021 14:26:49 -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=ZZHUC404; 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 S234619AbhDBVXz (ORCPT + 99 others); Fri, 2 Apr 2021 17:23:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234821AbhDBVXx (ORCPT ); Fri, 2 Apr 2021 17:23:53 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFD8EC061793 for ; Fri, 2 Apr 2021 14:23:51 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id d8so2999816plh.11 for ; Fri, 02 Apr 2021 14:23:51 -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:in-reply-to; bh=08HQieGvJ5s4z39bQ9/VIsRPK3KWDyfUJY19CVcTpoA=; b=ZZHUC404vOs5t/NKB0to6ybKeOuaagPe7GwEPz8E4aRbI9bzhmQ5eh2W3fmlGIAQ5G Zt/fFdSLqRat7R08DbmWJyelbPm9NoUFsXTYln4CMBO6HfJXssG1Hr1HTZiCoU7Zt5xd iPVcqhkNAIOTylk143rBaRMhzzLH4EjarZKoQ= 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:in-reply-to; bh=08HQieGvJ5s4z39bQ9/VIsRPK3KWDyfUJY19CVcTpoA=; b=GWL/4ykcEA+MF+D+d4nn7VKYDcBOx8QxfHiqoWb0gghAX4XUDtGvBfVnj+axcNIZjP tx3WNOa8ddxeg/zJCRv8S+Qy8mHruk96/xt17Ept/TGteqwsX9ukc8xfjHlnvPQm7+8c OaZtpJZoPLw6s9lSquOOW7fumAzGkRhuoyngyr5oFDsobxmbQCfq1I6CJ857WymD41VY gLJDPJHPbR41KbPO7Yk/a40EzIeWAS3N0syoU0BXkC8wUxadL3orF/qY7rT+ScITPRbA U8de2kyDcFwu3RJAA5Hv3pVQ4COwcdUJM9k6wzU67gAGAsekekDL4Imn2EaUNwmq3wDk eIUw== X-Gm-Message-State: AOAM532ubmcBf8bTVaBja4KbYjPu9+p/UsFk6a09CYXRAvyh/2vVjH7b Qdb58ang0CUQix8DgZf5WYhbgg== X-Received: by 2002:a17:90a:420d:: with SMTP id o13mr15596212pjg.61.1617398631259; Fri, 02 Apr 2021 14:23:51 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id t3sm8999011pfg.176.2021.04.02.14.23.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Apr 2021 14:23:50 -0700 (PDT) Date: Fri, 2 Apr 2021 14:23:48 -0700 From: Kees Cook To: Christoph Hellwig Cc: Greg Kroah-Hartman , Nathan Chancellor , Arnd Bergmann , Tejun Heo , Alexander Viro , "Rafael J. Wysocki" , Shuah Khan , Nathan Chancellor , Nick Desaulniers , Andrew Morton , Kefeng Wang , "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kselftest@vger.kernel.org, clang-built-linux@googlegroups.com, Michal Hocko , Alexey Dobriyan , Lee Duncan , Chris Leech , Adam Nichols , linux-hardening@vger.kernel.org Subject: Re: [PATCH v4 3/3] sysfs: Unconditionally use vmalloc for buffer Message-ID: <202104021421.97A06AE@keescook> References: <20210401221320.2717732-1-keescook@chromium.org> <20210401221320.2717732-4-keescook@chromium.org> <20210402063221.GA5260@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210402063221.GA5260@lst.de> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 02, 2021 at 08:32:21AM +0200, Christoph Hellwig wrote: > On Thu, Apr 01, 2021 at 03:13:20PM -0700, Kees Cook wrote: > > The sysfs interface to seq_file continues to be rather fragile > > (seq_get_buf() should not be used outside of seq_file), 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 sysfs's > > use of seq_file almost always already uses PAGE_SIZE allocations, has > > normally short-lived allocations, and is not normally on a performance > > critical path. > > This looks completely weird to me. In the end sysfs uses nothing > of the seq_file infrastructure, so why do we even pretend to use it? > Just switch sysfs_file_kfops_ro and sysfs_file_kfops_rw from using > ->seq_show to ->read and do the vmalloc there instead of pretending > this is a seq_file. As far as I can tell it's a result of kernfs using seq_file, but sysfs never converted all its callbacks to use seq_file. > > Once seq_get_buf() has been removed (and all sysfs callbacks using > > seq_file directly), this change can also be removed. > > And with sysfs out of the way I think kiling off the other few users > should be pretty easy as well. Let me look at switching to "read" ... it is a twisty maze. :) -- Kees Cook