Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp7466219imm; Tue, 28 Aug 2018 12:33:23 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZ11IcjzgWPGt4CzuXEtDFuXhoj8eBjCuVeAymFNdH63W555cVT64xtDb6dJthAJchlURjX X-Received: by 2002:aa7:82c3:: with SMTP id f3-v6mr2942439pfn.136.1535484803711; Tue, 28 Aug 2018 12:33:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535484803; cv=none; d=google.com; s=arc-20160816; b=zlo7VaYzNIjcged8bwBqb/h1lKaxWeVVcF/fsC3bRlMPg/XAzuNsG7NsiN+ekVK4y2 Dii6Z2l89NqSZmbr/ZzirxKhZxBGlCGibAE+bo8ChKlHZzylsaFYFMgzG8PPQt42f/9S 2Nm2pyyLBUzY1Ofh3qvM75SnjIXdaKsE4wnm3zFUxshezbpoMgCiFaW5d1hBjsb8de+Y 9m2MylzBlHshCbo0ua7u7qn138r4dkO4mTOxMpDuqPAPhbwPUvlPipABfwFgtyCeyWpP TboOC26EG8vz5W08OzBdGqHh6gY3z6pAHRQjcr3i1dNENLJR+R6V59TgUChrIZg2tpOv wLkw== 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=2QaO0uIgbLsrFdfJ2kZm/STVp1yxqwRwLt4j60URw+8=; b=R62vzDVO4LHA94/W6PeTnFfe5t3b9tVm7LciRgefePeOURVzvSoYeEa3+oslhqakl6 /mZDLlqia+AOHNVnyPuTbBDOGZHb82X/8Ce5UZQpOdtu7GJP0+WhMkUc/Nlo+LyJxUfX nqvhm8mJXCimoRHnXfv4Jm2KzRR/llXuPXN7DBH2+oero020denO/dHsQJ+fvR+X4RR/ dacmKJHl17nGjRVOI087dkt3yeWvNK2EJi+EjKQu8ZLz2DlStBtLl9DiHTalz8YGTF5z 5KXoJ8sryZwanuCfo694CbF+EGDVn9RqllHaXeuyv2/+DMsoCF8qpP+wLFMVnBDs1dlZ xMMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AqycH65M; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 186-v6si1670399pff.270.2018.08.28.12.33.07; Tue, 28 Aug 2018 12:33:23 -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=@gmail.com header.s=20161025 header.b=AqycH65M; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727162AbeH1XZE (ORCPT + 99 others); Tue, 28 Aug 2018 19:25:04 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:41001 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726807AbeH1XZE (ORCPT ); Tue, 28 Aug 2018 19:25:04 -0400 Received: by mail-ed1-f66.google.com with SMTP id f38-v6so2205479edd.8 for ; Tue, 28 Aug 2018 12:31:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=2QaO0uIgbLsrFdfJ2kZm/STVp1yxqwRwLt4j60URw+8=; b=AqycH65MohoeO3aU6lLx15ixIkNpEp1PJvSWX3wiUq3BSnzuJVx0/VuP0qkmEUAP0E qJXhvAdt4dZYAXSvAKc4GV0VkZ62khpQi9Kwr3+oMpg0GorTxzRNA7aD61NZgWYflmaH HhJ5RS0fWLbLB+RS2UUnbs4iDAUfYSAClvFeKSkkwdaVXXEhLZRwjWbx4Ovl7QQ9Mwpy jr+zQm62zP+1mR+Vb1/etkU2zP01fGHLr88FtBJUszkx0dAGuGO+vo6dShqvPlcfUkBH zjMZLDDqc+8Us4izAI+ROHAj5nrQU+wiDWL3g6qd9ae93FIFww+nBQ9gUAKx1MJm35Ne jqLg== 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=2QaO0uIgbLsrFdfJ2kZm/STVp1yxqwRwLt4j60URw+8=; b=SEGkBRmwlBaaMjnixZEDWd7PjstIMW4GlbCnV8Csj7dM2e32gkkKDpMhBaPHUXniG6 Hqu8XvJJExCxhFnDYfjuGzzD+jyuG5uw/ek3M3UmMp2+PoyEBxzS+qVfebhoIRlIRulK WaKBPVsTIFdV3XNvXCzHm/ISR4vtN4ncSMUTdqXBoqBoUMPay4FcEZ2B552H6fduJdFV 8lctfbjbAUmwfOFarxMP1M7Ik62Vet8E0i8DCAJbX3fq6u+qCRW8XS0GNxb2LDMr0t+q Kpjgc/nJxYgiuNbQzPDvFvXsZKbL9NfzK6b/XzPneHDceJFsqUTpX29fSq1LUWI4CHUR sNAQ== X-Gm-Message-State: APzg51A1Ee37AtSs0T+atKSQbQfaz3ze4WslaHYi/OH5fRM76UHSOA1s N0rH+YrLESdkcX3Rd6SVKA== X-Received: by 2002:a50:e40d:: with SMTP id d13-v6mr4065459edm.263.1535484717658; Tue, 28 Aug 2018 12:31:57 -0700 (PDT) Received: from avx2 (nat4-minsk-pool-46-53-177-92.telecom.by. [46.53.177.92]) by smtp.gmail.com with ESMTPSA id p28-v6sm2156936eda.85.2018.08.28.12.31.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Aug 2018 12:31:56 -0700 (PDT) Date: Tue, 28 Aug 2018 22:31:54 +0300 From: Alexey Dobriyan To: "Ahmed S. Darwish" Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 11/13] proc: readdir /proc/*/task Message-ID: <20180828193154.GA4847@avx2> References: <20180827231503.26899-1-adobriyan@gmail.com> <20180827231503.26899-11-adobriyan@gmail.com> <20180828123622.GA2087@darwi-kernel> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180828123622.GA2087@darwi-kernel> 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 Tue, Aug 28, 2018 at 12:36:22PM +0000, Ahmed S. Darwish wrote: > On Tue, Aug 28, 2018 at 02:15:01AM +0300, Alexey Dobriyan wrote: > > --- > > fs/proc/base.c | 8 ++++---- > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > Missing description and S-o-b. Further comments below.. > > > diff --git a/fs/proc/base.c b/fs/proc/base.c > > index 33f444721965..668e465c86b3 100644 > > --- a/fs/proc/base.c > > +++ b/fs/proc/base.c > > @@ -3549,11 +3549,11 @@ static int proc_task_readdir(struct file *file, struct dir_context *ctx) > > for (task = first_tid(proc_pid(inode), tid, ctx->pos - 2, ns); > > task; > > task = next_tid(task), ctx->pos++) { > > - char name[10 + 1]; > > - unsigned int len; > > + char name[10], *p = name + sizeof(name); > > + > > Multiple issues: > > - len should be 11, as was in the original code > (0xffffffff = 4294967295, 10 letters) len should be 10. > - while we're at it, let's use a constant for the '11' instead of > mysterious magic numbers > > - 'p' is clearly overflowing the stack here > > > tid = task_pid_nr_ns(task, ns); > > - len = snprintf(name, sizeof(name), "%u", tid); > > - if (!proc_fill_cache(file, ctx, name, len, > > + p = _print_integer_u32(p, tid); > > + if (!proc_fill_cache(file, ctx, p, name + sizeof(name) - p, > > You're replacing snprintf() code __that did proper len checking__ > with code that does not. That's not good. Yes, the whole point of the patch is to skip length checking. > I can't see how the fourth proc_fill_cache() parameter, ``name + > sizeof(name)'' safely ever replace the original 'len' parameter. > It's a pointer value .. (!) > > Overall this looks like a broken patch submitted by mistake.