Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5149701imm; Tue, 31 Jul 2018 06:24:33 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeS+ybQChuQhmdT1ADSzgBbBeUzzR3hro2qqyLjo+W9vluEMy9GEGwKkKGXn3Lqs+8/RQdm X-Received: by 2002:a63:a347:: with SMTP id v7-v6mr19897779pgn.182.1533043473264; Tue, 31 Jul 2018 06:24:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533043473; cv=none; d=google.com; s=arc-20160816; b=r5D8U9ZM7dJ6zyzaSeZXI/qMAKtmJj65fz5Y5KnwopSM5vxBukEN4w4/tuuOiyp8sV zzpqU6zSoy9LsxzVnCh8JeVB2puIMWSLh761uNlDpaYnty/TxkcKDvPOVSNJQb/bfEqQ 9ybIpgtk8jw9eNTdo6zLfd6xKYwvSvOzzB0cDNuNf5qS11wg5US62XggUsDQA6jb/KiP /3u9PmPHrhHwHtwGY1rkcSNibFtlJQKdzjsXIzf5zNkai4XvaZ6ALm1q+JYkV5zNSqpL Uj15mXp8+sYffPSzM8gloDI2XvaTh65tf97oDNXG88R1Ql96ZXmkHskQjgUwVvZyQepe qH3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=QpbT3UXIG5rYjc4TLEcBAPVut8LzMvY571CNwf5xdWE=; b=U1+c0q6EZK20NYZZJSjWGsvsDk/3uegQRxKYWiQTrk6q2V3qWGzWySDbfE45iyV5/N H5uKgZIqSA4nkaMFN2mxrSP91BGQu8kPwGBwMWGFhqloLplS7dTsYFD2L77auYpeTiSA maqcY0RbKdEHZatyMwt9NLwhBt3KMeS6AtiXsUp6KPxPOxoHCvW1zwtGEEFbXvGGCYGO MZP27MWpU4FNl6g15B58mSxo4kG4ei8mdEhtNQWFdzaPRxBzbh7QjYTMw6ZOfO9qUkHK QsOBybk/rb053uc4La42UthOSwVl72qSaqb6VR69O5hXNMwout/YIUVxHaHiMK2y5CLW /k+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=a+zaXx2n; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 89-v6si9668946pld.390.2018.07.31.06.24.19; Tue, 31 Jul 2018 06:24:33 -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=@google.com header.s=20161025 header.b=a+zaXx2n; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732255AbeGaPDm (ORCPT + 99 others); Tue, 31 Jul 2018 11:03:42 -0400 Received: from mail-it0-f65.google.com ([209.85.214.65]:35514 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732194AbeGaPDm (ORCPT ); Tue, 31 Jul 2018 11:03:42 -0400 Received: by mail-it0-f65.google.com with SMTP id q20-v6so4323775ith.0 for ; Tue, 31 Jul 2018 06:23:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=QpbT3UXIG5rYjc4TLEcBAPVut8LzMvY571CNwf5xdWE=; b=a+zaXx2nTsLbGVADaHZ1GdN/atj2ZAJVQ0YMn3aApr41kI+SAJ37MkjKH5NbFUNkau 8XrlQlK1VnWNqotEZawz45uQ2UE6aGXnjf1dVdUR0BC1duMXtBQwRAkHqOcSYV2R37c2 yJnEzzlul9fk4nnBh7jYNKzUnFMnAw71+FGikJDjYUReTQ4xDNS8ks4qurq4Y8Rj81EK AP0NXwsQHO9bIGOkULG/U/N7vHr8JeZyAzzaF5tfKXaH/89JQAHmfB2VP5q5VXLdYzox LVz2OmzYVmliH4BQ43WVUjSzCimVTnd3z9UB+QmbnFEsqq4EJTjBzqtvHOo47Xi007YB cZdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=QpbT3UXIG5rYjc4TLEcBAPVut8LzMvY571CNwf5xdWE=; b=jiinxqLb1LzJSAi5v2Pw+9jktsQgSW0hVu9pFp7RikbIx897YHPPPm94DJ6Szeoa2R n0k8kFaVeEKv7kxewqSoYRYg1IDrxguZKQqRmoOOjT5nGHBW7dG3O3Ucv/KpdM2s4xxG lb+3WtcGu0EtZxFp9XEWkh7kRgsZtT0IqKAAgDPaG0LJ7RY/FFWQfi6Zz4W8Q2GjVMW9 +SQVPBLg/5a1UTTVRf47F/emOb0WYXHdmFqPlqCjbUoX945bbKs4hNyEhLXejL/i2Mv6 TxmBhfr+38pKhFxaF2EBVxwwXHWa/vE2JdcUPBlZ2eyBoCJtjoLEHNKrIcuDy1iJ0fOd FShg== X-Gm-Message-State: AOUpUlH1sbO4EzgV8yZBFm5w1LQetmtYmRyeoqhg5jGfq6y8dnvhKkA1 Ms0oPL6CSX7KTCWyVZeAjozVUqynE2eSqeTimaKj/w== X-Received: by 2002:a24:22cf:: with SMTP id o198-v6mr3005405ito.53.1533043402246; Tue, 31 Jul 2018 06:23:22 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a02:918c:0:0:0:0:0 with HTTP; Tue, 31 Jul 2018 06:23:21 -0700 (PDT) In-Reply-To: References: <20180626172900.ufclp2pfrhwkxjco@armageddon.cambridge.arm.com> From: Andrey Konovalov Date: Tue, 31 Jul 2018 15:23:21 +0200 Message-ID: Subject: Re: [PATCH v4 0/7] arm64: untag user pointers passed to the kernel To: Catalin Marinas Cc: Will Deacon , Mark Rutland , Robin Murphy , Al Viro , Kees Cook , Kate Stewart , Greg Kroah-Hartman , Andrew Morton , Ingo Molnar , "Kirill A . Shutemov" , Shuah Khan , Linux ARM , linux-doc@vger.kernel.org, Linux Memory Management List , linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org, LKML , Chintan Pandya , Jacob Bramley , Ruben Ayrapetyan , Lee Smith , Kostya Serebryany , Dmitry Vyukov , Ramana Radhakrishnan , Evgeniy Stepanov Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 16, 2018 at 1:25 PM, Andrey Konovalov wrote: > So the checker reports ~100 different places where a __user pointer > being casted. I've looked through them and found 3 places where we > need to add untagging. Source code lines below come from 4.18-rc2+ > (6f0d349d). > > Place 1: > > arch/arm64/mm/fault.c:302:34: warning: user pointer cast > current->thread.fault_address = (unsigned long)info->si_addr; > > Compare a pointer with TASK_SIZE (1 << 48) to check whether it lies in > the kernel or in user space. Need to untag the address before > performing a comparison. > > Place 2: > > fs/namespace.c:2736:21: warning: user pointer cast > size = TASK_SIZE - (unsigned long)data; > > A similar check performed by subtracting a pointer from TASK_SIZE. > Need to untag before subtracting. > > Place 3: > > drivers/usb/core/devio.c:1407:29: warning: user pointer cast > unsigned long uurb_start = (unsigned long)uurb->buffer; > drivers/usb/core/devio.c:1636:31: warning: user pointer cast > unsigned long uurb_start = (unsigned long)uurb->buffer; > drivers/usb/core/devio.c:1715:30: warning: user pointer cast > unsigned long uurb_start = (unsigned long)uurb->buffer; > > The device keeps list of mmapped areas and searches them for provided > __user pointer. Need to untag before searching. > > There are also a few cases of memory syscalls operating on __user > pointers instead of unsigned longs like mmap: > > ipc/shm.c:1355:23: warning: user pointer cast > unsigned long addr = (unsigned long)shmaddr; > ipc/shm.c:1566:23: warning: user pointer cast > unsigned long addr = (unsigned long)shmaddr; > mm/migrate.c:1586:10: warning: user pointer cast > addr = (unsigned long)p; > mm/migrate.c:1660:24: warning: user pointer cast > unsigned long addr = (unsigned long)(*pages); > > If we don't add untagging to mmap, we probably don't need it here. > > The rest of reported places look fine as is. Full annotated results of > running the checker are here [2]. > > I'll add the 3 patches with fixes to v5 of this patchset. > > Catalin, WDYT? ping