Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp864592rwb; Wed, 14 Dec 2022 03:58:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf7oFrHh0OZVQG91PCyUY+1KeuQcuGjrw2PgXV8wj/CfJ4jv5sWTVjojad5QpyJdw937zJJQ X-Received: by 2002:a05:6402:370d:b0:45c:937d:25c8 with SMTP id ek13-20020a056402370d00b0045c937d25c8mr19805862edb.1.1671019133146; Wed, 14 Dec 2022 03:58:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671019133; cv=none; d=google.com; s=arc-20160816; b=NTqYkZDwYZJvQ8nVYgXfqjDmn3/q1wmaP8BZkFFTtG8jVFGely9tYlHPsjJAiwVMJ5 UiBBjjP8VUxJqGxAkns+kIJWTlbliGe+0oQqQLM3KbehlE411gC5A3dtouJL/s8a1cri WoFr1GI6LRU5Igh+SAlvzz0Jt0Y7j/sPTFhOgRpJuK+kakWD1BnegpCi3WRuemlxOOGe 13yyxpkAUEvUgkF3mL110wBWtVukuJp9cBfWG2b9+YOs3Rsd9j3H1yvz340OeD5LKbDa KwytJyyKzpJS5HZ9XEpIm/3G/G9UIfEE0FIuPeCr5M7iYk/mMltQeMk6dZrP9+3z7zQI 5G2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=mRg78ZkhOQVpDZ+QaAFV8935UrX4bn0uxcF9aGCrixQ=; b=lwZhNIwEpJTMfZpgMKelF84EX9m2U+qoJ8gXiXpeagLcPv6iQuM/bSHnK8LPcOPGaI L7oyfdD7hN+Nc4XInsMnSW3TyuQKcFmz4O347HzaGGOYPkc5/8ZCEdCEmvuVcshXRqrY 1yiW/oCpdd0rjPyjy4Jfr8LIhblqwtKogaOkUem6JM6qmYPRfYEQoCEwKK9Fl9D+BOhP mg26Ss2wYa0W11EC06iWNE9u1mYDO7qcdXbDZfhU81z9dNlhnCWGPlzV3RjZFyvmef9I nxBW27G+MzMqF6ASzVInE+1FR/8LX5O14ZHmcWLUguXCzT/NMdWaJThDl3To6Cg9HDCo o/rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=apULYgXW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id by11-20020a0564021b0b00b0046a222caa96si10741129edb.516.2022.12.14.03.58.33; Wed, 14 Dec 2022 03:58:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=apULYgXW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238208AbiLNLJf (ORCPT + 69 others); Wed, 14 Dec 2022 06:09:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238177AbiLNLJc (ORCPT ); Wed, 14 Dec 2022 06:09:32 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFCD424BEA for ; Wed, 14 Dec 2022 03:08:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671016122; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mRg78ZkhOQVpDZ+QaAFV8935UrX4bn0uxcF9aGCrixQ=; b=apULYgXWyZ9qKk/SyH9Sf5i64X6aP8M0gWCs5vgkeUwhRUkcuzJ3HwF9IPGGgdIPLK6SvB r2cdb5SuCv+2DbuKI6nj+C6XUe11SoCEerpGVXNRP5ivoHFfiEqBV9i4ebf1+p25EDwVmC TCD8G/7lJBG/q7wmf2ErWIBuX44UwGI= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-657-QYP6SJt-OjO-X-u3YLWLCQ-1; Wed, 14 Dec 2022 06:08:41 -0500 X-MC-Unique: QYP6SJt-OjO-X-u3YLWLCQ-1 Received: by mail-wm1-f72.google.com with SMTP id h9-20020a1c2109000000b003cfd37aec58so6269771wmh.1 for ; Wed, 14 Dec 2022 03:08:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=mRg78ZkhOQVpDZ+QaAFV8935UrX4bn0uxcF9aGCrixQ=; b=Wco9P/k3FWUVNtt/Rg2tDbd9qTaIHSmCdRxG7lZ+8KseT9ShNe+ftCRoXvkEalMvlN Tvz7+BDNv9/3i4F+R7LHVmGJP9PWvzNh5Qu4U/6ROMUX1hT7tYGdhqlK93c+vuOiIgU/ /r9KOFHKX6Polpi1bq24wE2kjtcoWQze71uDI6bVTNPWctG7+46LOR49gFYGrUP8bdT6 FYNWVfgXSTkZodZoB/NRHrZ5QPoFiVk0dkISTD4DEA3JCQ1X4NyAXTAWjLWBIC7Dg7N9 tgLt46iobmf6yyWZBEKyozxV/oA24diOg2xz5e6IHxbSqRunSU1orHfZhIzVOwPhIl/k HlJA== X-Gm-Message-State: ANoB5pn9VKGwRPkY38PfhqPsD+X1WQGmbPAESy5iXd8WcoO1axJ0IQ99 MrxyCfIPLOpTU7OEoqvp2qFesPZZVmwa/rvnqGDlx+WKUpaS8bToTap5L6Fi1s+NhmQPmgob5u8 WZnJljTxz0Kj9cPPsohOGL+pW X-Received: by 2002:a5d:5c07:0:b0:242:3cb6:36b8 with SMTP id cc7-20020a5d5c07000000b002423cb636b8mr16926031wrb.44.1671016119849; Wed, 14 Dec 2022 03:08:39 -0800 (PST) X-Received: by 2002:a5d:5c07:0:b0:242:3cb6:36b8 with SMTP id cc7-20020a5d5c07000000b002423cb636b8mr16926016wrb.44.1671016119585; Wed, 14 Dec 2022 03:08:39 -0800 (PST) Received: from ?IPV6:2003:cb:c703:7700:dd7c:92f8:481f:b96b? (p200300cbc7037700dd7c92f8481fb96b.dip0.t-ipconnect.de. [2003:cb:c703:7700:dd7c:92f8:481f:b96b]) by smtp.gmail.com with ESMTPSA id z13-20020a5d44cd000000b0023c8026841csm2586564wrr.23.2022.12.14.03.08.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 14 Dec 2022 03:08:39 -0800 (PST) Message-ID: Date: Wed, 14 Dec 2022 12:08:38 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: Dubious usage of VM_SHARED in atomisp_fops.c Content-Language: en-US To: Hans de Goede Cc: "linux-mm@kvack.org" , Mauro Carvalho Chehab , "linux-media@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Sakari Ailus , Andy Shevchenko References: From: David Hildenbrand Organization: Red Hat In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 14.12.22 12:07, Hans de Goede wrote: > Hi David, > > On 12/14/22 11:22, David Hildenbrand wrote: >> Hi, >> >> going over all VM_SHARED and VM_MAYSHARE user in the kernel, I stumbled over the following dubious code in drivers/staging/media/atomisp/pci/atomisp_fops.c: >> >> >> if (!(vma->vm_flags & (VM_WRITE | VM_READ))) >>     return -EACCES; >> >> ... >> >> if (!(vma->vm_flags & VM_SHARED)) { >>     /* Map private buffer. >>      * Set VM_SHARED to the flags since we need >>      * to map the buffer page by page. >>      * Without VM_SHARED, remap_pfn_range() treats >>      * this kind of mapping as invalid. >>      */ >>     vma->vm_flags |= VM_SHARED; >>     ret = hmm_mmap(vma, vma->vm_pgoff << PAGE_SHIFT); >>     ... >> } >> >> >> We're converting a writable MAP_PRIVATE mapping ("COW mapping") into a writable MAP_SHARED mapping, to hack around the is_cow_mapping() check in remap_pfn_range_notrack(). >> >> We're not even setting VM_MAYSHARE and turn the mapping silently into something with completely different semantics. >> >> >> That code has to go. >> >> >> One approach would be to reject such mappings (no idea if user space relies on private mappings), the other one would be to remove this driver. Judging that the driver already was marked broken in 2020 (ad85094b293e ("Revert "media: staging: atomisp: Remove driver"")), maybe it's time for the driver to go. > > There is still quite a lot of hw out there (and being used > with Linux) which has camera sensors connected to the atomisp2. > > Recently a community member finally managed to actually make > the driver work and I have been working on cleaning it up since. > > For 6.2 I set of patches converting the driver to the videobuf2 > framework will land and as part of that all the problematic code > you point to above has been removed. > > If you grep for VM_SHARED under drivers/staging/media/atomisp > in linux-next you will find no hits :) Hurray, thanks Hans :) -- Thanks, David / dhildenb