From patchwork Fri Oct 16 02:40:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jann Horn X-Patchwork-Id: 11840495 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E614A16BC for ; Fri, 16 Oct 2020 02:40:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 957F920878 for ; Fri, 16 Oct 2020 02:40:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="syzN3L/W" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 957F920878 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 23BA6940009; Thu, 15 Oct 2020 22:40:38 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1EED3900002; Thu, 15 Oct 2020 22:40:38 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 107E8940009; Thu, 15 Oct 2020 22:40:38 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id CCE09900002 for ; Thu, 15 Oct 2020 22:40:37 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 69059362E for ; Fri, 16 Oct 2020 02:40:37 +0000 (UTC) X-FDA: 77376235314.10.leaf77_5d08fdb27219 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id 4BA7516A0B9 for ; Fri, 16 Oct 2020 02:40:37 +0000 (UTC) X-Spam-Summary: 1,0,0,93bb8a1d20ee9c6e,d41d8cd98f00b204,jannh@google.com,,RULES_HIT:41:69:355:379:541:800:960:966:973:988:989:1260:1311:1314:1345:1359:1437:1515:1535:1542:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:2693:3138:3139:3140:3141:3142:3152:3353:3865:3866:3867:3868:3870:3871:3874:4321:4385:5007:6120:6261:6653:7875:9592:9969:10004:11658:11914:12043:12048:12296:12297:12517:12519:12555:12895:12986:13138:13231:13618:13894:14096:14181:14721:21080:21444:21451:21627:30054,0,RBL:209.85.128.68:@google.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100;04yrs4wqkguyu4mizpqytgy76s9stypaeqpnhdh1bx96wittjnw9fhesinukm5i.qsnga6b5uwnzyx9b9i7rny1iskts7ywy7s35x4bn4mbtz4zi9g1xfidqxzwb1at.1-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: leaf77_5d08fdb27219 X-Filterd-Recvd-Size: 5140 Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by imf21.hostedemail.com (Postfix) with ESMTP for ; Fri, 16 Oct 2020 02:40:36 +0000 (UTC) Received: by mail-wm1-f68.google.com with SMTP id p15so939254wmi.4 for ; Thu, 15 Oct 2020 19:40:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eMrDzdvIowItPCZxwmw+48iBRpQ/wjXi6fymrEYNArc=; b=syzN3L/Wp3YBmgLZItyTMxNEiB7mSUwRKg+lARKzCumVW9bP0wC/rA7URPv/3XF2yt NrGKLpQo13w4rdDGIqCvUm3OISGfJNWUuhWojJn6f1GySxsY9rQqnNl+nyluowWKlF/w /SfnEGkqDMZDKLHzI5YHh1fFjWw5PbMtQKqRUbHCZnkS//gMV2wIk7A2G37nuTKvHADs B/zEQmJuo6j1bA3+59r6JaC2HhzekjfyfiImcMg48D1936b52+jSyU3YhSQywN11p6mU R867i5PzCvR+idcLzFJMQt7NwJbNlQ98E3Z39zytdEiGac/EIY/UPKeRButIQE62fycf qhaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eMrDzdvIowItPCZxwmw+48iBRpQ/wjXi6fymrEYNArc=; b=VUNGd9q3dSx6X0QB/myxca2r25AWJBcgxVB6hvl+fjgi4H9wCMuYytJs7GmYDUd0jq FWhGRLgfWDmJyqwLiow2xMSnncGvaUVEwtc9rc4Ei1XMO2EyPQLWw4KRVRrvzxfsPZlq bJycxByv8OhCdeHZKB9eJn2+EqQzpn0F7gMr6kxCBuevmAgheBvxGS2BVtEURS9cqjMW OYPlMwJbfYxra4EigNqpJ/DONvmDMt2Mdj0IRF116O/7LWjb0w8MUjX9GrsppF4qoDAz e2GabLL3AGDjp0gc88u/2tbCXV2FhPiDxLvAf/azvwjEqbj0ABUuh5cvh6yPorKcx8Nv Wj3Q== X-Gm-Message-State: AOAM531SGT8vV601WtjC052h+nQC77ba8F+3EUL8wEz5RKVmmVzqjzoL mpcGAWVOXEn1s3f9pr0IYR0u0g== X-Google-Smtp-Source: ABdhPJy9aBJRo775A0oUO4Y+eGG3JV+yIwLDNGANvDx1gCLPck3vDjMcMFiN3f0sqr3F+s6pCGS/Hw== X-Received: by 2002:a1c:e919:: with SMTP id q25mr1385922wmc.142.1602816035657; Thu, 15 Oct 2020 19:40:35 -0700 (PDT) Received: from localhost ([2a02:168:96c5:1:55ed:514f:6ad7:5bcc]) by smtp.gmail.com with ESMTPSA id k5sm972649wmb.19.2020.10.15.19.40.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Oct 2020 19:40:34 -0700 (PDT) From: Jann Horn To: Andrew Morton , linux-mm@kvack.org, Eric Biederman , Oleg Nesterov Cc: linux-kernel@vger.kernel.org, Will Deacon , Kees Cook , Ingo Molnar Subject: [RFC PATCH 2/6] refcount: Move refcount_t definition into linux/types.h Date: Fri, 16 Oct 2020 04:40:15 +0200 Message-Id: <20201016024019.1882062-3-jannh@google.com> X-Mailer: git-send-email 2.29.0.rc1.297.gfa9743e501-goog In-Reply-To: <20201016024019.1882062-1-jannh@google.com> References: <20201016024019.1882062-1-jannh@google.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: I want to use refcount_t in mm_struct, but if refcount_t is defined in linux/refcount.h, that header would have to be included in linux/mm_types.h; that would be wasteful. Let's move refcount_t over into linux/types.h so that includes can be written less wastefully. Signed-off-by: Jann Horn --- include/linux/refcount.h | 13 +------------ include/linux/types.h | 12 ++++++++++++ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/include/linux/refcount.h b/include/linux/refcount.h index 0e3ee25eb156..fd8cf65e4e2f 100644 --- a/include/linux/refcount.h +++ b/include/linux/refcount.h @@ -96,22 +96,11 @@ #include #include #include +#include /* refcount_t is defined here */ #include struct mutex; -/** - * struct refcount_t - variant of atomic_t specialized for reference counts - * @refs: atomic_t counter field - * - * The counter saturates at REFCOUNT_SATURATED and will not move once - * there. This avoids wrapping the counter and causing 'spurious' - * use-after-free bugs. - */ -typedef struct refcount_struct { - atomic_t refs; -} refcount_t; - #define REFCOUNT_INIT(n) { .refs = ATOMIC_INIT(n), } #define REFCOUNT_MAX INT_MAX #define REFCOUNT_SATURATED (INT_MIN / 2) diff --git a/include/linux/types.h b/include/linux/types.h index a147977602b5..34e4e779e767 100644 --- a/include/linux/types.h +++ b/include/linux/types.h @@ -175,6 +175,18 @@ typedef struct { } atomic64_t; #endif +/** + * struct refcount_t - variant of atomic_t specialized for reference counts + * @refs: atomic_t counter field + * + * The counter saturates at REFCOUNT_SATURATED and will not move once + * there. This avoids wrapping the counter and causing 'spurious' + * use-after-free bugs. + */ +typedef struct refcount_struct { + atomic_t refs; +} refcount_t; + struct list_head { struct list_head *next, *prev; };