From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,T_DKIMWL_WL_HIGH,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B3CFC28CC5 for ; Sat, 8 Jun 2019 04:02:31 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D6205208C0 for ; Sat, 8 Jun 2019 04:02:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="IeVV20O7"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="HXvVg9co" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D6205208C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=iywVFrzrnuH0rnU33RRLvQ6yGo8n75gVbnTH/zNr7Jw=; b=IeVV20O7rCLprZ dplBzztIFl039HpZ3tl1ZnUVPm8Ne19v69xXSdKpRaFjy+LYi+MO4HPDTBQBvY+0m0Hi2h673oYq/ SI6lEJmDdGNXapkrtwjgDyu6HRjQuLxO0leEs9zuCzD8QfB1ihf3oVQwemXZRoV5UrdUFo00SEGto zJV7Fg+Bfj8xY8Q+L5MQ7tRA2405sR4Zil4PuH4wsWAXPAk8wQirlq6e1Aw+lxLUTS80zADqDfE9t upQvBMs1LRXTZuLgxhU4bAVRyuXlePKMcynCAYeYdpHDTKONdRxNkGfGb8W+cc0j6lA58+Zf6eZh7 nkA+p7arbEP44nI4EKiw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hZSYo-0005jb-Bu; Sat, 08 Jun 2019 04:02:30 +0000 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hZSYl-0005iq-21 for linux-arm-kernel@lists.infradead.org; Sat, 08 Jun 2019 04:02:28 +0000 Received: by mail-pl1-x644.google.com with SMTP id bi6so1141271plb.12 for ; Fri, 07 Jun 2019 21:02:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ld9qqur+4qvQ29YBRyUFm2eutAmUIhRNEhUVQshxtq0=; b=HXvVg9coUo1xEEGS0DwgDUYkxEz6DS1r+bnepiqG47VSO6k+SKaBqi5wnLJUzhKT0Q F77v/3inF5WO9KdoxanRYXG9UTvU9WuNvhZbHSnOvkwygp4/KRjUvBwoWTTXrnkExWcy ADu9rIK/0BZ8VaknNJsilZ7GGCNNLhX/1899U= 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; bh=ld9qqur+4qvQ29YBRyUFm2eutAmUIhRNEhUVQshxtq0=; b=ZjzBFI5u3ozmNTX8ts6uMXkgMmX/YDcgpV9Xf09Lzo/g6d9iXV5OCsxoPtHo/Cjh0t hPaQCOcG9dQbGokgoIuQTLAjjItFjxAAM9PqemT/iP5GaE/ZjNnO4ZbtgipRFA5oCTcB +6EOoGdVqBY29iiozga7sTdlERP7VyVR8FUXQVHjbQYbPBEO7e1H+HcxTSKJGKIyeLFF sDcWJizImFvQVS5/BIgmMiFqckOxNteVe8qSON9J8dNt95XlrMo0yp2gj/vR21O33o6S Yhc98jXXmlFuV86q76HPbMCaj7m4i39WEpFWPfDldyiHjJXYcaYQ2vSn7uMqyFo4Vyzg JXMw== X-Gm-Message-State: APjAAAVacyXnyvW3JZoR+Ig4/P1JtvwZuP2r43Cs4W0f20rE2pYrOtJY UT3JL/yfdtUmKZpoEA7ONxP1Jg== X-Google-Smtp-Source: APXvYqyWIU7z0h83s595E4gtAHnTw/dwV2AWdUHb9XfpIujI04l63mQHZIFAtQw1iHXTD7aat4vguA== X-Received: by 2002:a17:902:8ec3:: with SMTP id x3mr57418900plo.340.1559966546670; Fri, 07 Jun 2019 21:02:26 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id b16sm3567551pfd.12.2019.06.07.21.02.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Jun 2019 21:02:25 -0700 (PDT) Date: Fri, 7 Jun 2019 21:02:25 -0700 From: Kees Cook To: Andrey Konovalov Subject: Re: [PATCH v16 08/16] fs, arm64: untag user pointers in copy_mount_options Message-ID: <201906072101.58C919E@keescook> References: <51f44a12c4e81c9edea8dcd268f820f5d1fad87c.1559580831.git.andreyknvl@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <51f44a12c4e81c9edea8dcd268f820f5d1fad87c.1559580831.git.andreyknvl@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190607_210227_124613_1DF2EBDB X-CRM114-Status: GOOD ( 21.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , kvm@vger.kernel.org, Szabolcs Nagy , Catalin Marinas , Will Deacon , dri-devel@lists.freedesktop.org, linux-mm@kvack.org, Khalid Aziz , linux-kselftest@vger.kernel.org, Felix Kuehling , Vincenzo Frascino , Jacob Bramley , Leon Romanovsky , linux-rdma@vger.kernel.org, amd-gfx@lists.freedesktop.org, Christoph Hellwig , Jason Gunthorpe , Dmitry Vyukov , Dave Martin , Evgeniy Stepanov , linux-media@vger.kernel.org, Kevin Brodsky , Ruben Ayrapetyan , Ramana Radhakrishnan , Alex Williamson , Mauro Carvalho Chehab , linux-arm-kernel@lists.infradead.org, Kostya Serebryany , Greg Kroah-Hartman , Yishai Hadas , linux-kernel@vger.kernel.org, Jens Wiklander , Lee Smith , Alexander Deucher , Andrew Morton , enh , Robin Murphy , Christian Koenig , Luc Van Oostenryck Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Jun 03, 2019 at 06:55:10PM +0200, Andrey Konovalov wrote: > This patch is a part of a series that extends arm64 kernel ABI to allow to > pass tagged user pointers (with the top byte set to something else other > than 0x00) as syscall arguments. > > In copy_mount_options a user address is being subtracted from TASK_SIZE. > If the address is lower than TASK_SIZE, the size is calculated to not > allow the exact_copy_from_user() call to cross TASK_SIZE boundary. > However if the address is tagged, then the size will be calculated > incorrectly. > > Untag the address before subtracting. > > Reviewed-by: Catalin Marinas > Signed-off-by: Andrey Konovalov One thing I just noticed in the commit titles... "arm64" is in the prefix, but these are arch-indep areas. Should the ", arm64" be left out? I would expect, instead: fs/namespace: untag user pointers in copy_mount_options Reviewed-by: Kees Cook -Kees > --- > fs/namespace.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/namespace.c b/fs/namespace.c > index b26778bdc236..2e85712a19ed 100644 > --- a/fs/namespace.c > +++ b/fs/namespace.c > @@ -2993,7 +2993,7 @@ void *copy_mount_options(const void __user * data) > * the remainder of the page. > */ > /* copy_from_user cannot cross TASK_SIZE ! */ > - size = TASK_SIZE - (unsigned long)data; > + size = TASK_SIZE - (unsigned long)untagged_addr(data); > if (size > PAGE_SIZE) > size = PAGE_SIZE; > > -- > 2.22.0.rc1.311.g5d7573a151-goog > -- Kees Cook _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel