From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Simo Sorce <simo@redhat.com>,
"J. Bruce Fields" <bfields@redhat.com>
Subject: [ 47/49] rpc: fix huge kmallocs in gss-proxy
Date: Sun, 29 Sep 2013 12:27:21 -0700 [thread overview]
Message-ID: <20130929191606.192725883@linuxfoundation.org> (raw)
In-Reply-To: <20130929191603.008825488@linuxfoundation.org>
3.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: "J. Bruce Fields" <bfields@redhat.com>
commit 9dfd87da1aeb0fd364167ad199f40fe96a6a87be upstream.
The reply to a gssproxy can include up to NGROUPS_MAX gid's, which will
take up more than a page. We therefore need to allocate an array of
pages to hold the reply instead of trying to allocate a single huge
buffer.
Tested-by: Simo Sorce <simo@redhat.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
net/sunrpc/auth_gss/gss_rpc_upcall.c | 30 ++++++++++++++++++++++++++++++
net/sunrpc/auth_gss/gss_rpc_xdr.c | 3 +++
net/sunrpc/auth_gss/gss_rpc_xdr.h | 5 ++++-
3 files changed, 37 insertions(+), 1 deletion(-)
--- a/net/sunrpc/auth_gss/gss_rpc_upcall.c
+++ b/net/sunrpc/auth_gss/gss_rpc_upcall.c
@@ -213,6 +213,30 @@ static int gssp_call(struct net *net, st
return status;
}
+static void gssp_free_receive_pages(struct gssx_arg_accept_sec_context *arg)
+{
+ int i;
+
+ for (i = 0; i < arg->npages && arg->pages[i]; i++)
+ __free_page(arg->pages[i]);
+}
+
+static int gssp_alloc_receive_pages(struct gssx_arg_accept_sec_context *arg)
+{
+ int i;
+
+ arg->npages = DIV_ROUND_UP(NGROUPS_MAX * 4, PAGE_SIZE);
+ arg->pages = kzalloc(arg->npages * sizeof(struct page *), GFP_KERNEL);
+
+ for (i=0; i < arg->npages; i++) {
+ arg->pages[i] = alloc_page(GFP_KERNEL);
+ if (arg->pages[i] == NULL) {
+ gssp_free_receive_pages(arg);
+ return -ENOMEM;
+ }
+ }
+ return 0;
+}
/*
* Public functions
@@ -261,10 +285,16 @@ int gssp_accept_sec_context_upcall(struc
arg.context_handle = &ctxh;
res.output_token->len = GSSX_max_output_token_sz;
+ ret = gssp_alloc_receive_pages(&arg);
+ if (ret)
+ return ret;
+
/* use nfs/ for targ_name ? */
ret = gssp_call(net, &msg);
+ gssp_free_receive_pages(&arg);
+
/* we need to fetch all data even in case of error so
* that we can free special strctures is they have been allocated */
data->major_status = res.status.major_status;
--- a/net/sunrpc/auth_gss/gss_rpc_xdr.c
+++ b/net/sunrpc/auth_gss/gss_rpc_xdr.c
@@ -780,6 +780,9 @@ void gssx_enc_accept_sec_context(struct
/* arg->options */
err = dummy_enc_opt_array(xdr, &arg->options);
+ xdr_inline_pages(&req->rq_rcv_buf,
+ PAGE_SIZE/2 /* pretty arbitrary */,
+ arg->pages, 0 /* page base */, arg->npages * PAGE_SIZE);
done:
if (err)
dprintk("RPC: gssx_enc_accept_sec_context: %d\n", err);
--- a/net/sunrpc/auth_gss/gss_rpc_xdr.h
+++ b/net/sunrpc/auth_gss/gss_rpc_xdr.h
@@ -147,6 +147,8 @@ struct gssx_arg_accept_sec_context {
struct gssx_cb *input_cb;
u32 ret_deleg_cred;
struct gssx_option_array options;
+ struct page **pages;
+ unsigned int npages;
};
struct gssx_res_accept_sec_context {
@@ -240,7 +242,8 @@ int gssx_dec_accept_sec_context(struct r
2 * GSSX_max_princ_sz + \
8 + 8 + 4 + 4 + 4)
#define GSSX_max_output_token_sz 1024
-#define GSSX_max_creds_sz (4 + 4 + 4 + NGROUPS_MAX * 4)
+/* grouplist not included; we allocate separate pages for that: */
+#define GSSX_max_creds_sz (4 + 4 + 4 /* + NGROUPS_MAX*4 */)
#define GSSX_RES_accept_sec_context_sz (GSSX_default_status_sz + \
GSSX_default_ctx_sz + \
GSSX_max_output_token_sz + \
next prev parent reply other threads:[~2013-09-29 19:27 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-29 19:26 [ 00/49] 3.10.14-stable review Greg Kroah-Hartman
2013-09-29 19:26 ` [ 01/49] PCI / ACPI / PM: Clear pme_poll for devices in D3cold on wakeup Greg Kroah-Hartman
2013-09-29 19:26 ` [ 02/49] net: usb: cdc_ether: Use wwan interface for Telit modules Greg Kroah-Hartman
2013-09-29 19:26 ` [ 03/49] cifs: fix filp leak in cifs_atomic_open() Greg Kroah-Hartman
2013-09-29 19:26 ` [ 04/49] bgmac: fix internal switch initialization Greg Kroah-Hartman
2013-09-29 19:26 ` [ 05/49] rt2800: fix wrong TX power compensation Greg Kroah-Hartman
2013-09-29 19:26 ` [ 06/49] timekeeping: Fix HRTICK related deadlock from ntp lock changes Greg Kroah-Hartman
2013-09-29 19:26 ` [ 07/49] sched/cputime: Do not scale when utime == 0 Greg Kroah-Hartman
2013-09-29 19:26 ` [ 08/49] sched/fair: Fix small race where child->se.parent,cfs_rq might point to invalid ones Greg Kroah-Hartman
2013-09-29 19:26 ` [ 09/49] HID: provide a helper for validating hid reports Greg Kroah-Hartman
2013-09-29 19:26 ` [ 10/49] HID: validate feature and input report details Greg Kroah-Hartman
2013-09-29 19:26 ` [ 11/49] HID: multitouch: validate indexes details Greg Kroah-Hartman
2013-09-29 19:26 ` [ 12/49] HID: LG: validate HID output report details Greg Kroah-Hartman
2013-09-29 19:26 ` [ 13/49] HID: zeroplus: validate " Greg Kroah-Hartman
2013-09-29 19:26 ` [ 14/49] HID: lenovo-tpkbd: fix leak if tpkbd_probe_tp fails Greg Kroah-Hartman
2013-09-29 19:26 ` [ 15/49] HID: steelseries: validate output report details Greg Kroah-Hartman
2013-09-29 19:26 ` [ 16/49] HID: lenovo-tpkbd: " Greg Kroah-Hartman
2013-09-29 19:26 ` [ 17/49] HID: logitech-dj: " Greg Kroah-Hartman
2013-09-29 19:26 ` [ 18/49] usb: gadget: fix a bug and a WARN_ON in dummy-hcd Greg Kroah-Hartman
2013-09-29 19:26 ` [ 19/49] drm/i915: fix gpu hang vs. flip stall deadlocks Greg Kroah-Hartman
2013-09-29 19:26 ` [ 20/49] drm/i915: fix wait_for_pending_flips vs gpu hang deadlock Greg Kroah-Hartman
2013-09-29 19:26 ` [ 21/49] drm: fix DRM_IOCTL_MODE_GETFB handle-leak Greg Kroah-Hartman
2013-09-29 19:26 ` [ 22/49] drm/ast: fix the ast open key function Greg Kroah-Hartman
2013-09-29 19:26 ` [ 23/49] drm/ttm: fix the tt_populated check in ttm_tt_destroy() Greg Kroah-Hartman
2013-09-29 19:26 ` [ 24/49] drm/nv50/disp: prevent false output detection on the original nv50 Greg Kroah-Hartman
2013-09-29 19:26 ` [ 25/49] drm/radeon: fix LCD record parsing Greg Kroah-Hartman
2013-09-29 19:27 ` [ 26/49] drm/radeon: fix endian bugs in hw i2c atom routines Greg Kroah-Hartman
2013-09-29 19:27 ` [ 27/49] drm/radeon/si: Add support for CP DMA to CS checker for compute v2 Greg Kroah-Hartman
2013-09-29 19:27 ` [ 28/49] drm/radeon: update line buffer allocation for dce4.1/5 Greg Kroah-Hartman
2013-09-29 19:27 ` [ 29/49] drm/radeon: update line buffer allocation for dce6 Greg Kroah-Hartman
2013-09-29 19:27 ` [ 30/49] drm/radeon: fix resume on some rs4xx boards (v2) Greg Kroah-Hartman
2013-09-29 19:27 ` [ 31/49] drm/radeon: fix handling of variable sized arrays for router objects Greg Kroah-Hartman
2013-09-29 19:27 ` [ 32/49] rt2800: change initialization sequence to fix system freeze Greg Kroah-Hartman
2013-09-29 19:27 ` [ 33/49] drm/radeon/atom: workaround vbios bug in transmitter table on rs880 (v2) Greg Kroah-Hartman
2013-09-29 19:27 ` [ 34/49] drm/radeon: fix panel scaling with eDP and LVDS bridges Greg Kroah-Hartman
2013-09-29 19:27 ` [ 35/49] drm/radeon: avoid UVD corruptions on AGP cards Greg Kroah-Hartman
2013-09-29 19:27 ` [ 36/49] media: media/usb: fix kconfig dependencies Greg Kroah-Hartman
2013-09-29 19:27 ` [ 37/49] Properly handle tristate dependencies on USB/PCI menus Greg Kroah-Hartman
2013-09-29 19:27 ` [ 38/49] udf: Standardize return values in mount sequence Greg Kroah-Hartman
2013-09-29 19:27 ` [ 39/49] udf: Refuse RW mount of the filesystem instead of making it RO Greg Kroah-Hartman
2013-09-29 19:27 ` [ 40/49] audit: fix endless wait in audit_log_start() Greg Kroah-Hartman
2013-09-29 19:27 ` [ 41/49] mm: fix aio performance regression for database caused by THP Greg Kroah-Hartman
2013-09-29 19:27 ` [ 42/49] perf tools: Handle JITed code in shared memory Greg Kroah-Hartman
2013-09-29 19:27 ` [ 43/49] bio-integrity: Fix use of bs->bio_integrity_pool after free Greg Kroah-Hartman
2013-09-29 19:27 ` [ 44/49] cfq: explicitly use 64bit divide operation for 64bit arguments Greg Kroah-Hartman
2013-09-29 19:27 ` [ 45/49] rpc: clean up decoding of gssproxy linux creds Greg Kroah-Hartman
2013-09-29 19:27 ` [ 46/49] rpc: comment on linux_cred encoding, treat all as unsigned Greg Kroah-Hartman
2013-09-29 19:27 ` Greg Kroah-Hartman [this message]
2013-09-29 19:27 ` [ 48/49] rpc: let xdr layer allocate gssproxy receieve pages Greg Kroah-Hartman
2013-09-29 19:27 ` [ 49/49] netfilter: ipset: Fix serious failure in CIDR tracking Greg Kroah-Hartman
2013-09-30 1:27 ` [ 00/49] 3.10.14-stable review Guenter Roeck
2013-09-30 1:50 ` Greg Kroah-Hartman
2013-10-01 19:22 ` Shuah Khan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130929191606.192725883@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=bfields@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=simo@redhat.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).