Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp88064img; Thu, 21 Mar 2019 14:48:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqwtKatg9646DsFlDoFSEPOerfuQ/W7nyewjxH067o87c2suVayyPrhTfw/oKum0vuSl+oNg X-Received: by 2002:a63:c00a:: with SMTP id h10mr5516568pgg.272.1553204913649; Thu, 21 Mar 2019 14:48:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553204913; cv=none; d=google.com; s=arc-20160816; b=Nkj46AH1j0WPDPl2Yc0jMztNROa7Q+f0hEwZvzPgttWGcIU2FhIsWnWYALr0KOIXPL MJ5vA8yzgTjSgCaVQy9+5hpFh0JcLv9on18Ivi4lJ+i3n9zBcekp/HxScSl94GiBnWTV dByUzgntfGtTY2JEOtCghqdyMsCioXGdpk1/jnDyzsMLZM3sbGnyQunF6xr9kf+GVoMp ySnMWwErzKbWQFVSW9d2E8sk97cNcr+7zIgaSGE2KDJBXUQjDomFFMxZExZs6ZD8KD3+ oCj0AJ3XMFjrpABiEYD3qhwVEY0p/S8XuvsOLhK2DCWwvqOOHKDeLYOPYGY+60fZ8lKM /WHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=8zoApZhZWyc/zQDL8lsZCo2bpvcOvtsmY8WXGjwqfxs=; b=kUOopbuVcBVhJMhhX3tmwesc9FQhgnpFQwAHvc+uU4UDtvwJMRxz0BORCybmeYlURB P7fCcKV0259Qn0EtBRCEdiNxl0zvr5JIK3qpcPNzL5nrs+etZfYm1vbguTwQhnvQ5S8J 1CzW/IsmkMdjWMldvw1XlTa2RysaDG8WxJizsROyeokPjRuIYieAB1vYooFlr0exsHNJ 3+QjVqn/xr7Y5VR00xIJGdCA2G26oPSbX3Wggo236e1MmRzfG4u2vGgxzOTQclUQr8jA BHueelFdoMnhdL+qHkC5OypW2Rgfc8J9jkiKHmg9beNUzBjnE6EKjpAEHzgit9KaMHLL t5Pw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d4si5436717pla.112.2019.03.21.14.48.18; Thu, 21 Mar 2019 14:48:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727365AbfCUVpz (ORCPT + 99 others); Thu, 21 Mar 2019 17:45:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52254 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727168AbfCUVpl (ORCPT ); Thu, 21 Mar 2019 17:45:41 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D480C30821A3; Thu, 21 Mar 2019 21:45:40 +0000 (UTC) Received: from llong.com (dhcp-17-47.bos.redhat.com [10.18.17.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47A2A5C66D; Thu, 21 Mar 2019 21:45:39 +0000 (UTC) From: Waiman Long To: Andrew Morton , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, selinux@vger.kernel.org, Paul Moore , Stephen Smalley , Eric Paris , "Peter Zijlstra (Intel)" , Oleg Nesterov , Waiman Long Subject: [PATCH 3/4] signal: Add free_uid_to_q() Date: Thu, 21 Mar 2019 17:45:11 -0400 Message-Id: <20190321214512.11524-4-longman@redhat.com> In-Reply-To: <20190321214512.11524-1-longman@redhat.com> References: <20190321214512.11524-1-longman@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Thu, 21 Mar 2019 21:45:41 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a new free_uid_to_q() function to put the user structure on freeing queue instead of freeing it directly. That new function is then called from __sigqueue_free() with a free_q parameter. Signed-off-by: Waiman Long --- include/linux/sched/user.h | 3 +++ kernel/signal.c | 2 +- kernel/user.c | 17 +++++++++++++---- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/include/linux/sched/user.h b/include/linux/sched/user.h index c7b5f86b91a1..77f28d5cb940 100644 --- a/include/linux/sched/user.h +++ b/include/linux/sched/user.h @@ -63,6 +63,9 @@ static inline struct user_struct *get_uid(struct user_struct *u) refcount_inc(&u->__count); return u; } + +struct kmem_free_q_head; extern void free_uid(struct user_struct *); +extern void free_uid_to_q(struct user_struct *u, struct kmem_free_q_head *q); #endif /* _LINUX_SCHED_USER_H */ diff --git a/kernel/signal.c b/kernel/signal.c index 04fb202c16bd..2ecb23b540eb 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -440,7 +440,7 @@ static void __sigqueue_free(struct sigqueue *q, struct kmem_free_q_head *free_q) if (q->flags & SIGQUEUE_PREALLOC) return; atomic_dec(&q->user->sigpending); - free_uid(q->user); + free_uid_to_q(q->user, free_q); if (free_q) kmem_free_q_add(free_q, sigqueue_cachep, q); else diff --git a/kernel/user.c b/kernel/user.c index 0df9b1640b2a..d92629bae546 100644 --- a/kernel/user.c +++ b/kernel/user.c @@ -135,14 +135,18 @@ static struct user_struct *uid_hash_find(kuid_t uid, struct hlist_head *hashent) * IRQ state (as stored in flags) is restored and uidhash_lock released * upon function exit. */ -static void free_user(struct user_struct *up, unsigned long flags) +static void free_user(struct user_struct *up, unsigned long flags, + struct kmem_free_q_head *free_q) __releases(&uidhash_lock) { uid_hash_remove(up); spin_unlock_irqrestore(&uidhash_lock, flags); key_put(up->uid_keyring); key_put(up->session_keyring); - kmem_cache_free(uid_cachep, up); + if (free_q) + kmem_free_q_add(free_q, uid_cachep, up); + else + kmem_cache_free(uid_cachep, up); } /* @@ -162,7 +166,7 @@ struct user_struct *find_user(kuid_t uid) return ret; } -void free_uid(struct user_struct *up) +void free_uid_to_q(struct user_struct *up, struct kmem_free_q_head *free_q) { unsigned long flags; @@ -170,7 +174,12 @@ void free_uid(struct user_struct *up) return; if (refcount_dec_and_lock_irqsave(&up->__count, &uidhash_lock, &flags)) - free_user(up, flags); + free_user(up, flags, free_q); +} + +void free_uid(struct user_struct *up) +{ + free_uid_to_q(up, NULL); } struct user_struct *alloc_uid(kuid_t uid) -- 2.18.1