From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f194.google.com ([209.85.208.194]:41336 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727254AbeIFA2c (ORCPT ); Wed, 5 Sep 2018 20:28:32 -0400 Received: by mail-lj1-f194.google.com with SMTP id y17-v6so7299374ljy.8 for ; Wed, 05 Sep 2018 12:56:48 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20180904224150.GD24406@vader> References: <1536100545-26905-1-git-send-email-asmadeus@codewreck.org> <1536100702-28706-1-git-send-email-asmadeus@codewreck.org> <20180904224150.GD24406@vader> From: Bhupesh Sharma Date: Thu, 6 Sep 2018 01:26:47 +0530 Message-ID: Subject: Re: [PATCH v3] proc/kcore: fix invalid memory access in multi-page read optimization To: Omar Sandoval Cc: Dominique Martinet , Andrew Morton , Linux Kernel Mailing List , linux-fsdevel@vger.kernel.org, Alexey Dobriyan , Eric Biederman , James Morse , kernel-team@fb.com Content-Type: text/plain; charset="UTF-8" Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Wed, Sep 5, 2018 at 4:11 AM, Omar Sandoval wrote: > On Wed, Sep 05, 2018 at 12:38:22AM +0200, Dominique Martinet wrote: >> The 'm' kcore_list item could point to kclist_head, and it is incorrect to >> look at m->addr / m->size in this case. >> There is no choice but to run through the list of entries for every address >> if we did not find any entry in the previous iteration >> >> Reset 'm' to NULL in that case at Omar Sandoval's suggestion. >> >> Fixes: bf991c2231117 ("proc/kcore: optimize multiple page reads") > > Reviewed-by: Omar Sandoval > > Thanks again for catching this! > >> Signed-off-by: Dominique Martinet >> --- >> >> Sorry, resent v2 because From didn't match sob tag >> >> fs/proc/kcore.c | 1 + >> 1 file changed, 1 insertion(+) >> >> diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c >> index ad72261ee3fe..578926032880 100644 >> --- a/fs/proc/kcore.c >> +++ b/fs/proc/kcore.c >> @@ -464,6 +464,7 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos) >> ret = -EFAULT; >> goto out; >> } >> + m = NULL; >> } else if (m->type == KCORE_VMALLOC) { >> vread(buf, (char *)start, tsz); >> /* we have to zero-fill user buffer even if no read */ >> -- >> 2.17.1 Looks sane to me, so: Reviewed-by: Bhupesh Sharma Thanks.