Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3100596imm; Tue, 4 Sep 2018 15:40:20 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaLlUF8w+WLAWorXwYl+nnMmXP3PqJDh2YJQqY8QexBsc6Q+IaRqivoZILt+InK8lK9519o X-Received: by 2002:a17:902:da4:: with SMTP id 33-v6mr35522116plv.193.1536100819978; Tue, 04 Sep 2018 15:40:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536100819; cv=none; d=google.com; s=arc-20160816; b=PThOUyAHMlu2xi3JJpMeiT06Mq7qaPVRPoegN9fNHpjdjG99bfiAcRbVyhmWUaKm5g uhcPwQ95TDp4C6zuhvpmADVYQvLV+slZAVLe2VC29f4MgGkP0Ltnku7bS84GPNyQ0DJm Djmk3Vohfy7B4+xWT4Elm5iTYTQNWQwXcO94jEVitIpIbn7uPDlKJf7Y3wCDosOCqcH1 +ATpcUgiKLQ7NUtQXYyrTfs/2Amehaf30Wp7fjg8FG2DyPCGvB+vIAVVj6og0U5i1vCW 3pTO+1bVWaXEN8xAfyJS7gl3FTv1G1l80rEktNewJZLeCeYoSGV6eRho7rOx5qFpgoWF Y+rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=MQKX0nzEQTFQpscbvHXh8X8s0L4CmQD/gxtDvplqlmo=; b=lyDHnWmEAyci5/cJeY49TTK2lmY4ymDUyw8CdU7fPumGASnI5rHF7qCH4PspZwtC2X NqAaypRNwvStl2YrgNk6SWSXOzWi2qcb68qKi4o4JvoXxmHfjvmS+FRcPYkMFnqS+dOF 8646PTbs5CfgNpMfd625UP3avus9Wtzag+My2dyfNkAGdV32VmewQeFnR3rogvNE3+HD 7/d4iNgKNgNXJkwtO3Zf9//fIehSBEqCGz+d1i/4HFQlVjM3QTaIsEHMQL558jyzwY+b sIKC5nwNK63DkZTi2CdYSfyEaYXYbHtdA2W8m6PMX76xsSvmbA+HoRt9avAVjGk/wxDe MNdg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l63-v6si42389pfg.326.2018.09.04.15.40.04; Tue, 04 Sep 2018 15:40:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727181AbeIEDFp (ORCPT + 99 others); Tue, 4 Sep 2018 23:05:45 -0400 Received: from nautica.notk.org ([91.121.71.147]:41259 "EHLO nautica.notk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725825AbeIEDFp (ORCPT ); Tue, 4 Sep 2018 23:05:45 -0400 Received: by nautica.notk.org (Postfix, from userid 1001) id 05C77C009; Wed, 5 Sep 2018 00:38:32 +0200 (CEST) From: Dominique Martinet To: Omar Sandoval , Andrew Morton Cc: Dominique Martinet , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Alexey Dobriyan , Eric Biederman , James Morse , Bhupesh Sharma , kernel-team@fb.com Subject: [PATCH v3] proc/kcore: fix invalid memory access in multi-page read optimization Date: Wed, 5 Sep 2018 00:38:22 +0200 Message-Id: <1536100702-28706-1-git-send-email-asmadeus@codewreck.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1536100545-26905-1-git-send-email-asmadeus@codewreck.org> References: <1536100545-26905-1-git-send-email-asmadeus@codewreck.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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") 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