Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp970299rdb; Fri, 2 Feb 2024 09:17:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IHZJ27G3zvab5iTDx3NfY9IwSUfc9aBLcRvW/lR99hmCFqMmT7ji4KAVhCt9KHMUtG16puh X-Received: by 2002:a05:6359:4591:b0:176:5a5e:4b7c with SMTP id no17-20020a056359459100b001765a5e4b7cmr8681743rwb.6.1706894273280; Fri, 02 Feb 2024 09:17:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706894273; cv=pass; d=google.com; s=arc-20160816; b=qIv4FJ6QbhHD4RtM/saEGOqLDi2WNRrDJmDGbbN4FiCtVk1JtVS1sJaSWC2b14ZQ0l zwWGUfcKsXw0Htj94VoLJrQBs8PJBAvxd8Kh4ZiieFC2EJuutLcuNSQ4/g3pqAOxNSH6 ALBJuDbENvlxXBH2+qnWp6OFf2PYiceMaPDnJ5x4+KvjpAIlbxA3/HXnJf9is0vcKPcf aRJE3zAqTJPLC15c445i7TX3LVUi4Ziksi8mw1OVTcD+njxBEDuIRoaqCr01Z5WsTAKa ZPR6CQ6P5rs3hrjYJ8vGetlnLbbE4My/xVMQo284lPM+WdZnTd+PtJPIYfVGadIRZd7j 6D7w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=X1RE1DrW3cmzZt8gWsxhvtY1vXK4KiWnqvVkq0h0o+Q=; fh=mNT1WkrKftNT4kItX7zCNQt8lkzrgXRxDnH+4VbIWfA=; b=uC7t2KGXwIAThi3vuSfkjyfXABLs4TZxXgJUOEXzeI2XAUoEIZc0+IhBZWKHTV+A/T fRT1NofeVQihnfLOJwJOXd3sO7g99ArKr3/V/bDAzrlyQ6mfJJ6iTRDScI0W9XxDQCSh i/3wvPZfGolLFwvVEpRIKSfZzH9DecfdALWTyFco/qOODIDIIgrS6Eq4l8HHZDJAgFKe yIscMaT059cr8VGQJfFmj9TLmDHfTUcGdzr96LcgUM6FUdmerwyvbFNPAhUCFUobu39/ VWZqIefq1TozX/bahYMaE4/ZpXu5p91lLMbeK2HLRGsKO0SAda7hShyXHceFzCh5tkNq wh2g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bmzz4TUu; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50223-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50223-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCXoyM5oOKjHXZyVOxBROVSNzJvoghUK0ur1Yw6TbrLABwcxxeOFSUzmRyu5TFX7uOGqP3vm4coFVB5+zik1eS8t+gPlYpzgVxBdrDKVmA== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id j28-20020a63595c000000b005cfbd190e57si1815266pgm.297.2024.02.02.09.17.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 09:17:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50223-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=@kernel.org header.s=k20201202 header.b=bmzz4TUu; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50223-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50223-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.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 E0AD1286860 for ; Fri, 2 Feb 2024 17:14:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 30A1E14AD11; Fri, 2 Feb 2024 17:14:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bmzz4TUu" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 52FA47E0E5; Fri, 2 Feb 2024 17:14:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706894045; cv=none; b=a16BPKrKuimdhALrVzJn2sTgcsjp/rQeVI4/0ykAeyXaE6MnuvFwJwbHyBmD2htAfsb1aGHWPqXwVKAfhh9eKM2ZmH9VA4M4asrDtUUcB4QxRCkadxYaaRcHT0grIQaaZ2WKN37gSvJ7X7FjJEP7g9EP+vLgmSGi3F6lFLe+NAA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706894045; c=relaxed/simple; bh=CTr3UEtOevAFgGCu3DO+L25topN4UXf5ROEo1UZIWNQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YYdM9zpbjqoUhh5px18eR9LiDFEPsL7Ulz5R5WDqjQ01q/YH/9eR+HRMO0zvRziKedb6k657Hkinee4t/7X6GYFX85rSqeBgY37z98pwbnQfG5VDFNbL70D+rrbYPT6WtquUqSy8idrIbgxgDE9DFBNn1RJH7aQ5leOnVwgo6EE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bmzz4TUu; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3CB76C433F1; Fri, 2 Feb 2024 17:14:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706894044; bh=CTr3UEtOevAFgGCu3DO+L25topN4UXf5ROEo1UZIWNQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bmzz4TUuhznYAD4P+RMLOFk6Ifhy1aPXO6AwFnJXtKIyEtdN6GlkWLPbUoYrcoZBV dl216lb/hYo6ygy79ydOG6uhoLAO1w7gAakvrOql0CrbwpwLLIf4ty6mqeAx9MpSQA wvwtj7hMnWMRYeLArSRFRfHsvGzO5xtWJuVZz/5N8jkAv8obOe2FgVOiZlJVu02CRv dIr1xLUNMNTVaFAFiaJbcpsCSf6Tn9o7xfAoazABzpMGakcJnu7zxiKgRKZeni6qqT AZu59nK9qaksPT7JdvcH5f3RQZapuzYFSqIi8+hOsX6FOtLBYcI7ZHKzvQ4IS+mO63 dO6U8LAybDl6w== From: SeongJae Park To: Arnd Bergmann Cc: SeongJae Park , Andrew Morton , Arnd Bergmann , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/damon/dbgfs: fix bogus string length Date: Fri, 2 Feb 2024 09:14:02 -0800 Message-Id: <20240202171402.46340-1-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240202124339.892862-1-arnd@kernel.org> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Hi Arnd, On Fri, 2 Feb 2024 13:43:26 +0100 Arnd Bergmann wrote: > From: Arnd Bergmann > > gcc correctly points out that using strnlen() on a fixed size array > is nonsense with an overlong limit: > > mm/damon/dbgfs.c: In function 'damon_dbgfs_deprecated_read': > mm/damon/dbgfs.c:814:19: error: 'strnlen' specified bound 1024 exceeds source size 512 [-Werror=stringop-overread] > 814 | int len = strnlen(kbuf, 1024); > | ^~~~~~~~~~~~~~~~~~~ > mm/damon/dbgfs.c:813:14: note: source object allocated here > 813 | char kbuf[512] = DAMON_DBGFS_DEPRECATION_NOTICE; > | ^~~~ > > In fact, neither of the arbitrary limits are needed here: The first > one can just be a static const string and avoid wasting any more > space then necessary, and the strnlen() can be either strlen() or > sizeof(kbuf)-1, both of which the compiler turns into the same > constant here. Thank you for this fix! > > Fixes: adf9047adfff ("mm/damon/dbgfs: implement deprecation notice file") > Signed-off-by: Arnd Bergmann Reviewed-by: SeongJae Park Thanks, SJ [...]