Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3422323pxf; Mon, 29 Mar 2021 01:36:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxCuz1pOXW7XOaOqSChb7+DhQJ4pEoSPCII7q/sRddAaa/KXlRLpQ/+DiY3CA6VHu8O8Nn X-Received: by 2002:a50:fc08:: with SMTP id i8mr22259951edr.277.1617007004460; Mon, 29 Mar 2021 01:36:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617007004; cv=none; d=google.com; s=arc-20160816; b=ag0SXwJ4gXwnNu9rrBeGnhhm8pR/gVuG66ZXW26+NRM6HbqRS4Rq2N/ymf+Hh8N6g4 af/Bt9DpPVmecm+VI5CEivr2wyMP77VunXv+5DjE3lSRdeu9XPZdnKDbNg5zqCJ35eCW lHzhIV1pfDDy+x3MipLHZtmEZ3IGniz4LHvjN6OpeMaWXoe5WPGlFpo17auKaSmUw/FB x2hhqqwv8lbt/D61YCc/Qug+8NMFbFfUsFvkkQyCyCY6aGWYyRLIDpE3LaOluI9/s04M FPUoxu6GmRZf5pCO9aCb2S6njY1KY9psJXGGWYfv3HKQgV5ryuhRFE8PiMRPMI7adrC6 uzRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZcEYbr3BkyujSt8BRhvO27IgOPnR9I6Ui6eA3w3Sh5E=; b=VrfwskwskVkKb8PFzfnjSfe801QWrHUmDlY8RWsq8j9RYixymiv+eUzR0AM1PAgIAL /iZbeLp8V97FC4BiZ5LtK7UM33gsAThFJz+2wTLtp6KGcWIltaibMoD3HdeI80QRpeXi oQqtiP2NAsMelfoAcd5k+WADf1+PbHoghiI3nlQ+F2MRnpD6332r8N0N1pW0/n8iwWe2 VpjaT4g/fGAtO7ICkDx0ReYWtqj9Zx/TKj5iA6mVypuiMZ4JXeCQOpfsIChBInBavsOj blEu834wIjec22o9qeT2oahigRbsvCo7SHTuyq6y6C86lCy3XhAfnfYa8zYrDVitUGKX M5Eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LP1Dd2e4; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lu7si11879678ejb.27.2021.03.29.01.36.21; Mon, 29 Mar 2021 01:36:44 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=LP1Dd2e4; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234161AbhC2IcJ (ORCPT + 99 others); Mon, 29 Mar 2021 04:32:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:36578 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232910AbhC2IUJ (ORCPT ); Mon, 29 Mar 2021 04:20:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8D36661477; Mon, 29 Mar 2021 08:20:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617006009; bh=O6tClAaFA0Qq72nsz5l4iwyHAcp7i0MbnyNKYGoJMvk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LP1Dd2e4FlNA2B6C6KOFUcAR90576ALlMC2DI9gdvIzsnE+hJrmc1DNh+wIE+jc3r tyWDVt/4yuhkT8/Qf1J6HKcWoI0b3MRqELWcjUEamsdskJGjDpUdEDFKlRY/I9hmMR 3mTFflgUEDjl4Mfui1DcVsIEqBgmAtGqwDCroUro= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lucas Stach , John Hubbard , Daniel Vetter , Russell King , Christian Gmeiner , etnaviv@lists.freedesktop.org Subject: [PATCH 5.10 084/221] drm/etnaviv: Use FOLL_FORCE for userptr Date: Mon, 29 Mar 2021 09:56:55 +0200 Message-Id: <20210329075632.011485061@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075629.172032742@linuxfoundation.org> References: <20210329075629.172032742@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Daniel Vetter commit cd5297b0855f17c8b4e3ef1d20c6a3656209c7b3 upstream. Nothing checks userptr.ro except this call to pup_fast, which means there's nothing actually preventing userspace from writing to this. Which means you can just read-only mmap any file you want, userptr it and then write to it with the gpu. Not good. The right way to handle this is FOLL_WRITE | FOLL_FORCE, which will break any COW mappings and update tracking for MAY_WRITE mappings so there's no exploit and the vm isn't confused about what's going on. For any legit use case there's no difference from what userspace can observe and do. Reviewed-by: Lucas Stach Cc: stable@vger.kernel.org Cc: John Hubbard Signed-off-by: Daniel Vetter Cc: Lucas Stach Cc: Russell King Cc: Christian Gmeiner Cc: etnaviv@lists.freedesktop.org Link: https://patchwork.freedesktop.org/patch/msgid/20210301095254.1946084-1-daniel.vetter@ffwll.ch Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/etnaviv/etnaviv_gem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c @@ -675,7 +675,7 @@ static int etnaviv_gem_userptr_get_pages struct page **pages = pvec + pinned; ret = pin_user_pages_fast(ptr, num_pages, - !userptr->ro ? FOLL_WRITE : 0, pages); + FOLL_WRITE | FOLL_FORCE, pages); if (ret < 0) { unpin_user_pages(pvec, pinned); kvfree(pvec);