Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4024542ybz; Mon, 20 Apr 2020 14:06:09 -0700 (PDT) X-Google-Smtp-Source: APiQypIZGY5cy6Oxl2TJedgpm9Rs/nuFJgkQb+9X+nMI2LfZXnMdqmI8liGU47aIrntpyVH5Ky8Y X-Received: by 2002:a17:906:d0d2:: with SMTP id bq18mr17433674ejb.62.1587416769411; Mon, 20 Apr 2020 14:06:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587416769; cv=none; d=google.com; s=arc-20160816; b=dwUQT/JIrJNd8D6+tvHTIi0FglhptQrYncH1bld7BABxna4GzShjrJcC5QddQlXwxX rgRH9NBABhkQOiWiTCmGAcCO27mbLHiWzIbOgLojzdRiid7MOl9fdhB50ADLCe96N903 65CwdMPg6ss5XUmFPoBEkZUR6tITqatOgvbOM1FZwXZSx5cPLFw6+n41ht4Gtgwffuc9 xffdea1E++SiOpd7/QliZNMbVlFu9st4vHr1ci6q3DcftHQGnkFb5Tnjkz6Unqbau+Je iPnnIwSGh+9mKS4XPEpYy98j3sZhFHH/K1tAHgSueDkIKO0q2zG9PYXpvRCs1l+5ByQn K/Rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oJ3c5qOQfz7hY1h+qnaRsaFeSzEi0ESCJo4fsW8HRog=; b=W9M5RFVNeonQX2bLF14yEeZyAZG5KMBv2eeh6P9gcT6Nn6PWkV/sPKKf/kZwJKUctn CgwfE7Ig4fAw3TRHiMjG8f8SGzfBuXBAUUzKKpmXlZhXbDkI/Y6ZCFiWIQ5qgc+oN9wK UsbfclBei2+pyYgnmygHYhwpyJJPWYmulujcG1DU6IDoys8P0ErAi8qb+hQWw3W0GeRX HiA0jLFRAepYdt7O0PjKgzLVoy44Ad8NZGm4t+/nJyOQvMvPT9zr0WDAmqKhvWnBLWOv Wb3mAkroXSXFWTzmYeD0P/g/vYyKwOgYUmBRxQ316X6FpdQTtfbENN/66YkQdRFAph4D Zq1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JeR5HjYy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id n18si213315ejj.459.2020.04.20.14.02.53; Mon, 20 Apr 2020 14:06:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JeR5HjYy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1728390AbgDTU7B (ORCPT + 99 others); Mon, 20 Apr 2020 16:59:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725774AbgDTU6O (ORCPT ); Mon, 20 Apr 2020 16:58:14 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31FFBC061A0C; Mon, 20 Apr 2020 13:58:13 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id r26so1192501wmh.0; Mon, 20 Apr 2020 13:58:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oJ3c5qOQfz7hY1h+qnaRsaFeSzEi0ESCJo4fsW8HRog=; b=JeR5HjYyEmGmALLfAktwkQ2yJCEX90zhqS4fMYiZGpDGxy7ngv/NG3+jHScg47hJym VZ4G58jg4j6tZwSI793VYxsUlppJeLYh0sfKgdQJazlzTuDnsfQRi3nfGVLafZsHFoNP UNuKn4phDCyCxtcTJipdi5vRhXmRicCs5YzsenDO+MzQCtxweVuRF9cx4vBiG+s+NZlb ArssGsBFQJT6qww5Zmp+qLX5YzmLIaNfwAhP+FWhbShDDQqhoMQgkOyY2xM8xHv/HMwM 5OwvfgY0zVFoVUUxbi/hgz91xamwsQvdu2DwmbjgkvSOibnBqAnG+1/qSxG3oW0G4JGQ C+9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oJ3c5qOQfz7hY1h+qnaRsaFeSzEi0ESCJo4fsW8HRog=; b=hGzCgmiDgejGoPsEKwpsou1wfYLkZ4VH38JXqIsM1TdTra9GiDFvMkS9HVDCHaPWav 1N6QMmpErjbbFk3FiQRV7NgjtB2yfWaNhyihUhn/2qEF+fxg9LvHICkVP5xX/6EAyXhx H60HoA/iYDYW61meKA8CQKguwbZrXz37RHM2r5CqZLg7xzJO3igWxCSiv6zp2D+Uu7p9 9pjFdEW5iqsCuSoKiEJoafwFHSao1AHbBarhpjBoqWeLkFVTa5kZsUBGKCl2bfkIRRG6 CQ8iRPIreivPPaHa/VOTlR+TJ9pK54ShG1lG7Naq5UKo30lEaqzwYRL3P/ZaX1dujBWu humg== X-Gm-Message-State: AGi0PuZoN7VgXRMkgvgSz1hdAci1brovy4ivtd+0GlyZvtraOeyxbOxk lfwRWPnYKKrOOQk0B3qfAw== X-Received: by 2002:a1c:1b58:: with SMTP id b85mr1240849wmb.112.1587416291975; Mon, 20 Apr 2020 13:58:11 -0700 (PDT) Received: from avx2.telecom.by ([46.53.249.74]) by smtp.gmail.com with ESMTPSA id m8sm863069wrx.54.2020.04.20.13.58.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2020 13:58:11 -0700 (PDT) From: Alexey Dobriyan To: akpm@linux-foundation.org Cc: adobriyan@gmail.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, pmladek@suse.com, rostedt@goodmis.org, sergey.senozhatsky@gmail.com, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk Subject: [PATCH 05/15] print_integer, proc: rewrite /proc/thread-self via print_integer() Date: Mon, 20 Apr 2020 23:57:33 +0300 Message-Id: <20200420205743.19964-5-adobriyan@gmail.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200420205743.19964-1-adobriyan@gmail.com> References: <20200420205743.19964-1-adobriyan@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Alexey Dobriyan --- fs/proc/thread_self.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/proc/thread_self.c b/fs/proc/thread_self.c index f61ae53533f5..c29d37e3bd28 100644 --- a/fs/proc/thread_self.c +++ b/fs/proc/thread_self.c @@ -15,14 +15,20 @@ static const char *proc_thread_self_get_link(struct dentry *dentry, struct pid_namespace *ns = proc_pid_ns(inode); pid_t tgid = task_tgid_nr_ns(current, ns); pid_t pid = task_pid_nr_ns(current, ns); + char buf[10 + 6 + 10 + 1]; + char *p = buf + sizeof(buf); char *name; if (!pid) return ERR_PTR(-ENOENT); - name = kmalloc(10 + 6 + 10 + 1, dentry ? GFP_KERNEL : GFP_ATOMIC); + name = kmalloc(sizeof(buf), dentry ? GFP_KERNEL : GFP_ATOMIC); if (unlikely(!name)) return dentry ? ERR_PTR(-ENOMEM) : ERR_PTR(-ECHILD); - sprintf(name, "%u/task/%u", tgid, pid); + *--p = '\0'; + p = _print_integer_u32(p, pid); + p = memcpy(p - 6, "/task/", 6); + p = _print_integer_u32(p, tgid); + memcpy(name, p, buf + sizeof(buf) - p); set_delayed_call(done, kfree_link, name); return name; } -- 2.24.1