From patchwork Fri Nov 30 21:18:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 10707199 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 49A6F679F for ; Fri, 30 Nov 2018 21:20:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C879305CC for ; Fri, 30 Nov 2018 21:20:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 30D42305D6; Fri, 30 Nov 2018 21:20:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0FC9305CE for ; Fri, 30 Nov 2018 21:19:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726571AbeLAIae (ORCPT ); Sat, 1 Dec 2018 03:30:34 -0500 Received: from mail-it1-f195.google.com ([209.85.166.195]:53864 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725749AbeLAIae (ORCPT ); Sat, 1 Dec 2018 03:30:34 -0500 Received: by mail-it1-f195.google.com with SMTP id g85so618212ita.3 for ; Fri, 30 Nov 2018 13:19:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=01dPSorkMzYoAkW8cLBYQTAhpw9QBeR18qNhoOAgQ3Y=; b=ZzTYc7f7+BmSqMQS0wQU7pPh4Gi/4qecvkbc8I7O7xmmT3cMlknmZL2xtsTHQdpCwv PeqQO/jNy1e+vHSpcsSJIob+uzYZDcTVB58NATPf3IkSvZKuKtTyIdH2rUCQf3QZNMc7 JrolU+cwq5Hm+YvgDwnfZZU9Zia4LgDS4kaxVGwfUFwwfgVH25CmeltSrmys7e89pBhV k0QeyzwVB2y3EirMpHLF6O9UxstqQr7Myh8FOH/QE70NkI1ADP9W8+ykvb8lFuyJQhmV atfZ4slFvBJi07JfPF3il9kvDK+6J3Rbyxj72nHHTh9pQ/BVrS/AwupqdeBh/MCsJByE 1CVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=01dPSorkMzYoAkW8cLBYQTAhpw9QBeR18qNhoOAgQ3Y=; b=ox0/bvfnpqyBv4rXHVcJ178RyXHbWZ+6mvn/Yl1tu8cgmrj3gtZvq2UXr5GZvCnen2 hh1nrNpH/XdA82eDAWuAVnOW7WOltR0cE6JrUxmJqzjD+LXreidyjdSN2ON/lND0sRxE WmAHh4EPGt+bpms+yJNHTk4TUDYEzMtREXeL2qsUaxpWoc9sbnCjfgld01E7I+XSlVYh u5b6gZWbPdxugAKtr4KCSQBr0Vjp3TOpP82LpZ7iEMuK6+iAdFrpkYO3Z9wcViFf0F3q LzgJvsghjpvpElR0WvzW7tm/vylGGTqaNHIKaV2TDM4TKp/3xLXOXdqAOSgVKGVfmJre cyzw== X-Gm-Message-State: AA+aEWaoiSKSMhFIQTlr4EoflybjR9aQwiUYIyh6ME4kJ09kYUGoDA5c iGSJi/bslaP+dKOH0n1xw+7W4vc= X-Google-Smtp-Source: AFSGD/W8r0r8h9vKG2RZ4ogByGn4b60FEdS3eSUu0TptprqQevo7NyDvPRVAxAA3nil6GRGPzDAGkQ== X-Received: by 2002:a24:ce45:: with SMTP id v66-v6mr377906itg.26.1543612796585; Fri, 30 Nov 2018 13:19:56 -0800 (PST) Received: from localhost.localdomain (c-68-40-195-73.hsd1.mi.comcast.net. [68.40.195.73]) by smtp.gmail.com with ESMTPSA id y1sm141393itb.29.2018.11.30.13.19.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Nov 2018 13:19:56 -0800 (PST) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: Chuck Lever Cc: linux-nfs@vger.kernel.org Subject: [PATCH v2 2/3] SUNRPC: Fix leak of krb5p encode pages Date: Fri, 30 Nov 2018 16:18:45 -0500 Message-Id: <20181130211846.89000-2-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181130211846.89000-1-trond.myklebust@hammerspace.com> References: <20181130211846.89000-1-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Chuck Lever call_encode can be invoked more than once per RPC call. Ensure that each call to gss_wrap_req_priv does not overwrite pointers to previously allocated memory. Signed-off-by: Chuck Lever Cc: stable@kernel.org Signed-off-by: Trond Myklebust --- net/sunrpc/auth_gss/auth_gss.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c index 5d3f252659f1..ba765473d1f0 100644 --- a/net/sunrpc/auth_gss/auth_gss.c +++ b/net/sunrpc/auth_gss/auth_gss.c @@ -1791,6 +1791,7 @@ priv_release_snd_buf(struct rpc_rqst *rqstp) for (i=0; i < rqstp->rq_enc_pages_num; i++) __free_page(rqstp->rq_enc_pages[i]); kfree(rqstp->rq_enc_pages); + rqstp->rq_release_snd_buf = NULL; } static int @@ -1799,6 +1800,9 @@ alloc_enc_pages(struct rpc_rqst *rqstp) struct xdr_buf *snd_buf = &rqstp->rq_snd_buf; int first, last, i; + if (rqstp->rq_release_snd_buf) + rqstp->rq_release_snd_buf(rqstp); + if (snd_buf->page_len == 0) { rqstp->rq_enc_pages_num = 0; return 0;