[PATCH] Various attempts at whack-a-mole.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@xxxxxxxxxx>
---
 include/linux/bvec.h          | 26 +++++++++++++++++---------
 include/linux/pid_namespace.h |  8 ++++++--
 2 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/include/linux/bvec.h b/include/linux/bvec.h
index f41c7f0ef91e..567522aec2f9 100644
--- a/include/linux/bvec.h
+++ b/include/linux/bvec.h
@@ -101,9 +101,14 @@ struct bvec_iter_all {
 #define mp_bvec_iter_page(bvec, iter)				\
 	(__bvec_iter_bvec((bvec), (iter))->bv_page)

-#define mp_bvec_iter_len(bvec, iter)				\
-	min((iter).bi_size,					\
-	    __bvec_iter_bvec((bvec), (iter))->bv_len - (iter).bi_bvec_done)
+static inline unsigned mp_bvec_iter_len(const struct bio_vec *bvec,
+					struct bvec_iter iter)
+{
+	unsigned remains = __bvec_iter_bvec(bvec, iter)->bv_len -
+		iter.bi_bvec_done;
+
+	return remains < iter.bi_size ? remains : iter.bi_size;
+}

 #define mp_bvec_iter_offset(bvec, iter)				\
 	(__bvec_iter_bvec((bvec), (iter))->bv_offset + (iter).bi_bvec_done)
@@ -130,12 +135,15 @@ struct bvec_iter_all {
 	(mp_bvec_iter_page((bvec), (iter)) +			\
 	 mp_bvec_iter_page_idx((bvec), (iter)))

-#define bvec_iter_bvec(bvec, iter)				\
-((struct bio_vec) {						\
-	.bv_page	= bvec_iter_page((bvec), (iter)),	\
-	.bv_len		= bvec_iter_len((bvec), (iter)),	\
-	.bv_offset	= bvec_iter_offset((bvec), (iter)),	\
-})
+static inline struct bio_vec bvec_iter_bvec(struct bio_vec *bv,
+                                           struct bvec_iter iter)
+{
+       return (struct bio_vec) {
+               .bv_page        = bvec_iter_page(bv, iter),
+               .bv_len         = bvec_iter_len(bv, iter),
+               .bv_offset      = bvec_iter_offset(bv, iter)
+       };
+}

 static inline bool bvec_iter_advance(const struct bio_vec *bv,
 		struct bvec_iter *iter, unsigned bytes)
diff --git a/include/linux/pid_namespace.h b/include/linux/pid_namespace.h
index f9f9931e02d6..0c9642acc670 100644
--- a/include/linux/pid_namespace.h
+++ b/include/linux/pid_namespace.h
@@ -60,8 +60,12 @@ static inline int pidns_memfd_noexec_scope(struct pid_namespace *ns)
 {
 	int scope = MEMFD_NOEXEC_SCOPE_EXEC;

-	for (; ns; ns = ns->parent)
-		scope = max(scope, READ_ONCE(ns->memfd_noexec_scope));
+	for (; ns; ns = ns->parent) {
+		int ns_scope = READ_ONCE(ns->memfd_noexec_scope);
+
+		if (ns_scope > scope)
+			scope = ns_scope;
+	}

 	return scope;
 }
--
2.45.2




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux