Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4730655rwd; Tue, 30 May 2023 09:06:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6M8x7fH/utegb34SkK3CSlObYKllTnaW0lc12FT//gKn84LeHoXMXbhQSbd5U8PCfLsXPr X-Received: by 2002:a17:90a:6c64:b0:247:2874:a6a6 with SMTP id x91-20020a17090a6c6400b002472874a6a6mr3029627pjj.2.1685462767357; Tue, 30 May 2023 09:06:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685462767; cv=none; d=google.com; s=arc-20160816; b=ubcdvJVqxMArTpu+QsQXMqUc5KzgqOEQP8gGA4+SE2tFMdB3XEzY91KrTinnQvHY6M 7oScu6V0krxO6VRfAlRqUE4n1i+l+xo0NONubCMUXz/2kYTVL6YrQu2QuDXrc17ePX2i nLFZehNAaZUtCTd/gqcT1pfeGf1XyqFT4N+EGMOg6PkzIlww5B3Hxm3NCleFlD8fK2sd o9au0CZXkzWGm/+IyKgbKKDhWYtOSqgXX3vz3m8j4io8Y146Fp8SUnHfkFrNCMmSY0nN Gb56Wu/3xx0NdmFCVQnOendV/YtNfB3FGxu38TiWm1tFH36PBFveoVmPYJKIDpprV6tK 4Itg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=0W1ZMJcFCP9WzzPAXOyz5x6oO4Ir7TdajV4+qJUvDFw=; b=aMIfLgMBGOcDvtqi/bq19LHFhn3in9VwZdjgGS+Xwn2FZGAC02WdBxftBEqeSSx/kS d268psLeRxe2EM136CWvktS3kvg4aqzJH8NKYANBtgQGOLyg0SRvUsm1/RU0hf/C257I VttcxldtISvWklmDQ2lD0zkkfTUWfjTz/4V4td53Vg0j9AxUUxBmRxkwH5sURzsO9GKF CyLCHRwT2ZOku915/NEU2ZUWaLPaI4I09shNVKvbD3Gdx2f0TCjXCNsTxjO83Lz2/wrh OmrziZPDlOmChMBnpi4/tp3hLYQHuxnh5Ai9hox82gvqrzu46rFnLCsx4Dl3J3JzG0kj TVow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=f0YG9MFO; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b71-20020a63344a000000b0053ef1e7ac70si468470pga.729.2023.05.30.09.05.52; Tue, 30 May 2023 09:06:07 -0700 (PDT) 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=@gmail.com header.s=20221208 header.b=f0YG9MFO; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233067AbjE3P6n (ORCPT + 99 others); Tue, 30 May 2023 11:58:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233092AbjE3P6f (ORCPT ); Tue, 30 May 2023 11:58:35 -0400 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 705F6106; Tue, 30 May 2023 08:58:22 -0700 (PDT) Received: by mail-io1-xd2a.google.com with SMTP id ca18e2360f4ac-776fdba68ecso131599439f.1; Tue, 30 May 2023 08:58:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685462301; x=1688054301; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=0W1ZMJcFCP9WzzPAXOyz5x6oO4Ir7TdajV4+qJUvDFw=; b=f0YG9MFO2a3+WhBY4erUhouLjfQGEreHM8y8IhX1YRkAz3+mxfoQTySIVyJs3ZIKjS Niz8A+WLgToUy8DUbV52Z7casCFtu37uIsBvj6+BjPpmdyNYqU1GzcDnDJJ1asnjeQ+/ dvjLuABSIjHQA+9f6gwRQnVNkM7ri5ET/GlbeSv7nvz4wJ8lToYZA82rkbC6akJ9YiLy 5u/hxX6biDAlfb6jVqrMVOKbJN7uUkW1QChsQqUv2IvcwMin9tAwC7YmAu0PURRiY7hg +M9W25LBsGgnTVA3FCeXPw157/CX/oP4ukWYnnEHiV2pNBAAH5fqcGKLh0fRLKo5Wug7 THDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685462301; x=1688054301; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0W1ZMJcFCP9WzzPAXOyz5x6oO4Ir7TdajV4+qJUvDFw=; b=gbgejqd53Rb7LF2ia9UytEmyhH2Xk4HK9aOPfKp5MFr9fHYVtdngsHCf6PvJnlcNZW vnrJ+Igu7YE952g9X7AZsXBsFYXIV1J8aSYBd+ewp6PmHsQWf3WT6Vx+Klgy3dLlOGoE t5T9N5JxYtDL+yWneEECQOjxoYxR+JRe5oH1Q2Ot0yoXVZxTlsR0Ie33xqeeQwMQTcCR xJ2cCtBNRTuyt3/Edn8AtfF18WdBXRasncSXay+g+HXejPdCAF/WLqIfmpsE7DyLFzDB Z6/xGe1XyHEVWKYvS3RCAJsN9waGGXpNxD+MRYdZAlPHZ3c14/Xk0rh7GeS494hPZT9q e6lQ== X-Gm-Message-State: AC+VfDzMQmRKux0q8hqJB+2FolnIdpVvF2lVxbXycvYiGLEIqWATfTsv RLh35BdZBkxcQCZ49+JfVqo= X-Received: by 2002:a92:d405:0:b0:338:b9a1:5d06 with SMTP id q5-20020a92d405000000b00338b9a15d06mr47798ilm.2.1685462301630; Tue, 30 May 2023 08:58:21 -0700 (PDT) Received: from azeems-kspp.c.googlers.com.com (54.70.188.35.bc.googleusercontent.com. [35.188.70.54]) by smtp.gmail.com with ESMTPSA id p31-20020a056638191f00b0041650ca49casm818570jal.83.2023.05.30.08.58.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 May 2023 08:58:21 -0700 (PDT) From: Azeem Shaikh To: Hannes Reinecke Cc: linux-hardening@vger.kernel.org, Azeem Shaikh , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, "James E.J. Bottomley" , "Martin K. Petersen" Subject: [PATCH] scsi: libfcoe: Replace all non-returning strlcpy with strscpy Date: Tue, 30 May 2023 15:58:18 +0000 Message-ID: <20230530155818.368562-1-azeemshaikh38@gmail.com> X-Mailer: git-send-email 2.41.0.rc0.172.g3f132b7071-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 strlcpy() reads the entire source buffer first. This read may exceed the destination size limit. This is both inefficient and can lead to linear read overflows if a source string is not NUL-terminated [1]. In an effort to remove strlcpy() completely [2], replace strlcpy() here with strscpy(). No return values were used, so direct replacement is safe. [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy [2] https://github.com/KSPP/linux/issues/89 Signed-off-by: Azeem Shaikh --- drivers/scsi/fcoe/fcoe_transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/fcoe/fcoe_transport.c b/drivers/scsi/fcoe/fcoe_transport.c index 46b0bf237be1..a48d24af9ac3 100644 --- a/drivers/scsi/fcoe/fcoe_transport.c +++ b/drivers/scsi/fcoe/fcoe_transport.c @@ -711,7 +711,7 @@ static struct net_device *fcoe_if_to_netdev(const char *buffer) char ifname[IFNAMSIZ + 2]; if (buffer) { - strlcpy(ifname, buffer, IFNAMSIZ); + strscpy(ifname, buffer, IFNAMSIZ); cp = ifname + strlen(ifname); while (--cp >= ifname && *cp == '\n') *cp = '\0';