From patchwork Mon Nov 1 06:04:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 12595845 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B220C433EF for ; Mon, 1 Nov 2021 06:04:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D0A846108D for ; Mon, 1 Nov 2021 06:04:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D0A846108D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 6BA7B80011; Mon, 1 Nov 2021 02:04:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 691FC80008; Mon, 1 Nov 2021 02:04:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 50B7A80011; Mon, 1 Nov 2021 02:04:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0047.hostedemail.com [216.40.44.47]) by kanga.kvack.org (Postfix) with ESMTP id 3CCFD80008 for ; Mon, 1 Nov 2021 02:04:41 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 2B66A182057E9 for ; Mon, 1 Nov 2021 06:04:40 +0000 (UTC) X-FDA: 78759322362.17.0624911 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by imf24.hostedemail.com (Postfix) with ESMTP id B75C1B00009F for ; Mon, 1 Nov 2021 06:04:39 +0000 (UTC) Received: by mail-pf1-f178.google.com with SMTP id y20so4630863pfi.4 for ; Sun, 31 Oct 2021 23:04:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=o3r423UmuBw5jHyHMAFihSOkgDAeE6bhihnHvX68874=; b=LMNo4W3TjV5llf6jnlGy9NTRwR+hoKt0QLv5GmrPdv3tnhWv9SWc7CJ7IPQ25LBnzk bcRtJNIrFLRYdb+nwHDIMCzxk8OcTqZj1+KQoDpEpEyi4CNOYzHG7irT+iMD/qus1bRP gJpNr3rEp+9oEiUuNaizI1x0DMWAc3vLy2WnsYbX1+wB63+hqz8QVD8LDeRx0SgfgqKw 29ejtUEHKc/vPJ8SAql+Fv/wLIFhF7PSo8w1Ydn9qX+mHD0mR9MnwZ+am4lPfe/PBi3u mJbBqphRMOFBQ/gfkyGl+Ss6tcUTIXKBTaH7ednulSWrpVWbdBFxaDEy0u77cY4ekOZz EDRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=o3r423UmuBw5jHyHMAFihSOkgDAeE6bhihnHvX68874=; b=nzYtb6MkDrkGwLajWpf17ovo7lSgKHM8h7knuoEBghZQvcD9h4z9J5/TchW9N/FFZb N5SqQX64SNURMGTy7bkTV23bLZy9mEyFGwrNKjoMfmVFaUcncmZtqlI3DSebJNo4C6cV nifs8Mttni5lXNQGheMzcg/BvTbp1+YecCwjMHgSyBMIc56agCJtcSdoImyNQj0+3ad/ BEmFti21Ba4WaKFS51KPu16AKhFA1mI6M7fVr25rDFiYH8yv5XPYiMZqFykWdTKnVrIF VajP5Ik29bUdeLtqeRGp8VtBkFmTEm8f0UmHkr+4/tTimw7nJWAcqZDbLBGg3vZLmjlj TmOA== X-Gm-Message-State: AOAM530MmfTuDK4kBeDcG9+VlUH0WJFIK/Q+UPJO5AKKjIRtIaBI4k7P BLKUP4UJ/wlOpyr3W0yXek0= X-Google-Smtp-Source: ABdhPJxaybbOZX2waEJCer7qTNlHbiwvvo3L2vD0OkVD9dD70R5sF0i0k+8R93jpwPu6/vpMsOcejw== X-Received: by 2002:a05:6a00:2311:b0:431:c19f:2a93 with SMTP id h17-20020a056a00231100b00431c19f2a93mr26982527pfh.11.1635746678877; Sun, 31 Oct 2021 23:04:38 -0700 (PDT) Received: from localhost.localdomain ([144.202.123.152]) by smtp.gmail.com with ESMTPSA id g8sm3277586pfc.65.2021.10.31.23.04.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Oct 2021 23:04:38 -0700 (PDT) From: Yafang Shao To: akpm@linux-foundation.org, keescook@chromium.org, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, arnaldo.melo@gmail.com, pmladek@suse.com, peterz@infradead.org, viro@zeniv.linux.org.uk, valentin.schneider@arm.com, qiang.zhang@windriver.com, robdclark@chromium.org, christian@brauner.io, dietmar.eggemann@arm.com, mingo@redhat.com, juri.lelli@redhat.com, vincent.guittot@linaro.org, davem@davemloft.net, kuba@kernel.org, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, kafai@fb.com, songliubraving@fb.com, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, dennis.dalessandro@cornelisnetworks.com, mike.marciniszyn@cornelisnetworks.com, dledford@redhat.com, jgg@ziepe.ca Cc: linux-rdma@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, oliver.sang@intel.com, lkp@intel.com, Yafang Shao , Alexei Starovoitov , Andrii Nakryiko Subject: [PATCH v7 04/11] drivers/infiniband: make setup_ctxt always get a nul terminated task comm Date: Mon, 1 Nov 2021 06:04:12 +0000 Message-Id: <20211101060419.4682-5-laoar.shao@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211101060419.4682-1-laoar.shao@gmail.com> References: <20211101060419.4682-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: B75C1B00009F X-Stat-Signature: yy556hwwjkuehrdqes3tczn3ng4bqxtm Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=LMNo4W3T; spf=pass (imf24.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.210.178 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1635746679-350629 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Use get_task_comm() instead of open-coded strlcpy() to make the comm always nul terminated. As the comment above the hard-coded 16, we can replace it with TASK_COMM_LEN, then it will adopt to the comm size change. Signed-off-by: Yafang Shao Acked-by: Dennis Dalessandro Cc: Mathieu Desnoyers Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: Andrii Nakryiko Cc: Peter Zijlstra Cc: Steven Rostedt Cc: Al Viro Cc: Kees Cook Cc: Petr Mladek --- drivers/infiniband/hw/qib/qib.h | 2 +- drivers/infiniband/hw/qib/qib_file_ops.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h index 9363bccfc6e7..a8e1c30c370f 100644 --- a/drivers/infiniband/hw/qib/qib.h +++ b/drivers/infiniband/hw/qib/qib.h @@ -196,7 +196,7 @@ struct qib_ctxtdata { pid_t pid; pid_t subpid[QLOGIC_IB_MAX_SUBCTXT]; /* same size as task_struct .comm[], command that opened context */ - char comm[16]; + char comm[TASK_COMM_LEN]; /* pkeys set by this use of this ctxt */ u16 pkeys[4]; /* so file ops can get at unit */ diff --git a/drivers/infiniband/hw/qib/qib_file_ops.c b/drivers/infiniband/hw/qib/qib_file_ops.c index 63854f4b6524..aa290928cf96 100644 --- a/drivers/infiniband/hw/qib/qib_file_ops.c +++ b/drivers/infiniband/hw/qib/qib_file_ops.c @@ -1321,7 +1321,7 @@ static int setup_ctxt(struct qib_pportdata *ppd, int ctxt, rcd->tid_pg_list = ptmp; rcd->pid = current->pid; init_waitqueue_head(&dd->rcd[ctxt]->wait); - strlcpy(rcd->comm, current->comm, sizeof(rcd->comm)); + get_task_comm(rcd->comm, current); ctxt_fp(fp) = rcd; qib_stats.sps_ctxts++; dd->freectxts--;