Skip to contentSkip to conversation

Patch "mm: Handle 0 flags in _calc_vm_trans() macro" has been added to the 4.14-stable tree

PATCH [email protected] 1 participant 1 message Dec 18, 2017 Stable branch

lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

mm: Handle 0 flags in _calc_vm_trans() macro

to the 4.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
mm-handle-0-flags-in-_calc_vm_trans-macro.patch
and it can be found in the queue-4.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From foo@baz Mon Dec 18 13:28:59 CET 2017

From: Jan Kara <[email protected]>
Date: Fri, 3 Nov 2017 12:21:21 +0100
Subject: mm: Handle 0 flags in _calc_vm_trans() macro

From: Jan Kara <[email protected]>

[ Upstream commit 592e254502041f953e84d091eae2c68cba04c10b ]

_calc_vm_trans() does not handle the situation when some of the passed flags are 0 (which can happen if these VM flags do not make sense for the architecture). Improve the _calc_vm_trans() macro to return 0 in such situation. Since all passed flags are constant, this does not add any runtime overhead.

---
 include/linux/mman.h |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/linux/mman.h +2 -1
@@ -64,8 +64,9 @@ static inline bool arch_validate_prot(un
  * ("bit1" and "bit2" must be single bits)
  */
 #define _calc_vm_trans(x, bit1, bit2) \
+  ((!(bit1) || !(bit2)) ? 0 : \
   ((bit1) <= (bit2) ? ((x) & (bit1)) * ((bit2) / (bit1)) \
-   : ((x) & (bit1)) / ((bit1) / (bit2)))
+   : ((x) & (bit1)) / ((bit1) / (bit2))))
 
 /*
  * Combine the mmap "prot" argument into "vm_flags" used internally.

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

queue-4.14/mm-handle-0-flags-in-_calc_vm_trans-macro.patch queue-4.14/udf-avoid-overflow-when-session-starts-at-large-offset.patch