From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 C70A93093B5 for ; Tue, 24 Mar 2026 22:36:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774391807; cv=none; b=sYt3iHpuvbosVvis7P+KwtrwQpjYlTAiMrEJfioAv+gwLBaLop6lcMcASM3cT5mzYHZhj0tgqEc+HtVZ/2mFMU0+nuLrpU8mtCE2o+yLbgIZl2wbpMJ0PYXHo+b9/xxBbb7V3b3Bjj2AAGPGmLT4giX3jUiYJZc67Hm5tG5Rg7o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774391807; c=relaxed/simple; bh=D6a4sODgurWumOMmlJU2HZVlxIk8M7hyJqU671PcXTk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NZnHwe/P2wgKHd+n5lcS8NIn+nvYPETmfTjT/TrBBSQPrwIc1sYzffVexKlWC+fLaPL0jwg5a/sv+1c2OXjlE8JNL8+jkPCaddqHnOdGFYK49skmSDr+5J5waBSzfCd7fOAymyBxAtGm1M5G9KkhJXjOkLkZm8zbn27+YwOYpWs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=googlemail.com; spf=pass smtp.mailfrom=googlemail.com; dkim=pass (2048-bit key) header.d=googlemail.com header.i=@googlemail.com header.b=JhpEWuqK; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=googlemail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=googlemail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=googlemail.com header.i=@googlemail.com header.b="JhpEWuqK" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4852a9c6309so39414205e9.0 for ; Tue, 24 Mar 2026 15:36:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20251104; t=1774391804; x=1774996604; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=peEWCpydE3W39BrPkX54rd6U/gBnylU2ryccRF0Lwo4=; b=JhpEWuqKcEbry+35H3KA33vTKakB9dHe4PJRw4p+vk6nGQUlSx0vr6/JupqXf8bFx6 HQ7Mok1X3vjtoEKZSbPYwV49WngOrGBkhW76n21QqMW/kwrPNej2+mPZgMQdvwxCjgwh /a6OmJX8u35loz9SWpfsY8x4Pj6efv1AHHLwbhLjJNshHn26QYkiZF2l8aPo59eIe5uB EpzdddJRKzy2OGUAnXfZZN1Mocq0Z7FrJM7Zxrw9mIcIl6gnsYgZB1W8c9uTzokyiFUe YWDNq9YGG3U/qAfx3U+rFvll9Zva287R3TwNVFghrAtNzfT+6LPuoxdfUMTWV3lYtnFW lJuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774391804; x=1774996604; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=peEWCpydE3W39BrPkX54rd6U/gBnylU2ryccRF0Lwo4=; b=gW/XrivboZgUb9nPSa8VA6Cmz8Cv9kcVIwiZfLPfGb44rXD/Dq9TnIfMi07JQ7+OLy MKNS8LCBw5jEUZEYwDt2nml1FaWi/mDH1avh7+BJnxCujku32Ggc51AMHJuSn5imYOjp CYDDAoVuXU5cktgx91eMbuxjtIwC6tMGBe4CBs604heyd1+yhz26JRvxYMuwGGSUV2BB qd+LghM9oa66fvfTPG4Qtj7/MjbyUtQsbBMteuE/19Pb95LS6Dh+G7KwoFuPIDFghXBT kI/DmjQUTLnlPc7/+MAy2JAFpbe4JB2bwUPzRzSh/1eBIiarJ5GDpEG+I2FeRXIkDEv1 LZmg== X-Forwarded-Encrypted: i=1; AJvYcCV0Lmoft2FtdF0IKZy0UIlOE1BLYnmTB2yWAVUuV5SOt/+fC+XyK8Z4GasJqhFsGHU374W3xGtIO69kmBg=@vger.kernel.org X-Gm-Message-State: AOJu0YyUgAuLcS+VgnCoe+rBIPx5+OoxWW0afDyQiWT0fTD8RunUPOPZ j0SQhXYj5z87xSiP12VRzf2v2zCng357dgP8yIdo7RPHOMJdBBijtlQQEqp2ANRU X-Gm-Gg: ATEYQzyYa3bYqEeXBTRllQvfMU+tv4OR1FyJaOfh9wd+rwdrVd2YOdVEyOgu5rNZEff xTLdjMD+bsnwS9r0oACNqUoaYe2/EaOWjByCkkhm5JvlEMtDLlW2W1JOh56niOaN/01tPUKwA0E wMdC3ZD+StlyeUdXkQALWgHTmxEU2ilNz6hsLgbp0T5LVRnpwjeSxxn7f1RB10GBexDXbLunU8O GDp/GFrAZMmvODFwcapS+eJtRwESuTOjF7arZ8wG2HwJfiqVjR4prCQxojSoVKU5TQqnGRqKDfY P5dBfii0pu1nRL/nykhN6o05T9Vbu9mAAnp+jNne81LB71Rp2zgFMibilJTrA8l5VpfX+Iifb78 kc3t1tetITqBnol+aOPzvP/YsPxE71Wd1YEfphJiHCEUGfdQ8Xls8A9NKiTQF3JYgwoIC2ZIFqU o5cL13BBURJ0FnpmVHuuw= X-Received: by 2002:a05:600c:a112:b0:485:5c6e:8a38 with SMTP id 5b1f17b1804b1-487160429dbmr16208605e9.17.1774391804149; Tue, 24 Mar 2026 15:36:44 -0700 (PDT) Received: from DESKTOP-I0B9J3E ([2a02:8071:5392:3220::bcad]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-487113c4eb3sm91713535e9.0.2026.03.24.15.36.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Mar 2026 15:36:43 -0700 (PDT) From: buermarc To: joel.granados@kernel.org Cc: buermarc@googlemail.com, davem@davemloft.net, elias.rw2@gmail.com, kees@kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, opurdila@ixiacom.com, ps.report@gmx.net Subject: Re: [PATCH v3] sysctl: fix check against uninitialized variable in proc_do_large_bitmap Date: Tue, 24 Mar 2026 23:36:40 +0100 Message-ID: <20260324223640.807029-1-buermarc@googlemail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: 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 From: Marc Buerg Hi, On Tue, 24 Mar 2026 08:44:13 +0100 Joel Granados, wrote: > 1. len is calculated by doing len = p - tmp > 2. tmp is the beginning of the buffer > 3. p is the first character that is not a digit. > > There will always be at least one ('\0') character that is not a digit. Yes. > So len will be less than size at least by one (could be more if the > string contains non digit chars). When it is parsed to the end, > len will be less than size by one. I don't think this is the case. See below. > TL;DR I'll try to make it shorter. size is the length of the user buffer, even after the copy to the kernel buffer. The added '\0' does not increment size in proc_sys_call_handler(). Following the example for write(fd,"123",3). In the beginning of proc_get_long(): size = 3 @:012 3 ------- "123\0" | tmp=@0 | p=@0 After strtoul_lenient(): @:012 3 ------- "123\0" | | tmp=@0 | p=@3 @3 - @0 = 3 len = 3 (len < size) => (3 < 3) => false And size must be 3, proc_sys_call_handler() does not increment it. If we provide something like write(fd,"123\0",4) size will be 4, but now we will return -EINVAL. If len < size is true, we call memchk(). memchk will not find a trailing character as p points to '\0'. This means in this case we would return -EINVAL for the first proc_get_long() call in the while loop. Reason is '\0' is not in tr_a and therefore not a valid delimiter for the first proc_get_long() call. I hope this get's my point across. > All this holds unless the trailing '\0' is modified in some way in that > BPF call. To my knowledge there was no bpf tracing enabled on the affected host at the time that the behavior was observed. Finally: the fix which adds a check for left introduces a regression. "123-" is wrongly accepted. Not sure if you saw my other message. It should not be used. Best Regards, Marc