Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1284481yba; Thu, 4 Apr 2019 07:50:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqx2XSiPIOiQquXxfIB4FqAqKie7JfdolvdVK8yyiGE54KAI3IuxDCjxGdMEXM7tUQD10Jyk X-Received: by 2002:a17:902:4827:: with SMTP id s36mr6885474pld.296.1554389431744; Thu, 04 Apr 2019 07:50:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554389431; cv=none; d=google.com; s=arc-20160816; b=kFP4n47iAblQCYvLy5YuvwsWzPYmFzsFqnvnotNHcB8aov4MjUBTQgz0AfWuNEtQY+ CJ+aAAzGf/lp0wfoCJzfyrFlUS78NqxgRFSzbLy2/Kl5svjg9hkCmpku7Koe9NoIpYBx e7CaQK6f3jab9NZ6Rn6zPPlazR5uTS+hBUBcs59J1YBol0IVdiTiTIEvYIql+4aULuuO zVvOyzse1IZdN8VBl3NiZZ+lEbPJjJUwSRj9weg9EqKW0HvT5yP+8ZVyWCLzfHMn4xLB 1dJS840GzNUSuBXxO/jpLi3ul0NWsyfrhrHTDgNm5CXHJIHG+n0z5fNrJYi2eweMjLC3 mTPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=juueRY59R/m88qkqw19CEd+EkOE6j2K2smQOXFVEsWg=; b=MS6mwix3mY31QYzR+wLn8K15RP/mC7VClYa2W2Rjst/hMmLHWDUqI4XGb89n+qs2yC mqbaS6g/w5Psr2f8697JxN1ArKKrQo0zphDhwiST/paILC/FteF5TSAab+UBgIUftavq CnDVDDqwBsjqF7c0HLKT4SuU3lzh9k+F4r4bhg1825pFLhS2Rg0bXTwMhmEC42tHBFMX m8ZMipdEUolsxuvdly63Qx9lTfLIhnVEvG2l+EvCDKy4fRTbBtMFtb1x9f1ohg1WcfTU Xe9FknzvqcRUPGA3DwUInArkd/Wr6liVd4bpHx0V3HTOLobtThbCXCkrlERYwFwaJUG3 2TWg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d2si19429919pfm.253.2019.04.04.07.50.16; Thu, 04 Apr 2019 07:50:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729067AbfDDOtk (ORCPT + 99 others); Thu, 4 Apr 2019 10:49:40 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:41113 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728027AbfDDOtj (ORCPT ); Thu, 4 Apr 2019 10:49:39 -0400 Received: by mail-lj1-f194.google.com with SMTP id k8so2337676lja.8 for ; Thu, 04 Apr 2019 07:49:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=juueRY59R/m88qkqw19CEd+EkOE6j2K2smQOXFVEsWg=; b=id2//iQ4Fb/2L6ll7MXd0pRRwplwmRykBCk2Xx/6uGdiEdJ6pWxajpfNKKdr7HYMBI uw/Y92nxUFOMnlprnuIqmlAg4wnirLqtsBPNJ2F3Ee4alQD1eC0ELtaSdiqxD0NrnH0L GIJRTTSz+/v62/byEwADAhjukv6FgSfzeveLrVJvdtUW/5uLo6RREUSUyNzeFzmvsJQV uY5oKIPEYD9COSJtzsVmB6uYLwwzNP6m71qScNWQbkhzgaSztgNRZHMAaJ18wsu3fK1U 2p47m25RQU2qLZDpY12AqE5/hPe3HHJtzYb1qNSXB/Ol5he7gS4hQQJkWYJr8V/lKSVl IMUA== X-Gm-Message-State: APjAAAVSYTo1m5t/TbsAWjyV58vQpUWLDH8999FQqwaaRtl6q3HeSwYQ b+btb7RQVn++XFXNiD5uf0rLXm0Q+opBunwCNkeIIoLHkMs= X-Received: by 2002:a2e:1245:: with SMTP id t66mr3798426lje.18.1554389377982; Thu, 04 Apr 2019 07:49:37 -0700 (PDT) MIME-Version: 1.0 References: <20190328130306.25384-1-mcroce@redhat.com> <20190403140203.qq37rgcikvoawb5f@brauner.io> <20190403155108.GI22763@bombadil.infradead.org> <20190404140931.zpmcbfgdnlq6jkqn@brauner.io> In-Reply-To: <20190404140931.zpmcbfgdnlq6jkqn@brauner.io> From: Matteo Croce Date: Thu, 4 Apr 2019 16:49:02 +0200 Message-ID: Subject: Re: [PATCH] kernel/sysctl.c: fix out of bounds access in fs.file-max To: Christian Brauner Cc: Matthew Wilcox , linux-fsdevel@vger.kernel.org, LKML , Luis Chamberlain , Kees Cook , Zev Weiss , Andrew Morton , stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 4, 2019 at 4:09 PM Christian Brauner wrote: > > On Wed, Apr 03, 2019 at 07:08:47PM +0200, Matteo Croce wrote: > > On Wed, Apr 3, 2019 at 6:40 PM Matteo Croce wrote: > > > > > > On Wed, Apr 3, 2019 at 5:51 PM Matthew Wilcox wrote: > > > > > > > > On Wed, Apr 03, 2019 at 05:24:26PM +0200, Matteo Croce wrote: > > > > > On Wed, Apr 3, 2019 at 4:02 PM Christian Brauner wrote: > > > > > > Yeah, maybe but it still feels cleaner and more obvious to just add: > > > > > > > > > > > > static long long_zero; > > > > > > > > > > > > given that most callers actually seem to want an (unsigned) int. > > > > > > > > > > > > I don't have a strong opinion though so if others feel that it's just a > > > > > > waste of space consider it acked. > > > > > > > > > > > > > > > > Well, given that the value is zero, in this expectional case we could > > > > > avoid duplicating the symbol and save 4 bytes. > > > > > What the maintainers think? > > > > > > > > If we care about saving four bytes, we could just pass the address of > > > > ZERO_PAGE(0). > > > > > > That would work, work too, maybe it's a bit overkill. > > > int zero is always there and it's static, so enlarging it to long > > > should be a straightforward fix. > > > Obviously we can't do it for other numbers, but we can alias it just > > > for the zero case.. > > > > > > Regards, > > > > > > -- > > > Matteo Croce > > > per aspera ad upstream > > > > Anyway, I'm fine with both solutions, as I have other patches in the > > I think Matthew's idea gets us best of both worlds so I'd suggest to use > it and resend the patch. You likely want to Cc stable@vger.kernel.org > since the original patch this fixes got backported by Greg quite a bit > since this was a rather long-standing issue. Please also Cc Andrew this > time since he's likely going to pick it up. > > Thanks for the patch! > Christian So you mean using page_address(ZERO_PAGE(0)) ? The idea is nice, but since struct ctl_table kern_table is declared as global variable, how can I assign it to the structure? GCC complains about 'initializer element is not constant', and ZERO_PAGE(0)->virtual only works if WANT_PAGE_VIRTUAL. Anyway, I'm preparing a treewide patch to move all "zero", "one" and "int_max" to three single, const variables in fs/proc/proc_sysctl.c as there are 200+ occourrences of them, so I'd rather keep this simple to have it easily backported to stable. -- Matteo Croce per aspera ad upstream