Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3327993imu; Sun, 11 Nov 2018 12:28:32 -0800 (PST) X-Google-Smtp-Source: AJdET5c8jOIkILM/qxNJavtYSnEnCrWuOiu9eW3TYYAa8ApM87E6Myxgofnc2BF3hu+1Kb9wVIxv X-Received: by 2002:a17:902:bb86:: with SMTP id m6mr6263pls.315.1541968112671; Sun, 11 Nov 2018 12:28:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541968112; cv=none; d=google.com; s=arc-20160816; b=etFZqS1lPu91Isv2uNdOna8hLfPQPanCeDf+r50d1m9uBUOqN6XIlj0ZJNNPS8WC8i 1hPppuYJjSS1aZSRoqt+eY446LO8PMn0xHOkCp2Q0/a07+kdEHzVadNyWHfORb1RiY++ 6WsgqLrYY0Vrkyte4yyTtJ6TS8sYd/10UTFm4konDAWx553TwpVEpyn+4iVvBD9GM6dW E2K5MAlJG4FCcriAAuRfq3QD1KjvPqr3Z1qNcJWP8aniYMD6FfVzCRf/I8oHtgDlXOHM gBFl4+/OWJp7GRxCItfxW1qcGDZy9c0H6Mz4GWCNrUe74UhJWvl0ob0Rr+nl7CBDJhoF Ye5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=doo7/eejfjHmla8RGDHM1/KT03skESRiN4XOEjUa5NU=; b=b01JiI/k6/rEuQU8ZmZe6cfMZ9TBebe/O4aj/Zd6jYry2pSoBF4POLvz9LzHyMZ1o/ mYaz1tyNz/1fDFNQ1gqYn2od+w+UyyBMSeBPwrKq97tunb9ebSMrvVcquOedvBXYDoFd CdV2/ZiwwIiOPWzN4YJ/WCLlbbZS85pNM/YQdwIt6Di75/AKQeqypxdEZ2lE3bhfNkB1 iZSnfB2PYQw9SJk07pGDGkgJ+GbvScXsI12RG/LXsgeyNGhXBYo8Q+JsiRwf0qZvgU2A PeXh01Ebyc5/diL4ZR9KHM/VzNNy7S4TZmdQAEquGP03tvQe2v/j0bIa8fh3qC/cDUZE V+DA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y35-v6si14051755pgl.14.2018.11.11.12.28.17; Sun, 11 Nov 2018 12:28:32 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730665AbeKLGR0 (ORCPT + 99 others); Mon, 12 Nov 2018 01:17:26 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:50772 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730488AbeKLFsZ (ORCPT ); Mon, 12 Nov 2018 00:48:25 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvsk-0000lM-6i; Sun, 11 Nov 2018 19:58:54 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsY-0001o1-S4; Sun, 11 Nov 2018 19:58:42 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "kernel test robot" , "David S. Miller" , "Dmitry Safonov" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 305/366] netlink: Don't shift with UB on nlk->ngroups In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.61-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Dmitry Safonov commit 61f4b23769f0cc72ae62c9a81cf08f0397d40da8 upstream. On i386 nlk->ngroups might be 32 or 0. Which leads to UB, resulting in hang during boot. Check for 0 ngroups and use (unsigned long long) as a type to shift. Fixes: 7acf9d4237c4 ("netlink: Do not subscribe to non-existent groups"). Reported-by: kernel test robot Signed-off-by: Dmitry Safonov Signed-off-by: David S. Miller Signed-off-by: Ben Hutchings --- net/netlink/af_netlink.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c @@ -927,7 +927,11 @@ static int netlink_bind(struct socket *s if (err) return err; } - groups &= (1UL << nlk->ngroups) - 1; + + if (nlk->ngroups == 0) + groups = 0; + else + groups &= (1ULL << nlk->ngroups) - 1; if (nlk->portid) if (nladdr->nl_pid != nlk->portid)