Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2215835rdb; Thu, 21 Sep 2023 11:45:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGlTNY0uOMNOaL8EyJEmZ4C05R5dBqH8/KNPq1lxDXqSaQoXeyv7ET/t2G8m45f+NqE2Bnb X-Received: by 2002:a05:6a20:2444:b0:13f:de94:fb97 with SMTP id t4-20020a056a20244400b0013fde94fb97mr618564pzc.27.1695321944780; Thu, 21 Sep 2023 11:45:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695321944; cv=none; d=google.com; s=arc-20160816; b=I7To4afipXIIsP9G+NQyoOz21tZUzev5cwnMynmDeKee1j0p1nSLwJuKbIPYZIGdep PtKFdPMBI+bPciLZcxHc1BXMgoBXLxY0qO2HFFW5K/582ClC4qMewfizjM66uy6wf+hm xZRXO6vilxyL/m6fHKs1qIOebjn/lc5L4aZYLttJHD+z48qnXkmzjAnJk1j8RekortOZ lNKpRDZHD42rkchEgWBTYtJcRB5ubX9SuHLuHGQuKkkGkl0CpKIqKDiBD7K+h8yT9Ee+ baxYsWRFvmwv8GOjwSGIf34VEfOKq7bBMIzc8oX8S/hezdm8LgZL099NCO/XjWnqM8An CUiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=nDr7YD46q/hivKT4TkpCzeKSpSv67CB2sC2th7EnPUs=; fh=49jF+HLPhWa5zsA1li8kTNkV6fK6N++ksgINgsLfE08=; b=yVLK/6VjIo7kbkYvukHy+FTgk3Jkqf4AiPosJgGOuXK5g4LzfyGg6LXJcJcP+CIabp c82BfgJYKaCwvPZls6Una5t5DQ0aiIz8Llm5DmBEUlOkYsL4zmYYj3hsWdOmhLipUZsc euFUqUrSX1hBdmgD8unti5E7xmPUu4kSz0hHyEx6aJ9xYhmrvnTTdrvknr0yFvmzGFVv kSjmcogCBseYsGSlEeO+kIyT/y3nyUphII707msKU74i+9zgaijeEwdsy0tvQx1U1+SV DJUJp2wcIyWZ0pV4LPdvRiLZ2J041oPSSbOtd8HkL2ATPTH4vUAqUGXSqFBEmuF/Zx7j YUpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=H0xQpKVj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id w190-20020a6382c7000000b00578b8016c3esi1863433pgd.138.2023.09.21.11.45.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 11:45:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=H0xQpKVj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id CB61181C36CD; Thu, 21 Sep 2023 10:29:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230194AbjIUR27 (ORCPT + 99 others); Thu, 21 Sep 2023 13:28:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229995AbjIUR2Q (ORCPT ); Thu, 21 Sep 2023 13:28:16 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A58B2AC52 for ; Thu, 21 Sep 2023 10:11:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695316309; x=1726852309; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=+uJnQMLMCkrFmbMkL5ksZO00cYOUb/n0p/lufRKAs5o=; b=H0xQpKVjYsfxjCJaVrxOCQGEFnIrXvZ4KddRs2X3o2RHsFjfCobqkA36 5wT0EwZYog6fZ5APvO1y4E33/jeVDW3BLt/VkrhDvRps0DoxlD0zoFrsF UEkl6DFE8Yjh9Cpcdgm387l1WAoSOjHnSl3YFNlaIIjl3YOSE4HL+xCOC ra84TGLphRysiMTjWtHF+cX7lvZ7G9ftcR5QVA77I9NOhfNEa0lc6zeYe bEEOip3REG9Q1LJQBXDmUg0nrjxeGo/+DsxxrOCa5vVbnuUn3GQGZ/VXh qvIHtRjc5srDZECwQHB9mSK84KnfmWYCoMe80UWGQNN9sf7treFkRp/Bl w==; X-IronPort-AV: E=McAfee;i="6600,9927,10840"; a="370896833" X-IronPort-AV: E=Sophos;i="6.03,165,1694761200"; d="scan'208";a="370896833" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2023 09:18:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10840"; a="817463280" X-IronPort-AV: E=Sophos;i="6.03,165,1694761200"; d="scan'208";a="817463280" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga004.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2023 09:18:46 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.97-RC0) (envelope-from ) id 1qjMO3-0000000GxY6-47Cw; Thu, 21 Sep 2023 19:18:43 +0300 Date: Thu, 21 Sep 2023 19:18:43 +0300 From: Andy Shevchenko To: kernel test robot Cc: oe-lkp@lists.linux.dev, lkp@intel.com, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: Re: [PATCH v1 1/6] params: Use sysfs_emit() to instead of scnprintf() Message-ID: References: <20230912150551.401537-1-andriy.shevchenko@linux.intel.com> <202309211632.67e4c1e0-oliver.sang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=0.2 required=5.0 tests=BANG_GUAR,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 21 Sep 2023 10:29:07 -0700 (PDT) On Thu, Sep 21, 2023 at 06:36:38PM +0300, Andy Shevchenko wrote: > On Thu, Sep 21, 2023 at 09:34:13PM +0800, kernel test robot wrote: > > > > Hello, > > > > kernel test robot noticed "WARNING:at_fs/sysfs/file.c:#sysfs_emit" on: > > > > commit: d4004295e5502a1eb3e361e97ea4dd1686046af6 ("[PATCH v1 1/6] params: Use sysfs_emit() to instead of scnprintf()") > > url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/params-Introduce-the-param_unknown_fn-type/20230912-231033 > > base: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git 0bb80ecc33a8fb5a682236443c1e740d5c917d1d > > patch link: https://lore.kernel.org/all/20230912150551.401537-1-andriy.shevchenko@linux.intel.com/ > > patch subject: [PATCH v1 1/6] params: Use sysfs_emit() to instead of scnprintf() > > > > in testcase: trinity > > version: trinity-i386-abe9de86-1_20230429 > > with following parameters: > > > > runtime: 300s > > group: group-04 > > nr_groups: 5 > > > > what we observed is this issue doesn't always happen. we run the test upon > > this commit almost 500 times, it happened 42 times. > > however, the parent keeps clean. > > > > v6.6-rc1 d4004295e5502a1eb3e361e97ea > > ---------------- --------------------------- > > fail:runs %reproduction fail:runs > > | | | > > :497 8% 42:496 dmesg.EIP:sysfs_emit > > :497 8% 42:496 dmesg.WARNING:at_fs/sysfs/file.c:#sysfs_emit > > Cool! I will check this, thank you for the report. Oh, my gosh... This reveals a nice overflow bug for some getters that expect buffer to be PAGE_SIZE, but an array can be bigger than that. So, basically this is a flaw in param_array_get() which is a wrapper on top of getter and calls ->get() without any proper alignment or buffer size guarantee! While ->get() is by nature suppose to get an aligned buffer of PAGE_SIZE. Ideally we need to have an additional ->get_array_element() callback which will take an offset. Less intrusive one is to have an allocated buffer of PAGE_SIZE in the param_array_get() and ->get() to it, then copy to the real one with the offset. Any other proposals? Luis, which solution would you prefer? -- With Best Regards, Andy Shevchenko