Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1144508rwb; Tue, 29 Nov 2022 09:29:31 -0800 (PST) X-Google-Smtp-Source: AA0mqf4aED90PTE5GrW9k5jB+xsliTPUsygmNmeg9Sh/M7UOLwF8GC3w8ntsipJFZBQqz1gNLoOI X-Received: by 2002:a17:906:2693:b0:7aa:57c3:3f26 with SMTP id t19-20020a170906269300b007aa57c33f26mr32582647ejc.195.1669742971647; Tue, 29 Nov 2022 09:29:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669742971; cv=none; d=google.com; s=arc-20160816; b=PiQfyeqO4yegvpTV7oTSi9pbgW9FiZ6i0ZILkPoDg8UNObwzPqCXhcLzS4qa0zIPwT lWuEVYclUjdzZzZsMkok5mCl4ozmk/FMrMF9XmeUVzNmTi9/PCkUaIZT7znNpp10F0bL NkRKwWoOJ01Wf/IgrpZBWDcAF7KN5Smb8OZCC5v/1ubvk2gFNpLPS0vLKxpFbipGFs52 ntP8LnupQuti+27eSexe+Qd1P7iYvZQdJiLu7Qb4vuYzoOs2TgiVOC46xHBWL9b/RGZa FM5GLwi9oWJbhq7IDjpmBCglC9Acl9ax+RqvunKc5VT20TqUE/HLHwi5HwLyLpTab5t9 MIAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=JHEjD2xxLNtQCC6FYElEPgk7av75DQm6bwKKXcbxhRE=; b=Dxa1n8yciQRgW+XwSEtLrJivyPDWZzejl2DAooGP1mycR+WNrC97mHysW1xtWa5TJH +nMOWmx+GVaSSChHOs6OOPd4WLLfMyAmPmUiWwQyU5fomD8+M2xSSwz5ok24BkT1d4tk q7ZalqE85muX9ezKiBMLCD5cp+mrBulwzaImeghz/mgIbxgLhkPYR4WPCJM2hIy/SAz6 PWxLcOBLb6nsyHVXer2ZId9o9T0vHXSeDNsbb+4/HQdO5ZzodTQx0sZ3JdiLzoUYyrK1 C2/0qpivSlE/eCRnytvFziix8i43NzUGG8q/TcFkGVv5FNES+gUmb7plTQ9LV2ddC6vV xJvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=rcG6dqqN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k8-20020a17090627c800b0078e11e9286csi10102046ejc.195.2022.11.29.09.29.09; Tue, 29 Nov 2022 09:29:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=rcG6dqqN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236494AbiK2RNG (ORCPT + 84 others); Tue, 29 Nov 2022 12:13:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236568AbiK2RMy (ORCPT ); Tue, 29 Nov 2022 12:12:54 -0500 Received: from mail-yw1-x1131.google.com (mail-yw1-x1131.google.com [IPv6:2607:f8b0:4864:20::1131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB73C3FBB8 for ; Tue, 29 Nov 2022 09:12:49 -0800 (PST) Received: by mail-yw1-x1131.google.com with SMTP id 00721157ae682-3704852322fso145471137b3.8 for ; Tue, 29 Nov 2022 09:12:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=JHEjD2xxLNtQCC6FYElEPgk7av75DQm6bwKKXcbxhRE=; b=rcG6dqqNMky7jtdTJ46UkMVCNRhCC2wS2wzYNMxEWmGIbDbfjKUTHWdytUvxxZ1hCO hii0c0lXZOyFm8dJkzKTYZkEVGzbv50tfIKwFHk1Z4+6D/+dF+zj4hRkJfq9z8cmBL21 qQbfMHJ2NlTGaB434A4h0QmMLvib0OqFYg5apgzZxYpA/sF5NBxK46w8UJ2wJy6vAGY8 3IeY9uTE0JxVikWmy/lCoTqxXfVyFtezGLVM3gKj95d4Dxt9v5+8VM8ZbuDVvgyI4R7x EFR+uEnDq8S9gWaKyUB+g/NJ/YALqL4rI5FDrlTaSuguvEvo77nrE8+8zKnFOLXVVUTD 5LIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=JHEjD2xxLNtQCC6FYElEPgk7av75DQm6bwKKXcbxhRE=; b=jk0dN6SVwdeC4tD7aGZJ3/DSMP7RyXei/VXhI8nzWkPPNjnW+tTCPtV4JhtYYh2awx V+WCSCRdwsUxq6A5FLG1L0Fa1/iqgDLe16vVUlWlYONvQK4vxvEP57BRshVKm5DU8g/T xnsZ/vI5d6O4/bAAMv9BPqts6DazDRVoNMuqFUTD619oKoLG2IxkMu1oTOXvpZp7RHGw qPv2Pbu9pkh1J9//9uT/IyWskPYXu1ASn9h41kBinfcPMUNitHiElTJnk28OCSt0NFrJ Xz3U8TGoQe45VR3aDsGRXZr8Ljm4zK4gu3Joxyn/aQ1xdXSrPopl/0c3vAQctY4e2+CB kecg== X-Gm-Message-State: ANoB5pl+vJZbuP2EV+YPsbT2b81Wp3esVGnJBZcNbqMw0aErMh2TwMp4 GJjqJrgLPTFSbK7V+M4AH/cu3rUpDWj9pYoqa7tb1w== X-Received: by 2002:a81:9a94:0:b0:3af:eac8:76e0 with SMTP id r142-20020a819a94000000b003afeac876e0mr30728331ywg.256.1669741968574; Tue, 29 Nov 2022 09:12:48 -0800 (PST) MIME-Version: 1.0 References: <202211241926133236370@zte.com.cn> In-Reply-To: <202211241926133236370@zte.com.cn> From: "T.J. Mercier" Date: Tue, 29 Nov 2022 09:12:37 -0800 Message-ID: Subject: Re: [PATCH linux-next] dma-buf: use strscpy() to instead of strlcpy() To: yang.yang29@zte.com.cn Cc: sumit.semwal@linaro.org, christian.koenig@amd.com, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org, xu.panda@zte.com.cn Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 24, 2022 at 3:26 AM wrote: > > From: Xu Panda > > The implementation of strscpy() is more robust and safer. > That's now the recommended way to copy NUL terminated strings. > > Signed-off-by: Xu Panda > Signed-off-by: Yang Yang > --- > drivers/dma-buf/dma-buf.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c > index b6c36914e7c6..485cf4f3431e 100644 > --- a/drivers/dma-buf/dma-buf.c > +++ b/drivers/dma-buf/dma-buf.c > @@ -51,7 +51,7 @@ static char *dmabuffs_dname(struct dentry *dentry, char *buffer, int buflen) > dmabuf = dentry->d_fsdata; > spin_lock(&dmabuf->name_lock); > if (dmabuf->name) > - ret = strlcpy(name, dmabuf->name, DMA_BUF_NAME_LEN); > + ret = strscpy(name, dmabuf->name, DMA_BUF_NAME_LEN); The type of ret should also be changed to ssize_t to capture the negative error value which strlcpy does not have. We shouldn't ever see that error condition here with the code the way it is now, but let's not risk it. > spin_unlock(&dmabuf->name_lock); > > return dynamic_dname(buffer, buflen, "/%s:%s", > -- > 2.15.2