* [Qemu-devel] [PATCH] block/nfs: limit maximum readahead size to 1MB
@ 2015-06-26 11:14 Peter Lieven
2015-06-29 16:11 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
0 siblings, 1 reply; 2+ messages in thread
From: Peter Lieven @ 2015-06-26 11:14 UTC (permalink / raw)
To: qemu-block, qemu-devel
Cc: kwolf, jcody, Peter Lieven, qemu-stable, ronniesahlberg
a malicious caller could otherwise specify a very
large value via the URI and force libnfs to allocate
a large amount of memory for the readahead buffer.
Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Lieven <pl@kamp.de>
---
block/nfs.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/block/nfs.c b/block/nfs.c
index 43d48ae..4fb1937 100644
--- a/block/nfs.c
+++ b/block/nfs.c
@@ -35,6 +35,8 @@
#include "sysemu/sysemu.h"
#include <nfsc/libnfs.h>
+#define QEMU_NFS_MAX_READAHEAD_SIZE 1048576
+
typedef struct NFSClient {
struct nfs_context *context;
struct nfsfh *fh;
@@ -351,6 +353,11 @@ static int64_t nfs_client_open(NFSClient *client, const char *filename,
nfs_set_tcp_syncnt(client->context, val);
#ifdef LIBNFS_FEATURE_READAHEAD
} else if (!strcmp(qp->p[i].name, "readahead")) {
+ if (val > QEMU_NFS_MAX_READAHEAD_SIZE) {
+ error_report("NFS Warning: Truncating NFS readahead"
+ " size to %d", QEMU_NFS_MAX_READAHEAD_SIZE);
+ val = QEMU_NFS_MAX_READAHEAD_SIZE;
+ }
nfs_set_readahead(client->context, val);
#endif
} else {
--
1.7.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [Qemu-block] [PATCH] block/nfs: limit maximum readahead size to 1MB
2015-06-26 11:14 [Qemu-devel] [PATCH] block/nfs: limit maximum readahead size to 1MB Peter Lieven
@ 2015-06-29 16:11 ` Stefan Hajnoczi
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Hajnoczi @ 2015-06-29 16:11 UTC (permalink / raw)
To: Peter Lieven; +Cc: kwolf, ronniesahlberg, qemu-devel, qemu-block, qemu-stable
[-- Attachment #1: Type: text/plain, Size: 473 bytes --]
On Fri, Jun 26, 2015 at 01:14:01PM +0200, Peter Lieven wrote:
> a malicious caller could otherwise specify a very
> large value via the URI and force libnfs to allocate
> a large amount of memory for the readahead buffer.
>
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Peter Lieven <pl@kamp.de>
> ---
> block/nfs.c | 7 +++++++
> 1 file changed, 7 insertions(+)
Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block
Stefan
[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-06-29 16:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-26 11:14 [Qemu-devel] [PATCH] block/nfs: limit maximum readahead size to 1MB Peter Lieven
2015-06-29 16:11 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
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).