Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2952668imu; Sun, 9 Dec 2018 13:27:04 -0800 (PST) X-Google-Smtp-Source: AFSGD/UzbdZZwSL/3JZsH7bk8skjkiCdAC1zNb89QrvMVuyGQrZ5xcNrfqOZ5HqxbDdQHMqOCr+i X-Received: by 2002:a63:d818:: with SMTP id b24mr8573375pgh.174.1544390824379; Sun, 09 Dec 2018 13:27:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544390824; cv=none; d=google.com; s=arc-20160816; b=zkwyerYcSAg018P7fndp0fQLxi3g80lCX1808296yxpQhUkt7c2QuQ7bZO6boSFPHz dhoIXKrQmv8qiv7zFhgjgnu3X6vSJ7fg+oddNzLbiiw5do2MJt/83ZWL6uGiKtlxntAG ByTWPJkNasWqEaFTs7CcLCkfOT7k9eRZUVb/yl1cq61KsIUMk7YRPxW/RbhjVeS4svwy bzYrdtjSvTqjdFg8AMjRLpf+GtR7tBYhEw00zfBoCR4I7yJmb0eDDgyC8HwF78MdCvRM 950LUNm5lToE/EtfkH12B7qKnG8MESiEFZn+HJlma9UAwjVw/icbj/AHkCvVLy79qyJ3 TyUg== 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=ndonyk+1VUSAM+umr79jqJfNm0olKRQxrFc2mvGA1pk=; b=MaWc+/ekqZCE1kmz6TA5UpuT2FbIFKPHI7qjR1FphOTI+p7hN3yAIcijEVzvySpnvj XRcpLKEw1AiQw7LqAmfpE5NA3GavF68mMErLcrx1t9S/h77EQ8XRc/gqeO4I8TtYE2Sp LcYwch2qQkM99Og1GJct2+4ExOvXw1HJNY1a7IFPhbj/0qPUO0wOivKSEPZ7VfpMFCgw fVtGyvUW/MXajvy/EVfg3Ni/t40DCbj+eUYQ/IpG8HSGDVNQkgiEKvaIo/jDaIdbbvLF bFddosln++tBtf0gnFI9qezc6y7+IykHNr/ixsv0EO4JXEb4jFVKUkHqGJyFiTb7XPa1 sQhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tycho-ws.20150623.gappssmtp.com header.s=20150623 header.b=AUuz7YCE; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k12si7758713pgg.382.2018.12.09.13.26.46; Sun, 09 Dec 2018 13:27:04 -0800 (PST) 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=@tycho-ws.20150623.gappssmtp.com header.s=20150623 header.b=AUuz7YCE; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726277AbeLIVZ2 (ORCPT + 99 others); Sun, 9 Dec 2018 16:25:28 -0500 Received: from mail-io1-f67.google.com ([209.85.166.67]:43348 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726219AbeLIVZ2 (ORCPT ); Sun, 9 Dec 2018 16:25:28 -0500 Received: by mail-io1-f67.google.com with SMTP id f10so7233142iop.10 for ; Sun, 09 Dec 2018 13:25:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tycho-ws.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ndonyk+1VUSAM+umr79jqJfNm0olKRQxrFc2mvGA1pk=; b=AUuz7YCELysT0MluQWnfJjvUqQ+BL95/vzAnoZcSm/ySFtK8FavOIHZKPEXDHOIgdG NiQOptQWJMVogN+YS/TcV5sJutGV7WR/+vZm0tfa6We43D4G376wnST1UkUCM9UlH4fZ AjTerLsHEhWFcHVbUAV+J3DShdMoEzvE1eh8sBwE5QWUJjl7F6ftzTJvz+fMKUdSPKnZ JBhEz1JR5NbS+3txMuU7fnQqYCIK+hZUS8h9VAnHQ40yFyr7vzUzM+kr4KsTssZ8vWwu h9mANuL0WMy5ZUCL2hHm/Av4gqx1S3gq3IMJ5xaBuvSjQg6WdpMqn9fNLRzlP9mMcJ7x PPBg== 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:user-agent; bh=ndonyk+1VUSAM+umr79jqJfNm0olKRQxrFc2mvGA1pk=; b=UvB/kDBaqpV2fbL6by2kAo0UKSAgYEa28iWTrxf3rAyN4eWVddMbrTMr8qg8f9rsMg fP4Wam3P0Opi45LPx/SHlmmf6Yi/dSb9zQmAaGaP7GFwlwSQumFS0E3F0va2HZJBjsQC o/Xro6+J49cD2RyNt/EoXnHCTAdFkUyTIgCpfOByTORh2yCojsJRiBuekHnDgal7V08j Kf9I+hpBzwpAKxgFYLm1g5of4HcuD1XrdXPFBxg3evJh/MMcFjo5Cin+31X0YtjAFMYc ZU9yq7Knv99VStQTKsgy+80ku6eDWWmlBzwQ+bVDVx14x/2WL9eFPVgB2IYlUUehqE1n zCVw== X-Gm-Message-State: AA+aEWYShPjI0jx5MgwO6gsWEFW8uyOeUMrLWnJbdC+c3uwgClzgZ1Qz +Phe/y9hR7P9IqK6XA0/+46PNeXKLcJkpw== X-Received: by 2002:a6b:3b47:: with SMTP id i68mr7918814ioa.133.1544390726790; Sun, 09 Dec 2018 13:25:26 -0800 (PST) Received: from cisco (71-218-133-134.hlrn.qwest.net. [71.218.133.134]) by smtp.gmail.com with ESMTPSA id c68sm5066447itd.19.2018.12.09.13.25.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Dec 2018 13:25:26 -0800 (PST) Date: Sun, 9 Dec 2018 14:25:23 -0700 From: Tycho Andersen To: Al Viro Cc: linux-sparse@vger.kernel.org, kernel-hardening@lists.openwall.com, linux-kernel@vger.kernel.org Subject: Re: [RFC v1] copy_{to,from}_user(): only inline when !__CHECKER__ Message-ID: <20181209212523.GE30796@cisco> References: <20181209204449.18906-1-tycho@tycho.ws> <20181209210220.GB2217@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181209210220.GB2217@ZenIV.linux.org.uk> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Al, On Sun, Dec 09, 2018 at 09:02:21PM +0000, Al Viro wrote: > On Sun, Dec 09, 2018 at 01:44:49PM -0700, Tycho Andersen wrote: > > While working on some additional copy_to_user() checks for sparse, I > > noticed that sparse's current copy_to_user() checks are not triggered. This > > is because copy_to_user() is declared as __always_inline, and sparse > > specifically looks for a call instruction to copy_to_user() when it tries > > to apply the checks. > > > > A quick fix is to explicitly not inline when __CHECKER__ is defined, so > > that sparse will be able to analyze all the copy_{to,from}_user calls. > > There may be some refactoring in sparse that we can do to fix this, > > although it's not immediately obvious to me how, hence the RFC-ness of this > > patch. > > Which sparse checks do not trigger? Explain, please - as it is, I had been > unable to guess what could "specifically looks for a call instruction" refer > to. In sparse.c there's check_call_instruction(), which is triggered when there's an instruction of OP_CALL type in the basic block. This simply compares against the name of the call target to determine whether or not to call check_ctu(). I think what's happening here is that the call is getting inlined, and so the OP_CALL goes away, and check_call_instruction() never gets called. Tycho