Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1346776imm; Wed, 25 Jul 2018 16:36:08 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeM8I7VWNyWFWW7jUNVTzUh+5sewES6aGrwedTQIXYvK3rVpVKt0UguV1/nJ2hvZ7qamZxE X-Received: by 2002:a63:29c6:: with SMTP id p189-v6mr22694715pgp.305.1532561768203; Wed, 25 Jul 2018 16:36:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532561768; cv=none; d=google.com; s=arc-20160816; b=ESoyKmHKrFP+6Poz2yrGYJcDmLr48X9YzOGBxKZqDFxGHWb0GCGeB5rvxRPqGHQM9B yVN4MUe7+V9fx5AYjDn3yJqnd2XzQB8s/egV0jq0M/dX0eEAyeBflK04CuSSxVpuwmKR wM2kCmUpb2RFsw27KKCaSNR5F2dp94DZgYqZQ7udnA1xevvHQPRMNi91zV6JuUGYW2X0 ifuyXH5NCPx02zLUaqoI9uDDJjAaWCNnZtCiVPBC0N4lES2OVt/A7HDS5C08yAtkhqSB piJbM2vT/2otcqK7hgowqggPnBIHOPkdOk4RGW1AQ0kJg9jrIO7CHjolrCo/YU5jv2u4 aYFg== 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:dkim-signature:arc-authentication-results; bh=UbcnQ9ngTeOsn/XRP5L+38RrQ6GGaLD1Bg00W9uD32U=; b=mRl0J6Qak3Lk4d/VKNpZiCEc8vcGba28cvZi2pIMrD2QgWmi8i7zmXDJ/71pt2uOjD CrilbdotlqPA8lsVOmeR3XWUMBIZCg3qWrEeru4HHvDpEbFGt6KcZDwGWTRBz6+B6VAA q5+UKBbAGMJldM/eQzcuftfSaAxjRcRMIPNr4wimc/nqYEPa5v0om//xUhnXX1Zhnh19 ShuNm4A6EAAqVlWYyGCkP2Kh1di+AZEzvaoWMIGlA9RQ2vsfz25kXwLprYtjdYgXdPGb EZV6afHYuE1s8P7d62iwGj38AI8SEgnjubM9UI87NWNvCGSVM2djChifE3HVQ0RfVBZj Xoag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@osandov-com.20150623.gappssmtp.com header.s=20150623 header.b=pDIhWlVX; 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 w27-v6si15750126pgc.232.2018.07.25.16.35.52; Wed, 25 Jul 2018 16:36:08 -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; dkim=pass header.i=@osandov-com.20150623.gappssmtp.com header.s=20150623 header.b=pDIhWlVX; 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 S1731788AbeGZAsN (ORCPT + 99 others); Wed, 25 Jul 2018 20:48:13 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:42570 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731325AbeGZAsN (ORCPT ); Wed, 25 Jul 2018 20:48:13 -0400 Received: by mail-pg1-f196.google.com with SMTP id y4-v6so6276759pgp.9 for ; Wed, 25 Jul 2018 16:34:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=UbcnQ9ngTeOsn/XRP5L+38RrQ6GGaLD1Bg00W9uD32U=; b=pDIhWlVX0tipzauoLAUbBZJNYMFhab8OWfAlmUDWwkAg49tvJh3XC00goQlbSl1HxC A9CqEkrGm+RIrb0J13YB+AgwiWdPaSraADNwcC/c3bVF7jvSbvp7fql4RKsDK/FOjgpi DrSOCBHxFwSs3N4HzG+hiNTODZwZm0aB3YWhI8mdsMNJ/fRQab3AdUHTWHB21S6XKC3/ 68v57ZDnVto9QGeKIEaQkDkk9nS5It6ltKYy4G/NkoyPpbPVwuY9j1XFb10zGVgxK7C+ wYoRDY1fhGjCAahpWTax+09Wk2VK+B1wvxBWboPazi/OanFGKHTd1hpqkUtSr2lbA/zy T9DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=UbcnQ9ngTeOsn/XRP5L+38RrQ6GGaLD1Bg00W9uD32U=; b=WRezFH5OwE61Z8Eay2Y2cos63BZSZiKfdzaBJeipX7HLbgx18aYHbEFVZinbzoMsZ7 QSGC9e5aA80weJ8iK9Wh7W6517JFwVuPFpsnd2ggLyatFnSHfs81XS+qbE4PHBgeekXl X9qVn4DiWur8o8iEtjbKHHVxaHy/p88GxVUPo4H+FEGQ/+g+/5SYkqcHLtGxbUkrannx AK+436Wo+LpmoZAKp3xejiPzxbu3oa7LFdnVVh1TsiGxgBVsr+9WHp4qNA30UE/dOjkz okLMri/3uqMSjtOtGXzTKV4fBilwiRKO3MIT33LxG1WNaWYKHezIG1HOefCLDlu6JtPq 9hVw== X-Gm-Message-State: AOUpUlHjv2C4Jlah/sX/Qt7CT9HnYlpDcEGex/p4vxqnp/Vwbo5fFjX2 bl4NKndYoMAbFIg98PA+NT3WVQ== X-Received: by 2002:a63:743:: with SMTP id 64-v6mr22972379pgh.216.1532561653496; Wed, 25 Jul 2018 16:34:13 -0700 (PDT) Received: from vader ([2620:10d:c090:180::1:8d38]) by smtp.gmail.com with ESMTPSA id v6-v6sm27124640pfa.28.2018.07.25.16.34.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Jul 2018 16:34:12 -0700 (PDT) Date: Wed, 25 Jul 2018 16:34:11 -0700 From: Omar Sandoval To: Tetsuo Handa Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Andrew Morton , Alexey Dobriyan , Eric Biederman , James Morse , Bhupesh Sharma , kernel-team@fb.com Subject: Re: [PATCH v3 5/8] proc/kcore: hold lock during read Message-ID: <20180725233411.GF16847@vader> References: <7f905293-5c30-f001-987f-03caf8f36737@I-love.SAKURA.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7f905293-5c30-f001-987f-03caf8f36737@I-love.SAKURA.ne.jp> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 25, 2018 at 12:11:26AM +0900, Tetsuo Handa wrote: > On 2018/07/19 7:58, Omar Sandoval wrote: > > From: Omar Sandoval > > > > Now that we're using an rwsem, we can hold it during the entirety of > > read_kcore() and have a common return path. This is preparation for the > > next change. > > > > Signed-off-by: Omar Sandoval > > --- > > fs/proc/kcore.c | 70 ++++++++++++++++++++++++++++--------------------- > > 1 file changed, 40 insertions(+), 30 deletions(-) > > > > diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c > > index 95aa988c5b5d..e317ac890871 100644 > > --- a/fs/proc/kcore.c > > +++ b/fs/proc/kcore.c > > @@ -440,19 +440,18 @@ static ssize_t > > read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos) > > { > > char *buf = file->private_data; > > - ssize_t acc = 0; > > size_t size, tsz; > > size_t elf_buflen; > > int nphdr; > > unsigned long start; > > + size_t orig_buflen = buflen; > > + int ret = 0; > > > > down_read(&kclist_lock); > > (...snipped...) > > > +out: > > + up_write(&kclist_lock); > > Oops. This needs to be up_read(). Yeah, thanks, I'll fix this and rerun my tests with lockdep.