X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=libcfs%2Flibcfs%2Flinux%2Flinux-curproc.c;h=fee47a23fc0a5654361607ce53c7fdda0a8256d8;hb=6488c0ec57de2d188bd15e502917b762e3a9dd1d;hp=b846627a31a802994af4529de5c14b8c4c572997;hpb=72057a3af19ee02d9a686bd7e7d074917e381310;p=fs%2Flustre-release.git diff --git a/libcfs/libcfs/linux/linux-curproc.c b/libcfs/libcfs/linux/linux-curproc.c index b846627..fee47a2 100644 --- a/libcfs/libcfs/linux/linux-curproc.c +++ b/libcfs/libcfs/linux/linux-curproc.c @@ -23,7 +23,7 @@ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2012, 2015, Intel Corporation. + * Copyright (c) 2012, 2017, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -37,8 +37,12 @@ */ #include +#ifdef HAVE_SCHED_HEADERS +#include +#include +#endif #include - +#include #include #include @@ -149,7 +153,9 @@ static int cfs_access_process_vm(struct task_struct *tsk, int bytes, rc, offset; void *maddr; -#ifdef HAVE_GET_USER_PAGES_6ARG +#if defined(HAVE_GET_USER_PAGES_GUP_FLAGS) + rc = get_user_pages(addr, 1, write ? FOLL_WRITE : 0, &page, &vma); +#elif defined(HAVE_GET_USER_PAGES_6ARG) rc = get_user_pages(addr, 1, write, 1, &page, &vma); #else rc = get_user_pages(tsk, mm, addr, 1, write, 1, &page, &vma); @@ -256,9 +262,14 @@ int cfs_get_environ(const char *key, char *value, int *val_len) !memcmp(entry, key, key_len)) { entry += key_len + 1; entry_len -= key_len + 1; - /* The 'value' buffer passed in is too small.*/ - if (entry_len >= *val_len) + + /* The 'value' buffer passed in is too small. + * Copy what fits, but return -EOVERFLOW. */ + if (entry_len >= *val_len) { + memcpy(value, entry, *val_len); + value[*val_len - 1] = 0; GOTO(out, rc = -EOVERFLOW); + } memcpy(value, entry, entry_len); *val_len = entry_len;