Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp5331061pxb; Mon, 15 Feb 2021 16:53:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJwZQ5HQvwgFWQFWfz4EQdfulhcZEkv/vw0wj4WnUBP83hcSWk2pg3/bXfith3XcrPvZIzdy X-Received: by 2002:a50:d714:: with SMTP id t20mr17929585edi.65.1613436819323; Mon, 15 Feb 2021 16:53:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613436819; cv=none; d=google.com; s=arc-20160816; b=H3bbh8OC/LOpCnARo6q9G4venjMc01v3M9FDAtErB1S5pf+fHjgymSM5fQmlpcJuQF XPsbQ8yf1fddC+Dw80gUPWVrM3ckAHm/emYZZ1PAVd4cWUVXkn/+SZ5KdJR0hcCCsMn+ sFITHPYxDiwXsZ4yUgXXncifkBLq/OVZ90TF355D8qAtGx2PoIPoQhL/2142A/q60ZBI zruqYp6v647fpn1/TIZLX6hYeQhkJpLuUt20p7H4sa0qGOyDXL2p8TWMJT/PNiUwAjD9 YnpSjoTS9kzMpXXkAohqKCZWiELpKOPRGUQEYCruMu8Knk8CnHAFaE6r5j2c+dnroV6I aW5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:message-id :mime-version:in-reply-to:references:to:subject:from:date :dkim-signature; bh=uCn/Bflq9/wBUpEgI+BGaqJEFBlq0OwkbVwQBJDS7V0=; b=J+gAbYFpuV0uH2rvvPLAmKscOePpe7WM1yCRaHXEzxAygmNyjifhGd7H9BsBGomH2r rgEAtuklsGATaU2rQ3ZaOQBpOYkm2t+r0c5VJ4TksyqZ7xhoxqOmN/D6EGmbSpWB/QEc yUqMyufIu8gXxWBm9Jckom99vQgu3Y+FbOsCC2ppV0Xmb5BiwDcGKBl2+MwnGVxWcmGb D1dwCixGJ/OWXLTKPh9eb7WTtCnhGpxM0uL4nDnhhE+kwyZ+NOQJ/ptonCzCnW8jjmCG 2Yz/UqKIQ4O1qj7UxfotlmnRlqQ/EhwbxrFjNIs2f2wUvCT+gjkEFvbodqoLJAvLvI4v Bh7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.ca header.s=s2048 header.b=WKpmldml; 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=REJECT sp=REJECT dis=NONE) header.from=yahoo.ca Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ce22si7704628ejb.496.2021.02.15.16.53.13; Mon, 15 Feb 2021 16:53:39 -0800 (PST) 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=@yahoo.ca header.s=s2048 header.b=WKpmldml; 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=REJECT sp=REJECT dis=NONE) header.from=yahoo.ca Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229702AbhBPAuy (ORCPT + 99 others); Mon, 15 Feb 2021 19:50:54 -0500 Received: from sonic315-55.consmr.mail.gq1.yahoo.com ([98.137.65.31]:44696 "EHLO sonic315-55.consmr.mail.gq1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229497AbhBPAuy (ORCPT ); Mon, 15 Feb 2021 19:50:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.ca; s=s2048; t=1613436578; bh=uCn/Bflq9/wBUpEgI+BGaqJEFBlq0OwkbVwQBJDS7V0=; h=Date:From:Subject:To:References:In-Reply-To:From:Subject:Reply-To; b=WKpmldmlioOSiKnU0OXf8UaMGc0ozpBDy4JALwRX8uNNa8hX/fEwuB6Br5iguLcxaFSj59Wp9oRj2kYQPEp8Y9CpY9au9vV8dqOwkIL9pcE/DRdvPVtfC4Ad5xWiB66cW3UVoaIFBFT9kiAftKvdiuBdhZZWL2/kLt/0lOgkFDl2VamAZB+9E1C2uxJWq2OQhABkjLIeY8imh4c+3RgmPZ0D6UbJdyXR5v2KmV+wyveWIe00KtzxYozLGT+oxz5igU2BERxUV9JkOFdzjX43XiHQzxuDgP0rCukFhlKn9wUCy9/m4h//ZBadgOiLfiRoEUo64ef5ero0T2aAHb9p0Q== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1613436578; bh=4K43OsaN+c3jkspguRDAWVkUOYXOkclZJICSojcXm7Z=; h=X-Sonic-MF:Date:From:Subject:To:From:Subject; b=bQh7o/gD5oJjp79PChp3fGKwX8uWFuGECDmxnzYn6f1lsqVVsfmxEi9iKaS3zQShpqz1E+seIDxyQsXVuTHtZ0YRM8WGMK3GDd7uE5VkA2KVZR/T+d4GazXYrRbIMXkFPFRC00GIdNR581UpJqCLsHHe3hPdFE9ZAXPJ667Cy6tlsmAOSto303CEdNoJaf4YNstPeCJOSelEyVAgOsDQrg/1k1Trobcq8TMzp5zkbCjeeY4+Ix6Op+YntkCzMrdCcRk+mXmJ3Xz2Io0cOwm2aw1PCR6ngoJlqCfuCt79RMu9sM9tdd5I5sot+Ls64O1UILGLVxl2Jiy9udrX1FZ9fw== X-YMail-OSG: RhkyYoIVM1lvMN0kXt5R0eceLxBg2F24d8srvRU.xEsBPvY2KtCSx._ni8SbuAo F7Q0qayE.k61JySmeiRO2_UvCN7qstvZTLkuxxQ7nD55oR0j7WdkBPDYQlhWLxb3swSBr8xBnyjJ KtuYxhkjltN4EUSL1EOZ8VRt4bmF4zsPZ893YW299ocHMx3X2LGhlPldVud09y5xZdNY9ntVeY0r JLZqjEjrtaZgbbCdyHMigiYTGzxDpdr8ZrY5RCmPIECm5TWfIpA9PKEMgUJ3IykirWhCjf04a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CGesZa4AySiWa7JcgO3_H_BXUrpMgbNXiG2kDtjMZdrFyYhNzkHgEdePRdgWcWWNZ iCYcjgcVxp7QpHVQoFTc5jtQVYPGT2QVF5Y0Vxi_H0yHvxbKN5zN2DCEby44X_HtSPij.9cK1k7G JFSWv8KKLMLDr1Bz.KFAK189K3JNIpP0xhYVp09E814nTiiHd12KUtnx9TbXxAKX4VOTrWDAMU1Y 18.8zNR.zzznq.dPX9N4i7BgZiod3HO8h.jQZBQWsINPIc4ucWpwN7ilWm.ufWvwqKFvlMAW7OZ6 ZbP54ULOKeYs- X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic315.consmr.mail.gq1.yahoo.com with HTTP; Tue, 16 Feb 2021 00:49:38 +0000 Received: by smtp408.mail.gq1.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID a743c5bf659a941befe506b5142ddb40; Tue, 16 Feb 2021 00:49:34 +0000 (UTC) Date: Mon, 15 Feb 2021 19:49:31 -0500 From: "Alex Xu (Hello71)" Subject: Re: [PATCH] proc_sysctl: clamp sizes using table->maxlen To: linux-kernel@vger.kernel.org, Luis Chamberlain , Kees Cook , Christoph Hellwig , Andrey Ignatov , Al Viro , Iurii Zaikin , Alexey Dobriyan , linux-fsdevel@vger.kernel.org References: <20210215145305.283064-1-alex_y_xu.ref@yahoo.ca> <20210215145305.283064-1-alex_y_xu@yahoo.ca> In-Reply-To: <20210215145305.283064-1-alex_y_xu@yahoo.ca> MIME-Version: 1.0 Message-Id: <1613436483.9rqrq5iswg.none@localhost> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Mailer: WebService/1.1.17712 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Apache-HttpAsyncClient/4.1.4 (Java/11.0.9.1) Content-Length: 1166 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Excerpts from Alex Xu (Hello71)'s message of February 15, 2021 9:53 am: > This issue was discussed at [0] and following, and the solution was to > clamp the size at KMALLOC_MAX_LEN. However, KMALLOC_MAX_LEN is a maximum > allocation, and may be difficult to allocate in low memory conditions. >=20 > Since maxlen is already exposed, we can allocate approximately the right > amount directly, fixing up those drivers which set a bogus maxlen. These > drivers were located based on those which had copy_x_user replaced in > 32927393dc1c, on the basis that other drivers either use builtin proc_* > handlers, or do not access the data pointer. The latter is OK because > maxlen only needs to be an upper limit. >=20 > [0] https://lore.kernel.org/lkml/1fc7ce08-26a7-59ff-e580-4e6c22554752@ora= cle.com/ >=20 > Fixes: 32927393dc1c ("sysctl: pass kernel pointers to ->proc_handler") > Signed-off-by: Alex Xu (Hello71) Yeah, no, this doesn't work. A bunch of functions call proc_* but don't=20 set maxlen, and it's annoying to check this statically. Also causes=20 weird failures elsewhere. May need to think of a better solution here=20 (kvzalloc?).