svn commit: r365800 - in stable/12/sys: sys vm

Jack L. xxjack12xx at gmail.com
Sun Sep 20 04:17:33 UTC 2020


I'm getting a kernel panic on this revision on 12.2-STABLE after
updating to this revision on a Dell system. I have options RACCT
disabled in the kernel config. Would that be causing it to panic?
Trying to recompile the system with various revisions to make sure
this is the problem commit but also want to make sure it isn't because
I've disabled RACCT.

On Wed, Sep 16, 2020 at 7:20 AM Konstantin Belousov <kib at freebsd.org> wrote:
>
> Author: kib
> Date: Wed Sep 16 14:20:45 2020
> New Revision: 365800
> URL: https://svnweb.freebsd.org/changeset/base/365800
>
> Log:
>   MFC r365486:
>   Add kern_mmap_racct_check(), a helper to verify limits in vm_mmap*().
>
> Modified:
>   stable/12/sys/sys/syscallsubr.h
>   stable/12/sys/vm/vm_mmap.c
> Directory Properties:
>   stable/12/   (props changed)
>
> Modified: stable/12/sys/sys/syscallsubr.h
> ==============================================================================
> --- stable/12/sys/sys/syscallsubr.h     Wed Sep 16 14:16:09 2020        (r365799)
> +++ stable/12/sys/sys/syscallsubr.h     Wed Sep 16 14:20:45 2020        (r365800)
> @@ -62,6 +62,7 @@ struct sockaddr;
>  struct stat;
>  struct thr_param;
>  struct uio;
> +struct vm_map;
>
>  typedef int (*mmap_check_fp_fn)(struct file *, int, int, int);
>
> @@ -185,6 +186,8 @@ int kern_mmap(struct thread *td, uintptr_t addr, size_
>  int    kern_mmap_fpcheck(struct thread *td, uintptr_t addr, size_t len,
>             int prot, int flags, int fd, off_t pos,
>             mmap_check_fp_fn check_fp_fn);
> +int    kern_mmap_racct_check(struct thread *td, struct vm_map *map,
> +           vm_size_t size);
>  int    kern_mprotect(struct thread *td, uintptr_t addr, size_t size, int prot);
>  int    kern_msgctl(struct thread *, int, int, struct msqid_ds *);
>  int    kern_msgrcv(struct thread *, int, void *, size_t, long, int, long *);
>
> Modified: stable/12/sys/vm/vm_mmap.c
> ==============================================================================
> --- stable/12/sys/vm/vm_mmap.c  Wed Sep 16 14:16:09 2020        (r365799)
> +++ stable/12/sys/vm/vm_mmap.c  Wed Sep 16 14:20:45 2020        (r365800)
> @@ -1457,6 +1457,39 @@ vm_mmap(vm_map_t map, vm_offset_t *addr, vm_size_t siz
>         return (error);
>  }
>
> +int
> +kern_mmap_racct_check(struct thread *td, vm_map_t map, vm_size_t size)
> +{
> +       int error;
> +
> +       RACCT_PROC_LOCK(td->td_proc);
> +       if (map->size + size > lim_cur(td, RLIMIT_VMEM)) {
> +               RACCT_PROC_UNLOCK(td->td_proc);
> +               return (ENOMEM);
> +       }
> +       if (racct_set(td->td_proc, RACCT_VMEM, map->size + size)) {
> +               RACCT_PROC_UNLOCK(td->td_proc);
> +               return (ENOMEM);
> +       }
> +       if (!old_mlock && map->flags & MAP_WIREFUTURE) {
> +               if (ptoa(pmap_wired_count(map->pmap)) + size >
> +                   lim_cur(td, RLIMIT_MEMLOCK)) {
> +                       racct_set_force(td->td_proc, RACCT_VMEM, map->size);
> +                       RACCT_PROC_UNLOCK(td->td_proc);
> +                       return (ENOMEM);
> +               }
> +               error = racct_set(td->td_proc, RACCT_MEMLOCK,
> +                   ptoa(pmap_wired_count(map->pmap)) + size);
> +               if (error != 0) {
> +                       racct_set_force(td->td_proc, RACCT_VMEM, map->size);
> +                       RACCT_PROC_UNLOCK(td->td_proc);
> +                       return (error);
> +               }
> +       }
> +       RACCT_PROC_UNLOCK(td->td_proc);
> +       return (0);
> +}
> +
>  /*
>   * Internal version of mmap that maps a specific VM object into an
>   * map.  Called by mmap for MAP_ANON, vm_mmap, shm_mmap, and vn_mmap.
> @@ -1466,39 +1499,15 @@ vm_mmap_object(vm_map_t map, vm_offset_t *addr, vm_siz
>      vm_prot_t maxprot, int flags, vm_object_t object, vm_ooffset_t foff,
>      boolean_t writecounted, struct thread *td)
>  {
> -       boolean_t curmap, fitit;
>         vm_offset_t max_addr;
>         int docow, error, findspace, rv;
> +       bool curmap, fitit;
>
>         curmap = map == &td->td_proc->p_vmspace->vm_map;
>         if (curmap) {
> -               RACCT_PROC_LOCK(td->td_proc);
> -               if (map->size + size > lim_cur(td, RLIMIT_VMEM)) {
> -                       RACCT_PROC_UNLOCK(td->td_proc);
> -                       return (ENOMEM);
> -               }
> -               if (racct_set(td->td_proc, RACCT_VMEM, map->size + size)) {
> -                       RACCT_PROC_UNLOCK(td->td_proc);
> -                       return (ENOMEM);
> -               }
> -               if (!old_mlock && map->flags & MAP_WIREFUTURE) {
> -                       if (ptoa(pmap_wired_count(map->pmap)) + size >
> -                           lim_cur(td, RLIMIT_MEMLOCK)) {
> -                               racct_set_force(td->td_proc, RACCT_VMEM,
> -                                   map->size);
> -                               RACCT_PROC_UNLOCK(td->td_proc);
> -                               return (ENOMEM);
> -                       }
> -                       error = racct_set(td->td_proc, RACCT_MEMLOCK,
> -                           ptoa(pmap_wired_count(map->pmap)) + size);
> -                       if (error != 0) {
> -                               racct_set_force(td->td_proc, RACCT_VMEM,
> -                                   map->size);
> -                               RACCT_PROC_UNLOCK(td->td_proc);
> -                               return (error);
> -                       }
> -               }
> -               RACCT_PROC_UNLOCK(td->td_proc);
> +               error = kern_mmap_racct_check(td, map, size);
> +               if (error != 0)
> +                       return (error);
>         }
>
>         /*
> _______________________________________________
> svn-src-all at freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/svn-src-all
> To unsubscribe, send any mail to "svn-src-all-unsubscribe at freebsd.org"


More information about the svn-src-all mailing list