From patchwork Tue Jul 31 13:02:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 143186 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp5305788ljj; Tue, 31 Jul 2018 06:02:39 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd00nyatd79y70Qkvbo+Ph0vIWefEkg2eRioAX9Zqt+Xw0sRCZo8tHxwXGB10e+kigyytCd X-Received: by 2002:a62:455b:: with SMTP id s88-v6mr22140760pfa.203.1533042159309; Tue, 31 Jul 2018 06:02:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533042159; cv=none; d=google.com; s=arc-20160816; b=H22vKvxyfxTcdwZ0wzpBgaEfE6BG3JDBoYMS5KSDsplcchp3EgV/rrzS+Czto2i0Xm ptHtLnwMn5t0LqJnj0z3KYxBi4C7Y2iC/PkCF5pznTVzPoeFmrXW+GrPemqx3LkhvcAU a2QyYpxIEr8DP0KV1Bm9mjtVTAuijanzH0IzskV5f5GWtZOCur2+ZJmFnllJra7bk4oU V1dSnUKWWUETnf2twrNd93oZgRwMYsurC7js/CYWF+gci4fyr3yQ2E1AMg/U9M2Zmm0T +mNGiVxmug3ay086WSPRr2jsI0vFtVrn9vIyr9AW8qQkLVCDRpv1Id8924G+ShRpiIu0 nmWw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=BLylbrWFPqQ6/45540HtTrWBHCtjOTrCwrf/rexRW/c=; b=eq16K8VTZgmt7080xoCA1kxhCZQrH3ERlkRCHmDyaTL0Uijo879XyyuAqaWt8StgMZ ovRxA/7i/7iN/tIMw8/Tq1evWVKABFSNhToDvaeftgVi6h2Aq/Pu4laAxoVI/q1gkiQq mSG/ZcNEKZZ24iNRU+Nv8/kTr9eiCmnuIu1WOsl/AhUpND/UczzjOukp+mZcalamDqR9 XxkvYfPGw4FBLNEQBxMHY/2tgI6kJkPznLEzHDJvnJLWK8FZv4+XbH+nY0ErISo5jVRQ q47jTLrH0lQMZmc4Ate4vs4V28UTf60kL8JGvhwwcMxfZngmAFAVFpmYGUFbp8o2H8HQ kHbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="S1A/5s42"; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u35-v6si13052722pgl.237.2018.07.31.06.02.38; Tue, 31 Jul 2018 06:02:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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=@linaro.org header.s=google header.b="S1A/5s42"; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732233AbeGaOmw (ORCPT + 13 others); Tue, 31 Jul 2018 10:42:52 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:34170 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731962AbeGaOmv (ORCPT ); Tue, 31 Jul 2018 10:42:51 -0400 Received: by mail-pf1-f196.google.com with SMTP id k19-v6so6080712pfi.1 for ; Tue, 31 Jul 2018 06:02:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BLylbrWFPqQ6/45540HtTrWBHCtjOTrCwrf/rexRW/c=; b=S1A/5s42f+HuHG2Mzj0mBeV+hawXzC/Ic+/BZyAjFL6wWamv+KwL34R0j63wHro9kk Zjg8+bXcKQvQWh2BFpN/2gqe9+/qbco5bT5vHNyZrVeGbFjTLobQ1MLk902L7A9plPK+ AGt2vdOKgbAyS1bSyOA6fMk2CVhTievbHv4/U= 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=BLylbrWFPqQ6/45540HtTrWBHCtjOTrCwrf/rexRW/c=; b=NQIWkKRbEST2ApNt4IhsGDJocOY06D9hf/32CXu0+Eaawv048SAfRmUCWyaxW2BoTD tu7VlWz9ttnXfeOQBe0+mNICySSBWfIFSje4smDeJHCv+jG2bvi6N6DzFpSgkzgCcyX3 VEkf2FekwjYL0eqJWZ7mdR1VUgFjw17q82BvJyopkr/EhU4KnRTrmnDEgW4Jg9PRA6+I VqfgGr7WweNuAAcYJdtXjDXxDRtmh+fZI8qpvxa5h8YPpxFAxxapAHnIEr2sCvZAN33f 7sgXxACnuSwvHhl40+RR/4oHErf3oSvQDSr/Q2IG2DL1EJvc8vFUlJixI8mx1cNJihBG Et4w== X-Gm-Message-State: AOUpUlE12Gh6hac8qeTF++AqcC1/6xSEp8+XCnvt98SAJ4Z9Ux7AnhA3 2LwH1Xi5ToBMwzHo3/WHj1iKaw== X-Received: by 2002:a63:2013:: with SMTP id g19-v6mr20327938pgg.68.1533042157047; Tue, 31 Jul 2018 06:02:37 -0700 (PDT) Received: from localhost.localdomain ([106.51.18.123]) by smtp.gmail.com with ESMTPSA id f23-v6sm23048473pgl.5.2018.07.31.06.02.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 31 Jul 2018 06:02:35 -0700 (PDT) From: Amit Pundir To: Greg KH , Stable Cc: Lukas Wunner , =?utf-8?q?Ronald_Tschal=C3=A4r?= , Rob Herring , Sumit Semwal , Marcel Holtmann Subject: [PATCH for-4.14.y 4/5] Bluetooth: hci_serdev: Init hci_uart proto_lock to avoid oops Date: Tue, 31 Jul 2018 18:32:20 +0530 Message-Id: <1533042142-8681-4-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1533042142-8681-1-git-send-email-amit.pundir@linaro.org> References: <1533042142-8681-1-git-send-email-amit.pundir@linaro.org> MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Lukas Wunner commit d73e172816652772114827abaa2dbc053eecbbd7 upstream. John Stultz reports a boot time crash with the HiKey board (which uses hci_serdev) occurring in hci_uart_tx_wakeup(). That function is contained in hci_ldisc.c, but also called from the newer hci_serdev.c. It acquires the proto_lock in struct hci_uart and it turns out that we forgot to init the lock in the serdev code path, thus causing the crash. John bisected the crash to commit 67d2f8781b9f ("Bluetooth: hci_ldisc: Allow sleeping while proto locks are held"), but the issue was present before and the commit merely exposed it. (Perhaps by luck, the crash did not occur with rwlocks.) Init the proto_lock in the serdev code path to avoid the oops. Stack trace for posterity: Unable to handle kernel read from unreadable memory at 406f127000 [000000406f127000] user address but active_mm is swapper Internal error: Oops: 96000005 [#1] PREEMPT SMP Hardware name: HiKey Development Board (DT) Call trace: hci_uart_tx_wakeup+0x38/0x148 hci_uart_send_frame+0x28/0x38 hci_send_frame+0x64/0xc0 hci_cmd_work+0x98/0x110 process_one_work+0x134/0x330 worker_thread+0x130/0x468 kthread+0xf8/0x128 ret_from_fork+0x10/0x18 Link: https://lkml.org/lkml/2017/11/15/908 Reported-and-tested-by: John Stultz Cc: Ronald Tschalär Cc: Rob Herring Cc: Sumit Semwal Signed-off-by: Lukas Wunner Signed-off-by: Marcel Holtmann Signed-off-by: Amit Pundir --- Not applicable for 4.9.y, 4.4.y and 3.18.y drivers/bluetooth/hci_serdev.c | 1 + 1 file changed, 1 insertion(+) -- 2.7.4 diff --git a/drivers/bluetooth/hci_serdev.c b/drivers/bluetooth/hci_serdev.c index b725ac4f7ff6..52e6d4d1608e 100644 --- a/drivers/bluetooth/hci_serdev.c +++ b/drivers/bluetooth/hci_serdev.c @@ -304,6 +304,7 @@ int hci_uart_register_device(struct hci_uart *hu, hci_set_drvdata(hdev, hu); INIT_WORK(&hu->write_work, hci_uart_write_work); + percpu_init_rwsem(&hu->proto_lock); /* Only when vendor specific setup callback is provided, consider * the manufacturer information valid. This avoids filling in the