Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp1391947rdb; Fri, 9 Feb 2024 23:24:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IEiLD0dzpqmadqrc74wUlJjc1D/9wrHTrdqf2t2o6hd9rsl5apc4zQJmFiyNQLRIEmWTgF5 X-Received: by 2002:a05:6870:9d9c:b0:219:48a8:fc16 with SMTP id pv28-20020a0568709d9c00b0021948a8fc16mr1716589oab.46.1707549895176; Fri, 09 Feb 2024 23:24:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707549895; cv=pass; d=google.com; s=arc-20160816; b=Ak0vBEGkFdtjO2WIgc2aIFllnW5TIvI/QRjy2QW9XAe/J8zks6S4CI2NV8mjbJBbJW MbyMQcKt7ZEQY2NMJpvd100wS/8zrY4mL+FCdemNoKll7utV1JsNGbKpRlG4gJMqEKVn M3zZWwlMmNZeQ0B+irlylvoZ+Gqa4vPkDgj4DGWwFUMdY5UIykuO0sogYH2wGCW+hwSj BxwHya7TczC3z5ZC2ui0A3htdlp/Ju9suUNNd0NbeLUp4vDZSU4Fv6dN7Lxn7veLV45O SPdncZc0VPo9DRHDnxjHg3yw34TpYv9K7m4KMrTTLyiMrxaZHPxnJ3PyoJ3sdWD8hMuX zf0Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ItG/RHS5QiD2KktNBEoaf7WVQ+4rUlZA95b1HY5B7yQ=; fh=e8B+NZEfOK9RiCrqn1Cm4U26Es4AQPvkTdA/jfoUeQk=; b=Q8Pb8xeRGnYfEMW6l79ZSjcxjtSlvPqhcDaNr4Q1nzaoYaP5XaVT0HREd8B/K0NcJq /f46y7Ud69PKbJr3xvi4tYUP08A3fWI11w40AoJcTaHKkLGPg1h5hxrcPorYs/uBJ2wx Lo1RwQ0UTPqBaljmGBgu1bB2Iw5tUAE26T9bGMUkH00mzE5xHekMA8F0L84pe3H+Erts gS5TVaZqhXlOoK8GuALwXlgPrs/OpkuExTmnPUxbHHCpf08I6BOv/Br2F6HMiOM0E5fE G6el+9edZsyh8p93hAcMoMcawnQ5GWnKMnChqNaq49HbhHaznERPAza7NNUIExF2T/XT mMEQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ZdzPUxla; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60330-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60330-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCUYzuYDD5Cks4mxwIuqd/VdIbDuUMJFAyu2x4HC9zvXqk7UQpfQO+5V2M8Agr6J1q5mj5dWh6UjUSm6D73yAuwVpfds+/zNDhBJvEIpDA== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id s20-20020a63af54000000b005d8e3490d49si3067217pgo.407.2024.02.09.23.24.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 23:24:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60330-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ZdzPUxla; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60330-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60330-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 81B7A288DE8 for ; Sat, 10 Feb 2024 07:18:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 95DD4364C4; Sat, 10 Feb 2024 07:13:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="ZdzPUxla" Received: from mail-oa1-f51.google.com (mail-oa1-f51.google.com [209.85.160.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A4F3364A1 for ; Sat, 10 Feb 2024 07:13:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707549212; cv=none; b=L+hVzykdXmsDXG+oV1zojG5FkEkPImbgW2VPOsBS93S0n4l/K1N1upqmtgdDVpT2XYc4SeVzRL/P1FQe4SWBBLt7lowPKVIUL0wjH5AxqYsdsA0Syjev5jX7nO19k0YpdiJD17yUXwtYxBcalgerD2EjLQOpHwhWeTiNsztOK44= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707549212; c=relaxed/simple; bh=eLNqhG6BuOwuEDtpbLnGq2B+ck6kSMVlJ6ab7q6aBbg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fSM5XShT3LjivW8ZbL0u2U6dnuaH0RnAPSZ5hgE9o17UEND/E4wPJ6AchTynDRWP/puV+4KCbmJ4nsZzzJyiAhBgLzX5VFvkj8AfYFe/T2FFm7IKpFNhhyMTG4RBpCKB0ayGgOYSavlnJZET4lDRHr2J1l+PzaMLiNSmOEQ/bTk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=ZdzPUxla; arc=none smtp.client-ip=209.85.160.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-oa1-f51.google.com with SMTP id 586e51a60fabf-21920c78c9fso881942fac.1 for ; Fri, 09 Feb 2024 23:13:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707549209; x=1708154009; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ItG/RHS5QiD2KktNBEoaf7WVQ+4rUlZA95b1HY5B7yQ=; b=ZdzPUxlaFF0gJTPgCWJ7o4KR72en/vdlxxnjlbAW7KVi5uedg4dWnB/jbJ8fUGd/r8 eblmpf+iTfZb3rdx9ABhQq4jrY5V6555iYIGgHIUYD+dqRj/726h67+nbEP7aZipvm9o tgYUvblUrIsr/Gc/U5XUQHF8OV4FxZsfUmOGE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707549209; x=1708154009; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ItG/RHS5QiD2KktNBEoaf7WVQ+4rUlZA95b1HY5B7yQ=; b=nLczGdPgHN0f7Sxm7iP/Rrm8+nl07zb2W43gDjAh4UqPflbKdL6Syonz1iRunnWwEf wxScCyL9LqzkhWaLna3rprCNj1X/OuN6ggN+K4Mj9EC9SXO+thJM+dGxSgSSn4y7oTBO D6F6cNg5Gv+S7RBtKgLYwm1KQ3A5qEztk+HLJzGBo5VTFQP9Ht2L0sTT7FTeDLdpNY+Z vdRYBd7xhL/vB5DM2wC7nwjOhAaDsHhpdTJ4zWtkPtWeS00gITkZ6kTS35T+jF+avd77 7cYOpsBPQv4/Ik2wXx+eCVijsshpU8JF1k/b2YxssRC81Qj9SsoionOca3HWtp+x+Boc 0hbQ== X-Gm-Message-State: AOJu0YxR6qEfUEziOso+m4hMCicTWfNh3r+BOlNIIgJyCyBYYt5+BPBb cNQWUZFerAw5KwzgFiLLX3cya18anGE1wqwBwg7wp9egXWJ+bai7Tv9OFW1LTw== X-Received: by 2002:a05:6870:e89:b0:21a:2e98:75ec with SMTP id mm9-20020a0568700e8900b0021a2e9875ecmr1764810oab.48.1707549209593; Fri, 09 Feb 2024 23:13:29 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUfN/Cc5eb2GjsAXYbFZgDAw708o5YX2rlVLoKGUMfFqNNZA4uVKyw/8T6c8ZEHIJcuFLf5e93d/0zw0MoZSsyfO3o1SWHB6PNxMOk+thlGY1FIDz6LG2vxBDpx9TA8tALOPNXFbImXOALV05n1NmHiuN3atGtz2l740zsMhdSiE0Msafll2ubX2g/5FTYTt+SsosmJJN8fkKCb4vGM+bCgKixG41T+kBVJ0ZWLh8bUbcw= Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id cl3-20020a056a02098300b005dbcff5d38esm2528518pgb.68.2024.02.09.23.13.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 23:13:28 -0800 (PST) Date: Fri, 9 Feb 2024 23:13:28 -0800 From: Kees Cook To: Lee Jones Cc: linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, "James E.J. Bottomley" , "Martin K. Petersen" , support@areca.com.tw, linux-scsi@vger.kernel.org Subject: Re: [PATCH 10/10] scsi: arcmsr: Remove snprintf() from sysfs call-backs and replace with sysfs_emit() Message-ID: <202402092313.DF1409889@keescook> References: <20240208084512.3803250-1-lee@kernel.org> <20240208084512.3803250-11-lee@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240208084512.3803250-11-lee@kernel.org> On Thu, Feb 08, 2024 at 08:44:22AM +0000, Lee Jones wrote: > Since snprintf() has the documented, but still rather strange trait of > returning the length of the data that *would have been* written to the > array if space were available, rather than the arguably more useful > length of data *actually* written, it is usually considered wise to use > something else instead in order to avoid confusion. > > In the case of sysfs call-backs, new wrappers exist that do just that. > > Link: https://lwn.net/Articles/69419/ > Link: https://github.com/KSPP/linux/issues/105 > Signed-off-by: Lee Jones Reviewed-by: Kees Cook -- Kees Cook