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=-11.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 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 160CFC43457 for ; Mon, 19 Oct 2020 15:23:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9395822365 for ; Mon, 19 Oct 2020 15:23:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=fieldses.org header.i=@fieldses.org header.b="joviL40j" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730103AbgJSPXE (ORCPT ); Mon, 19 Oct 2020 11:23:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729544AbgJSPXD (ORCPT ); Mon, 19 Oct 2020 11:23:03 -0400 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00:e000:2f7::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D22D2C0613CE; Mon, 19 Oct 2020 08:23:02 -0700 (PDT) Received: by fieldses.org (Postfix, from userid 2815) id E5ADBAAD; Mon, 19 Oct 2020 11:23:01 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.11.0 fieldses.org E5ADBAAD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fieldses.org; s=default; t=1603120981; bh=lT5xtlsxdwOYkecuDWJlMrE8tDokDHNn495zYSF9O6g=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=joviL40jSOAtezsmhplLPOD506JpAKoE7uAJXqz9d5tKuxsgLjzu7RUEVujcEdkZe hZi5lpwnRHX4cywOrMhkd5Wui10LqL4MCOg9YVE/veJ6ilSTIsnTw8Uq6RZpEBlFdK ObD5ClmzEJkWXd77ArKXZpDkLAjIxqiljgfasrDk= Date: Mon, 19 Oct 2020 11:23:01 -0400 From: "J. Bruce Fields" To: Martijn de Gouw Cc: Trond Myklebust , Anna Schumaker , Chuck Lever , "David S. Miller" , Jakub Kicinski , Arnd Bergmann , NeilBrown , Alexey Dobriyan , Roberto Bergantinos Corpas , "open list:NFS, SUNRPC, AND LOCKD CLIENTS" , "open list:NETWORKING [GENERAL]" , open list Subject: Re: [PATCH] SUNRPC: fix copying of multiple pages in gss_read_proxy_verf() Message-ID: <20201019152301.GC32403@fieldses.org> References: <20201019114229.52973-1-martijn.de.gouw@prodrive-technologies.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201019114229.52973-1-martijn.de.gouw@prodrive-technologies.com> User-Agent: Mutt/1.5.21 (2010-09-15) Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Mon, Oct 19, 2020 at 01:42:27PM +0200, Martijn de Gouw wrote: > When the passed token is longer than 4032 bytes, the remaining part > of the token must be copied from the rqstp->rq_arg.pages. But the > copy must make sure it happens in a consecutive way. Thanks. Apologies, but I don't immediately see where the copy is non-consecutive. What exactly is the bug in the existing code? --b. > > Signed-off-by: Martijn de Gouw > --- > net/sunrpc/auth_gss/svcauth_gss.c | 27 +++++++++++++++++---------- > 1 file changed, 17 insertions(+), 10 deletions(-) > > diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c > index 258b04372f85..bd4678db9d76 100644 > --- a/net/sunrpc/auth_gss/svcauth_gss.c > +++ b/net/sunrpc/auth_gss/svcauth_gss.c > @@ -1147,9 +1147,9 @@ static int gss_read_proxy_verf(struct svc_rqst *rqstp, > struct gssp_in_token *in_token) > { > struct kvec *argv = &rqstp->rq_arg.head[0]; > - unsigned int page_base, length; > - int pages, i, res; > - size_t inlen; > + unsigned int length, pgto_offs, pgfrom_offs; > + int pages, i, res, pgto, pgfrom; > + size_t inlen, to_offs, from_offs; > > res = gss_read_common_verf(gc, argv, authp, in_handle); > if (res) > @@ -1177,17 +1177,24 @@ static int gss_read_proxy_verf(struct svc_rqst *rqstp, > memcpy(page_address(in_token->pages[0]), argv->iov_base, length); > inlen -= length; > > - i = 1; > - page_base = rqstp->rq_arg.page_base; > + to_offs = length; > + from_offs = rqstp->rq_arg.page_base; > while (inlen) { > - length = min_t(unsigned int, inlen, PAGE_SIZE); > - memcpy(page_address(in_token->pages[i]), > - page_address(rqstp->rq_arg.pages[i]) + page_base, > + pgto = to_offs >> PAGE_SHIFT; > + pgfrom = from_offs >> PAGE_SHIFT; > + pgto_offs = to_offs & ~PAGE_MASK; > + pgfrom_offs = from_offs & ~PAGE_MASK; > + > + length = min_t(unsigned int, inlen, > + min_t(unsigned int, PAGE_SIZE - pgto_offs, > + PAGE_SIZE - pgfrom_offs)); > + memcpy(page_address(in_token->pages[pgto]) + pgto_offs, > + page_address(rqstp->rq_arg.pages[pgfrom]) + pgfrom_offs, > length); > > + to_offs += length; > + from_offs += length; > inlen -= length; > - page_base = 0; > - i++; > } > return 0; > } > -- > 2.20.1