Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2179189imm; Thu, 11 Oct 2018 06:25:45 -0700 (PDT) X-Google-Smtp-Source: ACcGV62+DksdP6b/ewgEsek/8oYVcsJD6sn8oPhy/7O/yHNwSrfzRzu4GI7TvAONJk98PBm980py X-Received: by 2002:a65:60c9:: with SMTP id r9-v6mr1423921pgv.285.1539264345899; Thu, 11 Oct 2018 06:25:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539264345; cv=none; d=google.com; s=arc-20160816; b=yu2d4Va/p4uDS6W9DFO1aEU98GEpA4pO4ONiZEQ71bBs4Yf9+dR1eiF1kziewnJDqr 1xaqHq56TDDEFdNlZHe3XVVUsyULwKjA71Z4GI10eG5DBbENf/s0tQhTs6LiACG+1SKm Q9YzNsusx/93x+EEj6XHu5WGwHskTSEErulkGUDpEBN/UY/mX3PfoZTJ72284sMn35Dh nOAKJ/8PhYLtPS07fHX9poaKQ94fhYGpBXRu2lGLDIk7M53ROudo4oKFbI63TjDtCivr nmFE8KoKgguyhZKGuyasilyboVWYoCJ/k6CPCCnkwC43dJbJyuVotsBcAct0Uk3V9KX/ MtGw== 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=xA1Xq3zSEkL+SYbeUZCss7KxMc6kPb35X0Ss6FJLa90=; b=UECbASrDlg+Q2bBz4Ca6DN6lPbfftLhiiq2MNtTFVDxNLvkfCkICXRqvK7R9WCGucm peEG+5/JcicgMIbkFdj82kcwsQLWu2w9wMERqMPAMdWYyCdyr9lZRp2VjefWuIzTwkUZ OfJ/EsaaZt1ii3wQ/K8jszIwvx5jQBoWCc+guCW4oE37A31GirK5CjKyX4FarAwPXipJ 5AU+Crz/kdyPBN7K3ZCxUj1ahMzpzhmfxjNxiOGZLtKs5QbV/gIX5ambHFWbOhXFYjZk h8CS4WI3tJ03GeAGNzI5iMDtaM8/Vj75l7aflt76zBXyp2CkikCK9ULYv7pXAEtNRwc8 xxFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=ePBPSpA+; 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 s2-v6si3462815plp.139.2018.10.11.06.25.30; Thu, 11 Oct 2018 06:25:45 -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=@ziepe.ca header.s=google header.b=ePBPSpA+; 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 S1728234AbeJKUrb (ORCPT + 99 others); Thu, 11 Oct 2018 16:47:31 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:43339 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727988AbeJKUr1 (ORCPT ); Thu, 11 Oct 2018 16:47:27 -0400 Received: by mail-qt1-f195.google.com with SMTP id q41-v6so9722396qtq.10 for ; Thu, 11 Oct 2018 06:20:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=xA1Xq3zSEkL+SYbeUZCss7KxMc6kPb35X0Ss6FJLa90=; b=ePBPSpA+oMb4alDXBSN65oOkQ+06TxdF1p3pfLNZAayf0TN2r0lJmj9/9cp0A3nf0/ MN7/ZFxu6PpU0qcN8HYk9QQ3XDiF8TqaUHXS7auChq4hcl6Gu9689wXHe7EwYbZwykmO UpshWfSUDmpH2LpHIxpMQCcfWpc6bbFMmsFuoYHSDszMO9T+oAZ8VlkCNbXDl3jeNecB JuWbA5sOUKhU3rfxBXgi6ziTetKNGFf/Y5hpeL7KsNuLO/l+6bk6sq79pV5TbXa9umQl DlMgAWgdEI8jhdK4ipmcfbfq0EubGhDZ2M7YPpnNgh47+B+IgBS0EQuBhar6UR4uagCu pSAQ== 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=xA1Xq3zSEkL+SYbeUZCss7KxMc6kPb35X0Ss6FJLa90=; b=YgEs4Z8MYLYO1LIcjEbQ3i+RRbZ03yIW6TmEhQm4amLpkY5GVK3Gkdr46mQCmQ+0iF ydfCroLlXyiEw97eMR6pEQLplK3OQGM/jm8jFhCM+wQmprJcFFhUt+2FtTrT6q06f38Q 9Zr282xlFEe4Hv5S4k267DMaSAlphQfnhJXMigDjr0L0yig4svrTYvT9qBpIvDGM/EsU t1lbtZcfl9oyV5KjphMR8pNLXElrL2fFrOuD9aWlbgtbVEC6YDpW95VH30PAM2ohlY0O zDiQdbc5ljHEetkN1MkMgj+dZ4I1Q2QJMZVQDeXQCIU1uSI3bo06fB97n+J9kDSD//gu x5Iw== X-Gm-Message-State: ABuFfoiG9yp/Wbbq5mEsAqW6ZGgp8sGpmxwk/r+rQ/1NUAFlkpCX0nYQ dM2HEWU+U3DA/dKXL6VnIKVIAg== X-Received: by 2002:a0c:ec8e:: with SMTP id u14-v6mr1480994qvo.225.1539264016755; Thu, 11 Oct 2018 06:20:16 -0700 (PDT) Received: from ziepe.ca ([66.187.232.66]) by smtp.gmail.com with ESMTPSA id s52-v6sm18295106qts.5.2018.10.11.06.20.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Oct 2018 06:20:14 -0700 (PDT) Received: from jgg by jggl.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1gAasv-0001a3-Jr; Thu, 11 Oct 2018 07:20:13 -0600 Date: Thu, 11 Oct 2018 07:20:13 -0600 From: Jason Gunthorpe To: Jan Kara Cc: Andrew Morton , John Hubbard , john.hubbard@gmail.com, Matthew Wilcox , Michal Hocko , Christopher Lameter , Dan Williams , linux-mm@kvack.org, LKML , linux-rdma , linux-fsdevel@vger.kernel.org, Al Viro , Jerome Glisse , Christoph Hellwig , Ralph Campbell Subject: Re: [PATCH v4 2/3] mm: introduce put_user_page*(), placeholder versions Message-ID: <20181011132013.GA5968@ziepe.ca> References: <20181008211623.30796-1-jhubbard@nvidia.com> <20181008211623.30796-3-jhubbard@nvidia.com> <20181008171442.d3b3a1ea07d56c26d813a11e@linux-foundation.org> <5198a797-fa34-c859-ff9d-568834a85a83@nvidia.com> <20181010164541.ec4bf53f5a9e4ba6e5b52a21@linux-foundation.org> <20181011084929.GB8418@quack2.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181011084929.GB8418@quack2.suse.cz> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 11, 2018 at 10:49:29AM +0200, Jan Kara wrote: > > This is a real worry. If someone uses a mistaken put_page() then how > > will that bug manifest at runtime? Under what set of circumstances > > will the kernel trigger the bug? > > At runtime such bug will manifest as a page that can never be evicted from > memory. We could warn in put_page() if page reference count drops below > bare minimum for given user pin count which would be able to catch some > issues but it won't be 100% reliable. So at this point I'm more leaning > towards making get_user_pages() return a different type than just > struct page * to make it much harder for refcount to go wrong... At least for the infiniband code being used as an example here we take the struct page from get_user_pages, then stick it in a sgl, and at put_page time we get the page back out of the sgl via sg_page() So type safety will not help this case... I wonder how many other users are similar? I think this is a pretty reasonable flow for DMA with user pages. Jason