Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp6837300ybn; Mon, 30 Sep 2019 04:42:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqy4yKsNDcXLf8OW4idWZ6Y3DHzR/Pvp+5wVYMvHXA3pqCYMdqmKfz9XJ/A4jNeAkhf/i/dX X-Received: by 2002:a05:6402:713:: with SMTP id w19mr18816698edx.126.1569843767901; Mon, 30 Sep 2019 04:42:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569843767; cv=none; d=google.com; s=arc-20160816; b=enN4McX/GtNwNt7B0xRXq7UNO19YuaiQm2ZwSTq2z3f2rrZJjWIGyQK6Kg/wKwloc8 waTwg/g5SXawGkqHqJsWXEDs4ILwv1Qq7Hz5Ykd9yOQTflJ7bhjwDlWV0uQAh0+K0zQ6 fmUaEAkVhdm2f+zsSmvA+7DJXK9MPgxHC47Hb5CK/fI0ri8qPQutvqFAcfJk7iqFahyr JOsXqEZChOSBFitXbzGni5XFHfbuLF/GJmnnIqyn9+Li+2V55NbQlfArzLqJAd/ab5Ls ICebb3BLC2/lwqqwML3AQmogs8k6WoAXVYbCyirYBU4EPNKFbtRqpmpEN40eCTqxqdLb ki5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=GLx5yP5qbUMRRkm0I6vgS7nEtkPOJH3LxByogAf0qrQ=; b=b7kNbhVHmHcGUpKSwMyILezFIlG8r8XvaU7BQs+Ow5zTPb/cJx88auactiLFEDSbiI /JBPhOJUw9ROmTTtgPGqt8S2RQr2v+xoEEEwU60L+Bd0ot9ifJllvNMX8gmd6qCOjwJz jbPRzNx3JRveeKUjTyVlq6n1tOSYkuvMcpTAg2Wxs8/iGEuHuXs1BV+WgN8sSAVwL+6b fJNkbv6BmILxnaJ89Ru6oc1Pvts+yForIxrtr/rCOGwYXOPsMSn2Yqz1zecPUgSIgXwE o0VOZZ+tc+tws2j0Dgp6jMBr5z6hMXrVd4771TbT4xUKDpTALuzVW7A0UGwSAQ8kUWPQ 2Ajg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OrRkotIW; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id jx7si6768443ejb.84.2019.09.30.04.42.05; Mon, 30 Sep 2019 04:42:47 -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; dkim=pass header.i=@kernel.org header.s=default header.b=OrRkotIW; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729337AbfI3L0o (ORCPT + 99 others); Mon, 30 Sep 2019 07:26:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:34152 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726072AbfI3L0n (ORCPT ); Mon, 30 Sep 2019 07:26:43 -0400 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 76A30206BB; Mon, 30 Sep 2019 11:26:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569842802; bh=srPqDShwNAxoUEhMeFDiah3VlPzS3gr2KS0cPzlZHB4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OrRkotIWqtU+1P4CM+QDBBZmq5Pz6WxzkeH0RXa8qck41YG2Z+PXSxLa5dLTUsln5 JpHAZfEwI5+Yq7ezissogWCmYQX/ffrQGOxrUWf26e+n/6TIsVYx8otHB74XbqQjZw KiqrRsIL0KSugSGQlMAQFxJkEgkNlPLVJAMCcRXQ= Date: Mon, 30 Sep 2019 12:26:37 +0100 From: Will Deacon To: Linus Torvalds Cc: Nick Desaulniers , Nicolas Saenz Julienne , Masahiro Yamada , Andrew Morton , Ingo Molnar , Borislav Petkov , Miguel Ojeda , linux-arch , LKML , Catalin Marinas , Russell King , Stefan Wahren , Kees Cook Subject: Re: [PATCH] compiler: enable CONFIG_OPTIMIZE_INLINING forcibly Message-ID: <20190930112636.vx2qxo4hdysvxibl@willie-the-truck> References: <20190830034304.24259-1-yamada.masahiro@socionext.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 27, 2019 at 03:38:44PM -0700, Linus Torvalds wrote: > On Fri, Sep 27, 2019 at 3:08 PM Nick Desaulniers > wrote: > > > > So get_user() was passed a bad value/pointer from userspace? Do you > > know which of the tree calls to get_user() from sock_setsockopt() is > > failing? (It's not immediately clear to me how this patch is at > > fault, vs there just being a bug in the source somewhere). > > Based on the error messages, the SO_PASSCRED ones are almost certainly > from the get_user() in net/core/sock.c: sock_setsockopt(), which just > does > > if (optlen < sizeof(int)) > return -EINVAL; > > if (get_user(val, (int __user *)optval)) > return -EFAULT; > > valbool = val ? 1 : 0; > > but it's the other messages imply that a lot of other cases are > failing too (ie the "Failed to bind netlink socket" is, according to > google, a bind() that fails with the same EFAULT error). > > There are probably even more failures that happen elsewhere and just > don't even syslog the fact. I'd guess that all get_user() calls just > fail, and those are the ones that happen to get printed out. > > Now, _why_ it would fail, I have ni idea. There are several inlines in > the arm uaccess.h file, and it depends on other headers like > with more inlines still - eg get/set_domain() etc. > > Soem of that code is pretty subtle. They have fixed register usage > (but the asm macros actually check them). And the inline asms clobber > the link register, but they do seem to clearly _state_ that they > clobber it, so who knows. > > Just based on the EFAULT, I'd _guess_ that it's some interaction with > the domain access control register (so that get/set_domain() thing). > But I'm not even sure that code is enabled for the Rpi2, so who > knows.. FWIW, we've run into issues with CONFIG_OPTIMIZE_INLINING and local variables marked as 'register' where GCC would do crazy things and end up corrupting data, so I suspect the use of fixed registers in the arm uaccess functions is hitting something similar: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91111 Although this particular case couldn't be reproduced with GCC 9, prior versions of the compiler get it wrong so I'm very much opposed to enabling CONFIG_OPTIMIZE_INLINING by default on arm/arm64. Will