Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4311462pxb; Mon, 25 Oct 2021 01:35:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+zg11aaXuvjFRBFTGKF3/jin5CFQbvd6MJsmUkdttPY0xJ7TWfCdpJ0CTUq22ILgIf4FL X-Received: by 2002:a63:894a:: with SMTP id v71mr9703077pgd.451.1635150927587; Mon, 25 Oct 2021 01:35:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635150927; cv=none; d=google.com; s=arc-20160816; b=c5DmMQhX7DR5MZdFtUvn8FOYjGORGDRLsFOMEc2+t7/AFJTHWI9md0ilO7s4GuQMMd 4+DmfHJUxExi/Mj/38FhsuJUvAFC9PazqKzew5tAw69YhYOtKf08aecYjShsUTnje38u 2aEob1t+kncrSFCMKoYOB3LpI3+toW+Zk90YEPlrZ2PBSZup79U79Qm343UZQjkneHYn +rhArpluo9Me4xmomR9By2E8g9x6cAUw283KCaE5duMrnW70uVX2e42hz65OnkShhSkH eu5t82lgx8J4Gcc+oDiyGKDtL0xFOOvzth1kYFOos0MHTNDPWnIGKCJ4wrg3Jr7CDZRe D+fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UmL9mpq7ehorzv6mgqkv4FtNwEi5vXpR3ERUyc8B1Bw=; b=lcckuIkxX6cPG47Td09oDuWLYjYo3comuppHpWjIdwEuif7RFMMxA47GbmOsu1DYed B38EVJdnGf10dLpvBz3zq11dgkBWFsgHcG5f/JU9LzWK6LCZV6ZkZh+qUkSIp9JyyEPb /jljJF4VAZMZox75NiaRVWOQnaB0kimsev+mahJU2lUVU62ZAohhQCWE2FqEo3ZMbAKG Gdt2B/M3zsg/WS1dUKyPLtXOYsCpzpk9LR4kQ4DDmODwTbf7jsreYriuDNpfXzDEUkHb 0yfMXdtyMQ7MB+5M4rWSIW5pqO9QmaB+s/EFJsX/YfCqac7j9S2UZhr++iZd1rWpEzcv FdsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="f163QO/w"; 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 z2si24921422plg.183.2021.10.25.01.35.13; Mon, 25 Oct 2021 01:35:27 -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=20210112 header.b="f163QO/w"; 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 S232474AbhJYIg2 (ORCPT + 99 others); Mon, 25 Oct 2021 04:36:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232201AbhJYIgO (ORCPT ); Mon, 25 Oct 2021 04:36:14 -0400 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98C46C061243; Mon, 25 Oct 2021 01:33:52 -0700 (PDT) Received: by mail-pg1-x529.google.com with SMTP id g184so10206201pgc.6; 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=QH8bpyiTfJQeJIoEZJtyIOb3AZuufBPSn40DcZ3Cp4tti39Xr5X1BctRZGk4AqGU84 zC1giYJmM6cFC9OiKThr8yxrFfevr8e29gfVXlDhaMNjVBzVo8s9Bg4YkfPfq+L1eJ9u suuWwkBHyTSwHYAG/F0GKhxmTvmQe5IvHHf5OaRzhvPBTO5TRtruaT2CmmM3wC3CM/RJ +e0W5HZT5SoZYDC0+H0qkyb03nc0TVJ1AvNQzKF4Vyt55g1Eu3C3xNSYPJ9f4lbtDODl jH6v5jate7e4h0+SvPSy+IhXHZYuPGgV9PN9zrDXfC7FF03PXeXE2viiA6C4hh+Db369 SDVw== X-Gm-Message-State: AOAM530zJCpAJWg5/ZnWTLxu35wyJdrq1hrpJtiB/LBSVgqL0XkDmwZK MrnF4wcWq7pPeQNp97Xc+KM= 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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--; -- 2.17.1