Skip to contentSkip to conversation

ipc-shm-fix-shmat-nil-address-after-round-down-when-remapping.patch removed from -mm tree

merged [email protected] 1 participant 1 message May 29, 2018 Stable branch

lore
Share & tools
lore

[email protected]

author tree notice Applied
#0 lore raw

The patch titled
Subject: ipc/shm: fix shmat() nil address after round-down when remapping
has been removed from the -mm tree. Its filename was
ipc-shm-fix-shmat-nil-address-after-round-down-when-remapping.patch

This patch was dropped because it was merged into mainline or a subsystem tree

------------------------------------------------------
From: Davidlohr Bueso <[email protected]>
Subject: ipc/shm: fix shmat() nil address after round-down when remapping

shmat()'s SHM_REMAP option forbids passing a nil address for; this is in fact the very first thing we check for. Andrea reported that for SHM_RND|SHM_REMAP cases we can end up bypassing the initial addr check, but we need to check again if the address was rounded down to nil. As of this patch, such cases will return -EINVAL.

---

 ipc/shm.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
ipc/shm.c renamed from ipc/shm.c~ipc-shm-fix-shmat-nil-address-after-round-down-when-remapping +10 -2
diff -puN ipc/shm.c~ipc-shm-fix-shmat-nil-address-after-round-down-when-remapping ipc/shm.c
@@ -1363,9 +1363,17 @@ long do_shmat(int shmid, char __user *sh
 
 	if (addr) {
 		if (addr & (shmlba - 1)) {
-			if (shmflg & SHM_RND)
+			if (shmflg & SHM_RND) {
 				addr &= ~(shmlba - 1);  /* round down */
-			else
+
+				/*
+				 * Ensure that the round-down is non-nil
+				 * when remapping. This can happen for
+				 * cases when addr < shmlba.
+				 */
+				if (!addr && (shmflg & SHM_REMAP))
+					goto out;
+			} else
 #ifndef __ARCH_FORCE_SHMLBA
 				if (addr & ~PAGE_MASK)
 #endif

_

Patches currently in -mm which might be from [email protected] are

ipc-sem-mitigate-semnum-index-against-spectre-v1.patch