From nobody Sun Dec 14 05:53:38 2025 Received: from mail-oo1-f71.google.com (mail-oo1-f71.google.com [209.85.161.71]) (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 00EEB1DF271 for ; Fri, 12 Dec 2025 01:03:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.71 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765501437; cv=none; b=Ztj++T/BIdD2JuNgj5QjKO8A7I8cNJxWiGtOGP8zC5FhYPYDUtP/j9XP8UElCGNRU++PupklWkRJQsJpevOfYIv3HO5ESpwfogu3ijJI2z45WRhixnS0HXkw5d+JraBhSYOcTBIuDWSxTfl8+Oz14CTsmnfkhFR5deZjPPISIGQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765501437; c=relaxed/simple; bh=ytLW8g7BubtOM7Qka2TVNMylHNTLdgfU1SZMCgGXc1o=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=IexLi6lL2vC5ibosClO98RI/lY03Hn1kH6ML3tyeYnVKTFZCXkjFgJ8GThcezn3AXGfopoQ1QsRH6hhe/akCeA6mh6gkff6MDaRU5U+1xCWCOEajPIfBSX41zLG/3PPjTVm0JdaMx5C1ASONfk1U/NoWcbqzbzJh8ucD5s2q0mM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com; arc=none smtp.client-ip=209.85.161.71 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com Received: by mail-oo1-f71.google.com with SMTP id 006d021491bc7-657490e060dso751798eaf.3 for ; Thu, 11 Dec 2025 17:03:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765501435; x=1766106235; h=to:from:subject:message-id:in-reply-to:date:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BTLroMp+WT4ObI29OHOKmGtGuW8SJYOSxa8sWNV6Lvk=; b=fTVScyxEz9BCdhTsy4RPxHrxSON6fF7hB8GKNLmr85xr3rKnboLbb5mkBzaMfcHCe5 KHJ86S6aqCid4eAZrdZ889PLtbgaMfJxLqw3yuAQMKIsS+sGFkdEGSK5myekBDHEsXnL t1Q0ZZ8At8GVgcT7jh66IdWYfaHNHx+Iab5JmFbyquh48EWPnHpi6yyU++XLcdHoQNsP RDPatP3084XS9flM0Q6+Wa12eC+3JJEINipNQMWleQmKEcMwgkWJh3lDiIQmVbFcYnGV hQzxmF3DGedOlwe1z+1xkPYY4eFndyoAZGlYYaAow/BciRPa3nDG9dg/3vv2EttrbcGj gkhA== X-Gm-Message-State: AOJu0YzaG/mBkmAKKjBUgwemtzlCdhJYbHIt1eluoV3cyDImZ5ZRjnFA IYrQai4mMpskyyCdrgFD0MSWSZDOxgyVwqBjam+oxj6tGYnJ31hjadyBoVQ0xKk/cVBy7On6Gp+ xBluDVDjBQakJ+9F6t5/XG+0wmbdIwqUxgDduB2kZ9xqaRScTZchJQKsBBq0= X-Google-Smtp-Source: AGHT+IG3aYLb6/uH9nOFKxPkRk09SOu6XUW9qdZ09HaW1tClTdMRrPfGTCNTbSSWU85ej62pYz8dZlpdIHGE/2BhPbJWnnPi5oEa Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a05:6820:822:b0:659:9a49:9048 with SMTP id 006d021491bc7-65b45186c2dmr185068eaf.19.1765501435011; Thu, 11 Dec 2025 17:03:55 -0800 (PST) Date: Thu, 11 Dec 2025 17:03:54 -0800 In-Reply-To: <693b4abb.a70a0220.33cd7b.003a.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <693b69fa.a70a0220.33cd7b.0040.GAE@google.com> Subject: Forwarded: [PATCH] block: add allocation size check in blkdev_pr_read_keys() From: syzbot To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" For archival purposes, forwarding an incoming command email to linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com. *** Subject: [PATCH] block: add allocation size check in blkdev_pr_read_keys() Author: kartikey406@gmail.com #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git= master blkdev_pr_read_keys() takes num_keys from userspace and uses it to calculate the allocation size for keys_info via struct_size(). While there is a check for SIZE_MAX (integer overflow), there is no upper bound validation on the allocation size itself. A malicious or buggy userspace can pass a large num_keys value that doesn't trigger overflow but still results in an excessive allocation attempt, causing a warning in the page allocator when the order exceeds MAX_PAGE_ORDER. Fix this by checking that keys_info_len does not exceed KMALLOC_MAX_SIZE before attempting the allocation. Reported-by: syzbot+660d079d90f8a1baf54d@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3D660d079d90f8a1baf54d Signed-off-by: Deepanshu Kartikey --- block/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/ioctl.c b/block/ioctl.c index 61feed686418..3e9e4257569f 100644 --- a/block/ioctl.c +++ b/block/ioctl.c @@ -443,7 +443,7 @@ static int blkdev_pr_read_keys(struct block_device *bde= v, blk_mode_t mode, return -EFAULT; =20 keys_info_len =3D struct_size(keys_info, keys, read_keys.num_keys); - if (keys_info_len =3D=3D SIZE_MAX) + if (keys_info_len =3D=3D SIZE_MAX || keys_info_len > KMALLOC_MAX_SIZE) return -EINVAL; =20 keys_info =3D kzalloc(keys_info_len, GFP_KERNEL); --=20 2.43.0