Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp236560pxa; Thu, 27 Aug 2020 00:16:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbulRP1IPAUYgSXlahzemXAspgyoKPYKx1WGVoGhJ+xDLv2Ubx0I425gXr2RYvnBCwgN6J X-Received: by 2002:a17:906:554:: with SMTP id k20mr19391744eja.334.1598512587254; Thu, 27 Aug 2020 00:16:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598512587; cv=none; d=google.com; s=arc-20160816; b=GKLx+0CQ2GS2iLKgfMILU+QJ3qayp2gDYIm7FhV7rfGaqp3bunVSEhoONW7Yvz05dS vFcPojlUZ/KioqtqFc5rAMVtaCvZInFySu2M1of0woZa7StZZgFt7RxrMPvU7klJb8Qa Of9L/IFZKD0/UbsUXb7XbyCv9fpb/esEwHY3z+kC+y+NvQMMwEHZFeLMp/eBgzF9QNhc neu15DPtUHiX7DfS35vgUzUlAXTqnz46km93aL2qDuIranZp4WVEqfrZJhDCxpaE1l4X jzY7oZieViB9ZbpKi9ilxIgH1smG+wD045iVS4Qxlu/pTRbWIt+IdAsw3OoMmUT6a8zI qxqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=axA6R3WNGOyq2K3jT/w7kjt3OsDHDpwtS03gako2ZeY=; b=GoB1ejbD/D4zPxs5tdAv7stBpY21+y3ijAF4pe52zjMbBqiKUgJUjBzqbyoxa+u6PW /tqjtFIYQFCms4VuZM0ifIeFR+/+xBhCKfbVzq66jrdXsAwdqIEPjRdd5ANwFpZ0kIOp 4W1VFg1s21ryUf4PhuuyjRzFjizRN6u0CTrVJjIZiaJdgSiR+xstOD2lBaS1oCQgvRnE gndmB4rzVzz6DNe0kme472ZzViBs/T+gV42eT3xehMOMWTC1vwaP5cg/3oWz3I70KjtI LsjSMr4s44XWNwRyonkzvMQYeLEum8gB+p9BrkmexPGzzCpfgzwrxfyo1DW2Q4QpRhru r7UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yJE5N6v4; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bg14si803324ejb.368.2020.08.27.00.16.04; Thu, 27 Aug 2020 00:16: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=@kernel.org header.s=default header.b=yJE5N6v4; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728068AbgH0HPZ (ORCPT + 99 others); Thu, 27 Aug 2020 03:15:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:48680 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726123AbgH0HPY (ORCPT ); Thu, 27 Aug 2020 03:15:24 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AE34A22BEA; Thu, 27 Aug 2020 07:15:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598512524; bh=G3vscis/STSa2/sHE+rHOyY//y2R6JMcHXEvNAmvFjc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=yJE5N6v47+E0KRX01YAv96COO3XDT7VXEeKDw6FdFPRmrZlImwCdB6Gp3yYvqETQI ie8u9QidWO4l+3HhxaaMXrrfyeH//LZJ9N4FPnOZM2IYFA+4NPs1rrDaOfSopeTP6F DUlEY+96Bw+++8WPbVSYNsJFLjdbl+iP5zG+g60w= Date: Thu, 27 Aug 2020 09:15:37 +0200 From: Greg Kroah-Hartman To: Rasmus Villemoes Cc: Alex Dewar , Kees Cook , "Gustavo A. R. Silva" , accessrunner-general@lists.sourceforge.net, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] usb: atm: don't use snprintf() for sysfs attrs Message-ID: <20200827071537.GA168593@kroah.com> References: <20200824222322.22962-1-alex.dewar90@gmail.com> <48f2dc90-7852-eaf1-55d7-2c85cf954688@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <48f2dc90-7852-eaf1-55d7-2c85cf954688@rasmusvillemoes.dk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 27, 2020 at 08:42:06AM +0200, Rasmus Villemoes wrote: > On 25/08/2020 00.23, Alex Dewar wrote: > > kernel/cpu.c: don't use snprintf() for sysfs attrs > > > > As per the documentation (Documentation/filesystems/sysfs.rst), > > snprintf() should not be used for formatting values returned by sysfs. > > > > Sure. But then the security guys come along and send a patch saying > "sprintf is evil, always pass a buffer bound". Perhaps with a side of > "this code could get copy-pasted, better not promote the use of sprintf > more than strictly necessary". > > Can we have a sysfs_sprintf() (could just be a macro that does sprintf) > to make it clear to the next reader that we know we're in a sysfs show > method? It would make auditing uses of sprintf() much easier. Code churn to keep code checkers quiet for pointless reasons? What could go wrong with that... It should be pretty obvious to any reader that you are in a sysfs show method, as almost all of them are trivially tiny and obvious. Yes, it doesn't help with those that make blanket statements like "sprintf is evil", but I think that kind of just shows them that they shouldn't be making foolish blanket statements like that :) Anyway, we've had this for 20 years, if sysfs calls are the only left remaining user of sprintf(), then I'll be glad to consider using a "wrapper" function or macro. thanks, greg k-h