Files
Centos-kernel-stream-10/include/linux/utsname.h
T
Waiman Long 6daab4673f copy_process: pass clone_flags as u64 across calltree
JIRA: https://issues.redhat.com/browse/RHEL-152433
Conflicts:
  1) A context diff with the kernel/pid_namespace.c hunk due to missing
     upstream commit 7863dcc72d0f ("pid: allow pid_max to be set per
     pid namespace").
  2) A context diff with the net/core/net_namespace.c hunk due to
     missing upstream commit e57a6320215c ("net: Add net_passive_inc()
     and net_passive_dec().").

commit edd3cb05c00a040dc72bed20b14b5ba865188bce
Author: Simon Schuster <schuster.simon@siemens-energy.com>
Date:   Mon, 1 Sep 2025 15:09:51 +0200

    copy_process: pass clone_flags as u64 across calltree

    With the introduction of clone3 in commit 7f192e3cd3 ("fork: add
    clone3") the effective bit width of clone_flags on all architectures was
    increased from 32-bit to 64-bit, with a new type of u64 for the flags.
    However, for most consumers of clone_flags the interface was not
    changed from the previous type of unsigned long.

    While this works fine as long as none of the new 64-bit flag bits
    (CLONE_CLEAR_SIGHAND and CLONE_INTO_CGROUP) are evaluated, this is still
    undesirable in terms of the principle of least surprise.

    Thus, this commit fixes all relevant interfaces of callees to
    sys_clone3/copy_process (excluding the architecture-specific
    copy_thread) to consistently pass clone_flags as u64, so that
    no truncation to 32-bit integers occurs on 32-bit architectures.

    Signed-off-by: Simon Schuster <schuster.simon@siemens-energy.com>
    Link: https://lore.kernel.org/20250901-nios2-implement-clone3-v2-2-53fcf5577d57@siemens-energy.com
    Acked-by: David Hildenbrand <david@redhat.com>
    Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
    Reviewed-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Christian Brauner <brauner@kernel.org>

Signed-off-by: Waiman Long <longman@redhat.com>
2026-02-28 14:50:38 -05:00

93 lines
1.8 KiB
C

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _LINUX_UTSNAME_H
#define _LINUX_UTSNAME_H
#include <linux/sched.h>
#include <linux/nsproxy.h>
#include <linux/ns_common.h>
#include <linux/err.h>
#include <uapi/linux/utsname.h>
enum uts_proc {
UTS_PROC_ARCH,
UTS_PROC_OSTYPE,
UTS_PROC_OSRELEASE,
UTS_PROC_VERSION,
UTS_PROC_HOSTNAME,
UTS_PROC_DOMAINNAME,
};
struct user_namespace;
extern struct user_namespace init_user_ns;
struct uts_namespace {
struct new_utsname name;
struct user_namespace *user_ns;
struct ucounts *ucounts;
struct ns_common ns;
} __randomize_layout;
extern struct uts_namespace init_uts_ns;
#ifdef CONFIG_UTS_NS
static inline void get_uts_ns(struct uts_namespace *ns)
{
refcount_inc(&ns->ns.count);
}
extern struct uts_namespace *copy_utsname(u64 flags,
struct user_namespace *user_ns, struct uts_namespace *old_ns);
extern void free_uts_ns(struct uts_namespace *ns);
static inline void put_uts_ns(struct uts_namespace *ns)
{
if (refcount_dec_and_test(&ns->ns.count))
free_uts_ns(ns);
}
void uts_ns_init(void);
#else
static inline void get_uts_ns(struct uts_namespace *ns)
{
}
static inline void put_uts_ns(struct uts_namespace *ns)
{
}
static inline struct uts_namespace *copy_utsname(u64 flags,
struct user_namespace *user_ns, struct uts_namespace *old_ns)
{
if (flags & CLONE_NEWUTS)
return ERR_PTR(-EINVAL);
return old_ns;
}
static inline void uts_ns_init(void)
{
}
#endif
#ifdef CONFIG_PROC_SYSCTL
extern void uts_proc_notify(enum uts_proc proc);
#else
static inline void uts_proc_notify(enum uts_proc proc)
{
}
#endif
static inline struct new_utsname *utsname(void)
{
return &current->nsproxy->uts_ns->name;
}
static inline struct new_utsname *init_utsname(void)
{
return &init_uts_ns.name;
}
extern struct rw_semaphore uts_sem;
#endif /* _LINUX_UTSNAME_H */