Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp116323ybl; Mon, 27 Jan 2020 23:30:36 -0800 (PST) X-Google-Smtp-Source: APXvYqzBz6CaewkXwnscMZjPMuTbgvS26r9pCu8wzn44pn5rXvCT0Zcnpgs0FV0MwY3T1+pCT4VL X-Received: by 2002:aca:5844:: with SMTP id m65mr2008554oib.136.1580196636693; Mon, 27 Jan 2020 23:30:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580196636; cv=none; d=google.com; s=arc-20160816; b=ZV1QBreQcI+X54+N+B2ROLjZkU1t47lRca6QDaqPH8gTrq3uKqPrfpWqx3Vpj8usHO HTbnu3OQdh82BUdV0m0sozvAQg2JczFzGcgn8Q7T+P3Oj4Pe+/CwWNE6jU3Mw8HA3Ma/ 7a7hXqxFD6ffTedJKbqg2Otdc01CLRyH2Z0RiRabeMf+rP4yepgvNdzEigvBnlNzk+OT kzpYtdE5GZgfSvELLDeNbTrDvfsoASQh2kiaY2RccsV9R3Pnj9bu9Ew0x4hr5DEDkiz1 /KPwAqh+w+E4iveE7v2IF60P6SZ3FrqjTuNEbxItVJkn7V8R1D9znhydRaB4DrAWtes9 aMjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=TawkIIO8Cb/tgElG2C0aCqCdkT8w60kpDmt3fNug/+o=; b=xpskqbRLra5xVmMvQs0zdLwBFwzq0hx1FWalZ69kNadzRSqDraYn49x78t6K4DZZMl jw5IBaDl1xDqa5VOuzsaR7GFuSULeYDcX2bgrg7QC41GswspPLcw7d9Qdwy/eyE7qpoP oPYeWo4yoYevhQdNirtQiK7csHLXYZilhCYkmKyhdv571kcZX89peZ7PHMdIrG83aiQp Qy6c5h/QNg/N9LQWUO7OilubJ7hotkMHAj++0lio4l/C4qpmywUJoF+noZWsHiN5UBKq SjYoX+fbZ26uccltP6mtVv3j/bYOHmJLEGoswEHQ6uib/jboBpH9WKs3zv+X3lraW1R9 eK8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ErOK+PKg; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t1si7144247otq.148.2020.01.27.23.30.22; Mon, 27 Jan 2020 23:30:36 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ErOK+PKg; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725914AbgA1H2z (ORCPT + 99 others); Tue, 28 Jan 2020 02:28:55 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:33663 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725776AbgA1H2z (ORCPT ); Tue, 28 Jan 2020 02:28:55 -0500 Received: by mail-pl1-f193.google.com with SMTP id ay11so4764257plb.0 for ; Mon, 27 Jan 2020 23:28:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=TawkIIO8Cb/tgElG2C0aCqCdkT8w60kpDmt3fNug/+o=; b=ErOK+PKgLRTXy1g+eXt3RPbgNMGJ+fJJgirflfywne1W8bVviXLif+rxPq2ttpBrxU NWSZnmUgNnk97CfVlkQotJmDRhtSYT57PDJmwE22yqZdLt54ZXWU9xgnuCEn9ZVQPvBv KeLS0CyffyxruVl1X6nKiDu/m6YIbFpUh83GuxAUz3c9WmkvlMEDPDsL5yEjlPHzIFLB MaydMBc7Wu4ax3jrHNGVCcVN/DjSS1SfC+rx4StGYW6t6CL1L2mTpUQIezntT7Kd7r2q IK9h3+/cwtwg0LFlZNuFmFQHfWNKh+zDY7O3neLu9wQ/j3zKpVjO8aKto6sByZejXsjA +OkQ== 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:mime-version :content-transfer-encoding; bh=TawkIIO8Cb/tgElG2C0aCqCdkT8w60kpDmt3fNug/+o=; b=aZnW+kWUsucjr4kvMxTrlbH86euKvDb/3sY3AISqoMo/itqrD4CW/CqGOq4yDNnuVe hvjpX5x11CMUMht6bMqp5yFaN7IL1A5KNE2pfQ5lMvGpZYI2NUaaGDI2Cnz2d9FPaLDY G3y1KWqX1mFYLAvBXD5NK6TgZNhkiBVWM/JjRNEZAU5Le/CRjixisr4ckqPeqaqGihEm IlB3mjMQYPcD1co+Q5U+ZVAN7qQiOHvUv9ePK18wYeK8erK71TjR5a8NC2l35G1fRJjK /s+RF7sTJ879mUj8H3gze+HgxCrA5tn4CLfzi/m1e6U+vRQHLNFUmHDgsqXwcEgH/OZE 7ChQ== X-Gm-Message-State: APjAAAX60hdOZQUY0cerGSQbMkYBeMLJZhcqtbqlfu1q5UN+4uAtz/E8 X7tLaZSR1n/OVXitQ8YV55g= X-Received: by 2002:a17:90a:8a98:: with SMTP id x24mr3295738pjn.113.1580196534294; Mon, 27 Jan 2020 23:28:54 -0800 (PST) Received: from localhost.localdomain ([103.211.17.252]) by smtp.googlemail.com with ESMTPSA id j17sm18566735pfa.28.2020.01.27.23.28.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jan 2020 23:28:53 -0800 (PST) From: Amol Grover To: David Howells , Shakeel Butt , James Morris , Oleg Nesterov , Kees Cook , Amol Grover , Thomas Gleixner , Jann Horn Cc: linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, Joel Fernandes , Madhuparna Bhowmik , "Paul E . McKenney" Subject: [PATCH] cred: Use RCU primitives to access RCU pointers Date: Tue, 28 Jan 2020 12:57:41 +0530 Message-Id: <20200128072740.21272-1-frextrite@gmail.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org task_struct.cred and task_struct.real_cred are annotated by __rcu, hence use rcu_access_pointer to access them. Fixes the following sparse errors: kernel/cred.c:144:9: error: incompatible types in comparison expression (different address spaces): kernel/cred.c:144:9: struct cred * kernel/cred.c:144:9: struct cred const [noderef] * kernel/cred.c:145:9: error: incompatible types in comparison expression (different address spaces): kernel/cred.c:145:9: struct cred * kernel/cred.c:145:9: struct cred const [noderef] * Signed-off-by: Amol Grover --- kernel/cred.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/cred.c b/kernel/cred.c index 809a985b1793..3043c8e1544d 100644 --- a/kernel/cred.c +++ b/kernel/cred.c @@ -141,8 +141,8 @@ void __put_cred(struct cred *cred) cred->magic = CRED_MAGIC_DEAD; cred->put_addr = __builtin_return_address(0); #endif - BUG_ON(cred == current->cred); - BUG_ON(cred == current->real_cred); + BUG_ON(cred == rcu_access_pointer(current->cred)); + BUG_ON(cred == rcu_access_pointer(current->real_cred)); if (cred->non_rcu) put_cred_rcu(&cred->rcu); -- 2.24.1