Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp775065ybt; Wed, 17 Jun 2020 13:44:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/Iie+09XwKqLJBrA256fGiArgYbAMCNxCerqIz0WAwYX7rTa3SzYRnLqtVAUBnJY0PLtH X-Received: by 2002:a50:b022:: with SMTP id i31mr933420edd.301.1592426647238; Wed, 17 Jun 2020 13:44:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592426647; cv=none; d=google.com; s=arc-20160816; b=QAeiQIgHVuBL+6l0aGZuDEfhJw9NHD8rYfosTIZQZHMMRwHmufxxL90jN7xKOM6Vou +c4Zfn5wvdTJGD3No5GM0hwivqfPZfH7NfAUS/HJN57+pXocwlWbNymkEF+8kkUXAUl3 UFTLiH/T2X60Uz0t/xBBfAvnj2ySTh1Ga+RKam1Yo7Z4mjkoZvcJ/8enmQR+Mvj44/8m gbT0GRn1r0aMPoEz+MKarWmZ3TEsWct2b4dgjWaXofSv8QQqAoJInOlcqlmNEtNbzIdl KnW6ZID0tjDr5vykcmYTzVar+UqhXQAaLH9O3wFJT1kzBPJtPYAGxRrUVqZjXdOQj2UD bDvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:subject:autocrypt:from:references:cc:to; bh=UX4brrjCqXuf8JfyELRrcCYxTPT94k6LBNtVKmVNWAc=; b=J95y2hC6EJh8ScX0RRBPpKdrpblcQd3AMT4dm3dCx++5RqIl8Sn+QOm1DThF/UADEM 7kWUOdmEmCL2bILHLT+NC/FtRjZZOPSJIZbXRrzcOEZXByjUZQWjokq6wGsrKSftKS/T 2nWLTSJwTS/X/hraPYPXtLYdCrvZEpwuYvH1Ej3AT72ovSNMrRDixjvTCMVS3xsFraPM bA8W/OLCYVaKa0N+QpOoso/X/Jn4C++6PJlDspbEWwsUo4MEq9FybWm//X33HajHtQ7T SQkHMKEaCwEmFcaXQO/TILzOUREIKWDcnsmiBcoFQ5c4zmsSSINaBwHVN0Di7CK5hZix tdcw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d14si619008edp.573.2020.06.17.13.43.45; Wed, 17 Jun 2020 13:44:07 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726878AbgFQUlg (ORCPT + 99 others); Wed, 17 Jun 2020 16:41:36 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:45858 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726758AbgFQUlg (ORCPT ); Wed, 17 Jun 2020 16:41:36 -0400 Received: by mail-lf1-f67.google.com with SMTP id d7so2124251lfi.12 for ; Wed, 17 Jun 2020 13:41:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:autocrypt:subject :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=UX4brrjCqXuf8JfyELRrcCYxTPT94k6LBNtVKmVNWAc=; b=L0Dp7stU0GlCVX8VqKY80P37tWgdfb/WbqXnOkA8dKjhDhEY0D41EFpDo7DvW5kZsg K6gMW0aCjgfd+nS09/ahA4+Lb/ztnDH7xi5HBm0Y2NCTeDRu6rn0D/C5PDnzjVTUzJI4 YWy8X1vDCs7R6MN9O+Ux4vnjS+wDkCcO/5/ONmYxwERAY/OrDsMAjB4/W8LysI9k29bL RAaC1i0Gl8g4w+ov6QKAmo6dHF1ON+n4KLIiCfghc9Yb9zoVBVGLAHdI7gD9e6XggPfV hJguLmZR4tx2XQuZ/LRWpkb+VntkvULYb7ToAI7nBub9/N9wsdy4MZT33Yv8b7N+GhUJ XuyQ== X-Gm-Message-State: AOAM5330BoWphRVILI5AbigiIeyou38w4s2ZeFV3/QkgiG5ZxOth7Wwg 2NBkF6xz5YjoS+VcidZ2/Xk= X-Received: by 2002:a19:14e:: with SMTP id 75mr393249lfb.7.1592426493381; Wed, 17 Jun 2020 13:41:33 -0700 (PDT) Received: from [192.168.1.8] ([213.87.137.195]) by smtp.gmail.com with ESMTPSA id y22sm191346lfh.12.2020.06.17.13.41.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 17 Jun 2020 13:41:32 -0700 (PDT) To: Julia Lawall Cc: linux-kernel@vger.kernel.org, cocci@systeme.lip6.fr References: <20200615130242.11825-1-efremov@linux.com> From: Denis Efremov Autocrypt: addr=efremov@linux.com; keydata= mQINBFsJUXwBEADDnzbOGE/X5ZdHqpK/kNmR7AY39b/rR+2Wm/VbQHV+jpGk8ZL07iOWnVe1 ZInSp3Ze+scB4ZK+y48z0YDvKUU3L85Nb31UASB2bgWIV+8tmW4kV8a2PosqIc4wp4/Qa2A/ Ip6q+bWurxOOjyJkfzt51p6Th4FTUsuoxINKRMjHrs/0y5oEc7Wt/1qk2ljmnSocg3fMxo8+ y6IxmXt5tYvt+FfBqx/1XwXuOSd0WOku+/jscYmBPwyrLdk/pMSnnld6a2Fp1zxWIKz+4VJm QEIlCTe5SO3h5sozpXeWS916VwwCuf8oov6706yC4MlmAqsQpBdoihQEA7zgh+pk10sCvviX FYM4gIcoMkKRex/NSqmeh3VmvQunEv6P+hNMKnIlZ2eJGQpz/ezwqNtV/przO95FSMOQxvQY 11TbyNxudW4FBx6K3fzK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TrNCPnIauTgZtf/KCFQJpKaakC3ffEkPhyTjEl7oOE9xccNjccZraadi+2uHV0ULA1m ycHhb817A03n1I00QwLf2wOkckdqTqRbFFI/ik69hF9hemK/BmAHpShI+z1JsYT9cSs8D7wb aF/jQVy4URensgAPkgXsRiboqOj/rTz9F5mpd/gPU/IOUPFEMoo4TInt/+dEVECHioU3RRrW EahrGMfRngbdp/mKs9aBR56ECMfFFUPyI3VJsNbgpcIJjV/0N+JdJKQpJ/4uQ2zNm0wH/RU8 CRJvEwtKemX6fp/zLI36Gvz8zJIjSBIEqCb7vdgvWarksrhmi6/Jay5zRZ03+k6YwiqgX8t7 ANwvYa1h1dQ36OiTqm1cIxRCGl4wrypOVGx3OjCar7sBLD+NkwO4RaqFvdv0xuuy4x01VnOF Subject: Re: [Cocci] [PATCH] coccinelle: api: add device_attr_show script Message-ID: <871aeea8-9b61-5eaa-4b0d-a377ba82c2d0@linux.com> Date: Wed, 17 Jun 2020 23:41:28 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/17/20 11:27 PM, Julia Lawall wrote: > > > On Mon, 15 Jun 2020, Denis Efremov wrote: > >> According to the documentation[1] show() methods of device attributes >> should return the number of bytes printed into the buffer. This is >> the return value of scnprintf(). show() must not use snprintf() >> when formatting the value to be returned to user space. snprintf() >> returns the length the resulting string would be, assuming it all >> fit into the destination array[2]. scnprintf() return the length of >> the string actually created in buf. If one can guarantee that an >> overflow will never happen sprintf() can be used otherwise scnprintf(). > > The semantic patch looks fine. Do you have any accepted patches from > this? It's not my patches, but: 3f9f8daad342 cpuidle: sysfs: Fix the overlap for showing available governors 117e2cb3eeee sparc: use scnprintf() in show_pciobppath_attr() in vio.c 03a1b56f501e sparc: use scnprintf() in show_pciobppath_attr() in pci.c 3dee04262898 iio: tsl2772: Use scnprintf() for avoiding potential buffer overflow dbdd24eaac4e edd: Use scnprintf() for avoiding potential buffer overflow abdd9feb45ed btrfs: sysfs: Use scnprintf() instead of snprintf() f21431f2de33 thermal: int340x_thermal: Use scnprintf() for avoiding potential buffer overflow 40501c70e3f0 s390/zcrypt: replace snprintf/sprintf with scnprintf eb3e064b8dd1 s390/zcrypt: Use scnprintf() for avoiding potential buffer overflow 06b522d6de9d video: uvesafb: Use scnprintf() for avoiding potential buffer overflow bf1b615ad97e video: omapfb: Use scnprintf() for avoiding potential buffer overflow b40e288bfb53 platform/x86: sony-laptop: Use scnprintf() for avoiding potential buffer overflow ef21e1750158 ALSA: Use scnprintf() instead of snprintf() for show and many more Thanks, Denis