From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 945C7156661 for ; Mon, 28 Sep 2026 01:21:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790558494; cv=none; b=StmlQp8dt1nAQ3wc5qmjFEty7lDWxC5DOciU3rGxXi34n4K5S2u4r8euNZ96mOPVdIxHWLZjRgwO9xdovQCNrK9nPDbMy3SFp0fGn+tbNg0U+P29FaBs35gYfmJs4NPyJfQZ0EbRMnvvbrX6JcezDMncaSijlDhZ9ThtrDqKyCc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790558494; c=relaxed/simple; bh=4kMYA5jdQf0BHp8sqdgIiTdCAAcHHMLHeYJkNyk9iT4=; h=Date:To:From:Subject:Message-Id; b=srVMfgbajrwhnXONxMSMPkmb7W0KE1SftPjz3hGPTqgE65vL8ZtyMXR6s4OxwLm18GO4QhXyw1q0wD8aiN9gCLaDZyZoMAthTT7vW9S8VM8Dx8F5IARbHk/LplC5UKad6rBtb80f9EAF8FEUnnto2yZ/F1FjpaSLLayD4QG9TB8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=Pg4U8hk3; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="Pg4U8hk3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 243301F000FF; Mon, 28 Sep 2026 01:21:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1790558493; bh=MDreCZ36YhfTI/NYm72nKpNM+t0gmA5AhYPSWC3G8OI=; h=Date:To:From:Subject; b=Pg4U8hk3iPu6uitHH/3Kz3qG4v/gOieqM1OasNP9DbvBWUYJLxj3zYrMOGt3fVBl6 ty5oVRYUUsFzbblYtz8MQGWzUlj/aHuR9V+lxQ4jr94k0+Le+xVfBt/jji+TaI0wWu HGJppqfSTqVYQvRd5tdNBSKUHM42YRKkPsi3SS64= Date: Sun, 27 Sep 2026 18:21:32 -0700 To: mm-commits@vger.kernel.org,jack@suse.cz,gregkh@linuxfoundation.org,matthias.goergens@gmail.com,akpm@linux-foundation.org From: Andrew Morton Subject: + kdev_t-shift-in-dev_t-in-mkdev.patch added to mm-nonmm-unstable branch Message-Id: <20260928012133.243301F000FF@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The patch titled Subject: kdev_t: shift in dev_t in MKDEV() has been added to the -mm mm-nonmm-unstable branch. Its filename is kdev_t-shift-in-dev_t-in-mkdev.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/kdev_t-shift-in-dev_t-in-mkdev.patch This patch will later appear in the mm-nonmm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: Matthias Goergens Subject: kdev_t: shift in dev_t in MKDEV() Date: Mon, 28 Sep 2026 06:49:58 +0800 MKDEV(ma, mi) evaluates ((ma) << MINORBITS) in whatever type the caller passes, usually int. For majors >= 2048 (legal: majors go up to 4095) the result exceeds INT_MAX, which C11 leaves undefined for a signed left shift; shifting a negative ma is undefined regardless of the major's value. In practice, on the compilers and two's complement targets the kernel supports, both cases wrap to the intended bit pattern; this patch makes the macro well defined regardless by casting the major to dev_t before shifting. For major and minor numbers in range, the device number it produces is unchanged. isofs feeds the Rock Ridge 'PN' entry's dev_high and dev_low into MKDEV() while holding them in int variables (fs/isofs/rock.c), so a crafted image can drive this exact shift. Fixing the macro covers every caller instead of just that one. Link: https://lore.kernel.org/20260927224958.508964-1-matthias.goergens@gmail.com Signed-off-by: Matthias Goergens Signed-off-by: Andrew Morton Cc: Greg Kroah-Hartman Cc: Jan Kara --- include/linux/kdev_t.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/include/linux/kdev_t.h~kdev_t-shift-in-dev_t-in-mkdev +++ a/include/linux/kdev_t.h @@ -9,7 +9,7 @@ #define MAJOR(dev) ((unsigned int) ((dev) >> MINORBITS)) #define MINOR(dev) ((unsigned int) ((dev) & MINORMASK)) -#define MKDEV(ma,mi) (((ma) << MINORBITS) | (mi)) +#define MKDEV(ma, mi) (((dev_t)(ma) << MINORBITS) | (mi)) #define print_dev_t(buffer, dev) \ sprintf((buffer), "%u:%u\n", MAJOR(dev), MINOR(dev)) _ Patches currently in -mm which might be from matthias.goergens@gmail.com are kdev_t-shift-in-dev_t-in-mkdev.patch