From patchwork Mon Oct 25 08:33:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 12581035 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 1DFD8C433F5 for ; Mon, 25 Oct 2021 08:33:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C355F604AC for ; Mon, 25 Oct 2021 08:33:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C355F604AC 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 613AC940008; Mon, 25 Oct 2021 04:33:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5ECF2940007; Mon, 25 Oct 2021 04:33:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 43E11940008; Mon, 25 Oct 2021 04:33:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0102.hostedemail.com [216.40.44.102]) by kanga.kvack.org (Postfix) with ESMTP id 2A877940007 for ; Mon, 25 Oct 2021 04:33:53 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id DFB1D8249980 for ; Mon, 25 Oct 2021 08:33:52 +0000 (UTC) X-FDA: 78734296704.13.A0EB5DA Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) by imf12.hostedemail.com (Postfix) with ESMTP id 94AEA10000A3 for ; Mon, 25 Oct 2021 08:33:52 +0000 (UTC) Received: by mail-pf1-f182.google.com with SMTP id 187so10018601pfc.10 for ; Mon, 25 Oct 2021 01:33:52 -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=UmL9mpq7ehorzv6mgqkv4FtNwEi5vXpR3ERUyc8B1Bw=; b=f163QO/wIMQJPdoOkjqjFlNKMvqBZPsmaXtbryyYsIponOQR+Wm55Kffl/PqBvwbrX 2/bBGcHDjPpzSIG3jHCU6R3yJhNS+wQbdOfhoARB4yOocKMk8a+JNUVgk+/tBmA4q/Dk l2yEM/9ONmEYqiekXtJh3uOggqoVLCw/FP+bgYRLjIi0LhlqKy097NOWqtKsk6NXpKS3 DpSR3iN0FMse4S3PFGXm4G87lI8Mmg9ix/Wnyy1UPCWTHShXVchuDPcZwYV22SwmY06V niK8f1/1wZOqhierpRxnaj0S4IqCJQpLRQvmAo27zHXjVn6dlNf1WWEL8El50f1yFTzK O1jQ== 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=UmL9mpq7ehorzv6mgqkv4FtNwEi5vXpR3ERUyc8B1Bw=; b=I25qdRhyi2UeN9UbECubDa/9FgIlwTglap9cDFDWaZMRU7ebsjPXDFXFy2QUxXV5Cq 7BJlOvprP/X1SjOKnbG/A6lh6mR8k8RhwUWuAFmANVaQcDAzTO4/FaTUmeW88T3ylJ+k cUhksp4QgmfdpBlyJBAeFHg7tG2FNoWggklFsLiHRzdnFqiPNYf6hkg84bpAIK6JuT/y nYK7KC9ffAE5cTrDCCuzI4IhaLliSa0mzOMz/ecK7I3RknUuD6Vu/ynKHW1FXg0SKbqa BbRD2mjyZ3kzI7IxMOvbLkKM18L2LVU1bSe546ElTdXSVC6AN8P3CK1t0jW02QdJxWyr V17w== X-Gm-Message-State: AOAM530MU8/VlelG3W8IYg1F0UPzJy1DjVEDZlTT8SFYZqSmIzV5RK+F azcohwHMMklzzWUycVJzQLs= X-Google-Smtp-Source: ABdhPJwx82IKjZxf23iOo5e3UwoMZbq9DUsUmXnmSmClvglJWBA7mwqyIOKzLfgPYkxV6YLTaw9Few== X-Received: by 2002:a63:3c5d:: with SMTP id i29mr9097063pgn.59.1635150831602; Mon, 25 Oct 2021 01:33:51 -0700 (PDT) Received: from localhost.localdomain ([140.82.17.67]) by smtp.gmail.com with ESMTPSA id p13sm2495694pfo.102.2021.10.25.01.33.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Oct 2021 01:33:51 -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 , Andrii Nakryiko Subject: [PATCH v6 04/12] drivers/infiniband: make setup_ctxt always get a nul terminated task comm Date: Mon, 25 Oct 2021 08:33:07 +0000 Message-Id: <20211025083315.4752-5-laoar.shao@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211025083315.4752-1-laoar.shao@gmail.com> References: <20211025083315.4752-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 94AEA10000A3 X-Stat-Signature: aed6xt7etr4esg44j97j8rcn7hffrptp Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="f163QO/w"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf12.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.210.182 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com X-HE-Tag: 1635150832-554263 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 strscpy_pad() instead of 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 Cc: Mathieu Desnoyers Cc: Arnaldo Carvalho de Melo Cc: Andrii Nakryiko Cc: Peter Zijlstra Cc: Steven Rostedt Cc: Al Viro Cc: Kees Cook Cc: Petr Mladek Acked-by: Dennis Dalessandro --- 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..7ab2b448c183 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)); + strscpy_pad(rcd->comm, current->comm, sizeof(rcd->comm)); ctxt_fp(fp) = rcd; qib_stats.sps_ctxts++; dd->freectxts--;