Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3090258imm; Tue, 4 Sep 2018 15:26:07 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbqB4UFFRsM2ZnWYf1iI73hshGAAhWbOxf8SDfMH9jEVPS0k0C1uB80E3nV9vpIYcXs2fZH X-Received: by 2002:a65:520d:: with SMTP id o13-v6mr33591544pgp.282.1536099967114; Tue, 04 Sep 2018 15:26:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536099967; cv=none; d=google.com; s=arc-20160816; b=oydNKO1HiIGrB1tpAW32y5rSd0Vf/Z2kRGTN8T/mprPKEfW7XvQFSEfI8xxw7bqkyD q/oUX05cV+MPHeEwXyyUMHDpyDmSVJCEhrYYCKKOJqY1xFtj5pQp2JK70t7hLU8rqBt7 oKMB7SCZq6KGOd/2scJgGoPdXcNERvMmeJoIRFZfM/ocBDmyIqYW/lqrWiMrZQuzuRAy /cB7Nx2O9tL/mKZtTjD7mxt9xfLBDD7NtbUbTne8RvlcG4i+fKYMrnOI9lcqdQASlUNF ql28y8fVco0eO1S1w6VCycZlKnRjDRnOv5TpcnCI+ikEYA6OU8HC9fA3BSI9YpbLVAk+ UrXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=s088Ohjpjem9+RRkE/abgkDpI1zj1NoZTaoQArrUyI8=; b=jMzdKgEWSrz4+8oiVO6awZwtN+q/66LH9GlF4n5Uia08jskh/SMGJTWg2qNgJNncrA MUIhT1WqCiORW9jlcpBCk8Dc+xx0qE9sB5hRGwNlWMAtGPXVEf4D92Mib1tH9ojNSgak UttI4jIut7aaw/nXNiOh4L5gQRkJBuawKUnfuCa/YoL1nS6f3BLHRsyrL7NGNPAnV1HX oUKlKcJ37yndrf40FTlS7nFxFYB77b6h4QQ9ShLqpXwNcgXflNVn9AILhfs2uBXuvpti 7/1TPeSymonEUXIwr7poYoDPmWAuESH5WE7i18wvpg5LaXX5LXZLarer87pkFy5IMaJV A8Mg== 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 35-v6si39144pgz.453.2018.09.04.15.25.49; Tue, 04 Sep 2018 15:26:07 -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 S1726497AbeIECvr (ORCPT + 99 others); Tue, 4 Sep 2018 22:51:47 -0400 Received: from nautica.notk.org ([91.121.71.147]:55251 "EHLO nautica.notk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725825AbeIECvr (ORCPT ); Tue, 4 Sep 2018 22:51:47 -0400 Received: by nautica.notk.org (Postfix, from userid 1001) id 0ECB2C009; Wed, 5 Sep 2018 00:24:37 +0200 (CEST) Date: Wed, 5 Sep 2018 00:24:22 +0200 From: Dominique Martinet To: Omar Sandoval Cc: Andrew Morton , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Alexey Dobriyan , Eric Biederman , James Morse , Bhupesh Sharma , kernel-team@fb.com Subject: Re: [PATCH] proc/kcore: fix invalid memory access in multi-page read optimization Message-ID: <20180904222422.GB17486@nautica> References: <20180828105959.GA29204@nautica> <1535515447-21167-1-git-send-email-asmadeus@codewreck.org> <20180904180352.GA24406@vader> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180904180352.GA24406@vader> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Omar Sandoval wrote on Tue, Sep 04, 2018: > On Wed, Aug 29, 2018 at 06:04:07AM +0200, Dominique Martinet wrote: > > The 'm' kcore_list item can 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 > > > > Fixes: bf991c2231117 ("proc/kcore: optimize multiple page reads") > > Signed-off-by: Dominique Martinet > > --- > > > > I guess now I'm looking at bf991c2231117 again that it would be slightly > > more efficient to remove the !m check and initialize m to point to > > kclist_head like this: > > m = list_entry(&kclist_head, struct kcore_list, list); > > but it feels a bit forced to me; deferring the choice to others. > > Good catch! Sorry I missed this last week, Google decided this was spam > for some reason. Joys of self-hosted emails, it happens from time to time :/ > How about fixing it like this? One less conditional in the common > case, no hacky list_entry :) Good idea, I'll send a v2 in a few minutes after rebooting into it, no reason it won't work but might as well make earth a slightly warmer place along the way. -- Dominique