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=-6.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 53F09C76194 for ; Mon, 22 Jul 2019 16:46:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2D28E21911 for ; Mon, 22 Jul 2019 16:46:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="VX6SSuVo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728833AbfGVQqJ (ORCPT ); Mon, 22 Jul 2019 12:46:09 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:43998 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726925AbfGVQqJ (ORCPT ); Mon, 22 Jul 2019 12:46:09 -0400 Received: by mail-pg1-f194.google.com with SMTP id f25so17915708pgv.10 for ; Mon, 22 Jul 2019 09:46:09 -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=F8BugWPvgcU2u1kFFZKMyP/IOkg4/qodeykECt+PCWA=; b=VX6SSuVoSHuo5NAioif+DJtSSs1RJl179j5hlo4DTfAYF66Jgcx0vpiJB8eR+9HEL8 +f/45Mc4lQN3jKnZezfzKg+yOPAVpcviTazcgmREFQYvaP41eWd/rYtiTmOP5jut4IGW UsbCxeU7Nx57xcR3YkKPrTzMk7AWS/2VcXYuY= 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=F8BugWPvgcU2u1kFFZKMyP/IOkg4/qodeykECt+PCWA=; b=DWYKmk4jbSQueCChtX8LxskRwwQuxNfOdtj0JNU17+88mtyB4SMjgYMnE7ek7zep4g akucIuccVRK+Hh5q3jDAzKKhmc7d7nAdH9P5uxe2zuHfLOBmLpAMIGLZHJ1fcpLAHBO9 mH3T/UB/2iT0qUiZM7/ixrxblFtlGIiXgC5zVYVC0ERzFGQe859FwKfGyj44BD+uj3nA VL+cb7A9E1qWmUnbBc9y9RpeidGgRDwbFGdslVEMv6RxfZNUE3yAQPZCGsSoBNlojJdM GgXhO+F9LpnZMSUg+Y0kW567S6vRJqGq4EotPzfTkWiDoOwZmJwYn+w2n2MfQtdJjYTg rnFQ== X-Gm-Message-State: APjAAAUc8fO+EFVbzAfz9cMHhfQCLX3ByJMZrPbyYRIiXf8Ra9OG566P F9Bi4HqAcSSsbG7J0715IbUZsw== X-Google-Smtp-Source: APXvYqzl1okfrN5zPZDspTEQta/i5+YABh20qrSg3GL1AN5406TswuRoR6v+V+I5B+11TbFoYh/o0Q== X-Received: by 2002:a17:90a:ff17:: with SMTP id ce23mr77676431pjb.47.1563813968675; Mon, 22 Jul 2019 09:46:08 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id 4sm48411440pfc.92.2019.07.22.09.46.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 09:46:07 -0700 (PDT) Date: Mon, 22 Jul 2019 09:46:06 -0700 From: Kees Cook To: Andrey Konovalov Cc: Al Viro , Eric Biederman , Linux ARM , Linux Memory Management List , LKML , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-rdma@vger.kernel.org, linux-media@vger.kernel.org, kvm@vger.kernel.org, "open list:KERNEL SELFTEST FRAMEWORK" , Vincenzo Frascino , Will Deacon , Mark Rutland , Andrew Morton , Greg Kroah-Hartman , Yishai Hadas , Felix Kuehling , Alexander Deucher , Christian Koenig , Mauro Carvalho Chehab , Jens Wiklander , Alex Williamson , Leon Romanovsky , Luc Van Oostenryck , Dave Martin , Khalid Aziz , enh , Jason Gunthorpe , Christoph Hellwig , Dmitry Vyukov , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Robin Murphy , Kevin Brodsky , Szabolcs Nagy , Catalin Marinas Subject: Re: [PATCH v18 07/15] fs/namespace: untag user pointers in copy_mount_options Message-ID: <201907220944.5821C92518@keescook> References: <41e0a911e4e4d533486a1468114e6878e21f9f84.1561386715.git.andreyknvl@google.com> <20190624175009.GM29120@arrakis.emea.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org +Eric Biederman too, who might be able to Ack this... On Mon, Jul 15, 2019 at 06:00:04PM +0200, Andrey Konovalov wrote: > On Mon, Jun 24, 2019 at 7:50 PM Catalin Marinas wrote: > > > > On Mon, Jun 24, 2019 at 04:32:52PM +0200, Andrey Konovalov wrote: > > > This patch is a part of a series that extends 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: Khalid Aziz > > > Reviewed-by: Vincenzo Frascino > > > Reviewed-by: Kees Cook > > > Reviewed-by: Catalin Marinas > > > Signed-off-by: Andrey Konovalov > > > --- > > > fs/namespace.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/fs/namespace.c b/fs/namespace.c > > > index 7660c2749c96..ec78f7223917 100644 > > > --- a/fs/namespace.c > > > +++ b/fs/namespace.c > > > @@ -2994,7 +2994,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; > > > > I think this patch needs an ack from Al Viro (cc'ed). > > > > -- > > Catalin > > Hi Al, > > Could you take a look and give your acked-by? > > Thanks! -- Kees Cook