From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 522FEC282CE for ; Wed, 24 Apr 2019 17:23:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 032A321904 for ; Wed, 24 Apr 2019 17:23:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556126611; bh=2SErRLCqs0eCxuxqFUVpnt/ed7rfWF9J62ePGQWR4as=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=U2CAAxv0qyonpMT+zESULZfdjsE4y7/WP1Yv+gL6AQOkfMUuh1JKvjA153LSZ4hQX vUZQ8iCVPuBllbnELwyr/RtNFbFmv4ev3EdpCk/n0zBC91EzZspo1a5kGquIx2t5yo CDGH5PdzHSENLrpcPT0UEf3pVT8gqikCpPY3DMVc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389706AbfDXRX3 (ORCPT ); Wed, 24 Apr 2019 13:23:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:49142 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389682AbfDXRX0 (ORCPT ); Wed, 24 Apr 2019 13:23:26 -0400 Received: from localhost (62-193-50-229.as16211.net [62.193.50.229]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8CEA5205ED; Wed, 24 Apr 2019 17:23:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556126606; bh=2SErRLCqs0eCxuxqFUVpnt/ed7rfWF9J62ePGQWR4as=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hwrNJ8nUNg4p6tCT6tGDiae7dIBNZYjMRLbkEP+BNac/t72g1POVXmZAp4km2qFAF WB2BDE0D7cPP3E5LU4e/iERgbVJI3P/BQf1zJruWVkcU1GjpcejTm0xn5cMioUUqIG yd4a3t7ugy1e28wq7LXW0+cQP1NB0e5B+aD/d53w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jann Horn , Michal Hocko , Tejun Heo Subject: [PATCH 4.4 166/168] device_cgroup: fix RCU imbalance in error case Date: Wed, 24 Apr 2019 19:10:10 +0200 Message-Id: <20190424170933.101609252@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190424170923.452349382@linuxfoundation.org> References: <20190424170923.452349382@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jann Horn commit 0fcc4c8c044e117ac126ab6df4138ea9a67fa2a9 upstream. When dev_exception_add() returns an error (due to a failed memory allocation), make sure that we move the RCU preemption count back to where it was before we were called. We dropped the RCU read lock inside the loop body, so we can't just "break". sparse complains about this, too: $ make -s C=2 security/device_cgroup.o ./include/linux/rcupdate.h:647:9: warning: context imbalance in 'propagate_exception' - unexpected unlock Fixes: d591fb56618f ("device_cgroup: simplify cgroup tree walk in propagate_exception()") Cc: stable@vger.kernel.org Signed-off-by: Jann Horn Acked-by: Michal Hocko Signed-off-by: Tejun Heo Signed-off-by: Greg Kroah-Hartman --- security/device_cgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/security/device_cgroup.c +++ b/security/device_cgroup.c @@ -568,7 +568,7 @@ static int propagate_exception(struct de devcg->behavior == DEVCG_DEFAULT_ALLOW) { rc = dev_exception_add(devcg, ex); if (rc) - break; + return rc; } else { /* * in the other possible cases: