Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1646755pxb; Mon, 22 Feb 2021 07:25:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJwjlZD6t1oa2k62Pdaq1qWoozXGuvAilFQziU8Xu52d/h0HzE2qy9bCq4RkGwsQLd+y8dG8 X-Received: by 2002:a05:6402:1aca:: with SMTP id ba10mr17035650edb.6.1614007502708; Mon, 22 Feb 2021 07:25:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614007502; cv=none; d=google.com; s=arc-20160816; b=x0qvH/w7X4hXL48Uq9usic8FnWlsOwfkoK6hQ/9qbyrDWBH1gwmjaZNpL7NeQf5FKV yWyHAcErmU/rbE660p8rt06sxwPB3SDlFkmvgjmZkyEeoiSofBzIFXEi6Cadmx6vtHcT cUr/3cmuXRm5Pz78z41WLE6zuuDe+yvYVmrMgzQQZtefkyhhGUCQj0dmzkpq5B9mZLcx AQaVzTjVzivy1PtkWVjGy2Gv5rHHyT7G45L2h6yzBfWyFmCcZkeOlWvRva16LtnGpz13 Oob6qE/6Syqxiz0Vp6v/qJv35SatzOX/qvO3BaKPtDrK2VL02xnkK44z96WqyMJem03F rcKQ== 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=WYznJRJi7sEltEuFcbESAgA/1ekiiKcyEWk34Vl4+aw=; b=PhezlyzIR6nHK4qEtcP1ktmf1PvVRkavjVGP65iTSk6YCxlx8p8NIAMS3VO4Ooa0SF KjdrQpWasngqe5E4l7BekCQi/8NttD/PINPOGXSDvVP8h2dJHZcnQk0HgQfwphKJIEpB sU8DVhlP+EI2VANuUvPBb7s1ehxdghTudycGCH+zLw/gU4IFcRO0MakuYsA+KAxqP+Yi YF9cpOLqYuRjCrY4j2h8ewn5PUyzTBadurnPORZ/8Gka1TWqoLdl//szRgwnWjhBDDt5 ++OqgCLs8EycowoGLE0e/qG2EbISk5wRpUbdRKs4WFa+zPqgDN5Zm5gSSdBORQxvn10a DF9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="CcgFY/Ti"; 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 dp16si12851703ejc.520.2021.02.22.07.24.39; Mon, 22 Feb 2021 07:25:02 -0800 (PST) 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=20161025 header.b="CcgFY/Ti"; 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 S231675AbhBVPW5 (ORCPT + 99 others); Mon, 22 Feb 2021 10:22:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231365AbhBVPPM (ORCPT ); Mon, 22 Feb 2021 10:15:12 -0500 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9217C061A2A for ; Mon, 22 Feb 2021 07:13:01 -0800 (PST) Received: by mail-wr1-x430.google.com with SMTP id b3so19449328wrj.5 for ; Mon, 22 Feb 2021 07:13:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WYznJRJi7sEltEuFcbESAgA/1ekiiKcyEWk34Vl4+aw=; b=CcgFY/TizwV98v0EjQpqqprS4kVWLxLIO+yAEtYX9MJDmQjMwKOK0zhLFhUAmTTUvo UYCCmjDnP3NHnqKIuslmK1ckzcpTkXYuvs0ZfCVMNzBvYmY5JxTzUGmctvKraW5OW/3m d3UAE7bzLdvPxuy+csHIHgHU41Y17L8S4vqx0F0JnvKxr1BGWcR0gdJnGyVtMHkBv2OD G+ZRlYUbp7mUHzS2OGp06688Aziy6jCbmBcL2ghihroHV2JxcYem1sy18GTKwUfACGzy RNfbhejFrJtQ2h2UcWWTlvOP9zx7vP2kTgELNmMdR7OqC90iRXVahtQQtVVU1CPFV8sf TYdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WYznJRJi7sEltEuFcbESAgA/1ekiiKcyEWk34Vl4+aw=; b=N8VUF0YtMaG+XpyniVY47ziwAs4xRtoC7MM94MHQQbgbBDTqbQzxuEYX3ATAAZ/Rag y6OZV0Zp+gJHExkavvuQlxJQE4XFTT6MmWEarBu2NfiliSKbiCQm3kmAWJkdrSbaHr7q smiprOc/RxNS1Zzq7K0LhPFDduz3Gvu3PjavD2w7934h6BT9Lw7hr7FjmlAGu23ZvEMP jJAhBCadqLY/Z27mCbl7y+E0h3WJ2BBNgHwgahgurulTwejTmyq3MN0zWF1Dm1HUgHLH evYlDHDoWhg06rI7+naC7LeVNz0BtmZpORq0m3+wmoZIPUgS6tIZRL3nEEfNPbkUBDIw Q6sw== X-Gm-Message-State: AOAM531pwbSannS+69UES4KrWA+PTFWNyBE5Aek/UcINdEDLhs89z+hI DUIddm1OojSd5+emiq3Cnj0Ld/8+tWlZvz1xy8c= X-Received: by 2002:a5d:54cb:: with SMTP id x11mr2479881wrv.165.1614006780305; Mon, 22 Feb 2021 07:13:00 -0800 (PST) Received: from debby (176-141-241-253.abo.bbox.fr. [176.141.241.253]) by smtp.gmail.com with ESMTPSA id q20sm25316500wmc.14.2021.02.22.07.12.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Feb 2021 07:12:59 -0800 (PST) From: Romain Perier To: Kees Cook , kernel-hardening@lists.openwall.com, Jaroslav Kysela , Takashi Iwai Cc: Romain Perier , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH 15/20] ALSA: usb-audio: Manual replacement of the deprecated strlcpy() with return values Date: Mon, 22 Feb 2021 16:12:26 +0100 Message-Id: <20210222151231.22572-16-romain.perier@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210222151231.22572-1-romain.perier@gmail.com> References: <20210222151231.22572-1-romain.perier@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The strlcpy() reads the entire source buffer first, it is dangerous if the source buffer lenght is unbounded or possibility non NULL-terminated. It can lead to linear read overflows, crashes, etc... As recommended in the deprecated interfaces [1], it should be replaced by strscpy. This commit replaces all calls to strlcpy that handle the return values by the corresponding strscpy calls with new handling of the return values (as it is quite different between the two functions). [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy Signed-off-by: Romain Perier --- sound/usb/card.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/usb/card.c b/sound/usb/card.c index 85ed8507e41a..acb1ea3e16a3 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c @@ -496,7 +496,7 @@ static void usb_audio_make_longname(struct usb_device *dev, struct snd_card *card = chip->card; const struct usb_audio_device_name *preset; const char *s = NULL; - int len; + ssize_t len; preset = lookup_device_name(chip->usb_id); -- 2.20.1