From patchwork Fri Sep 11 12:45:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 309771 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=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 C1A6FC2BC11 for ; Fri, 11 Sep 2020 17:34:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8AD912220E for ; Fri, 11 Sep 2020 17:34:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845671; bh=Gv2VQIAkxKkmOmKv38WwXifetJCw0j2sR9CStMuv2Os=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=t2/wK5g4pXNTaOJOh/9FyBqPuHSkfU6fEccbjsvIo6t0QnM/HCIaXsNzusGyOWfBy lU/lDNiUiNl388YbJhMZNy750I7lv1HpTe6q+EH499XUA37S1xv+TFCkQuywa8EREg OM0HYpcJv6TWEBn4cD4UVlhNYgTRuXUCoS3I5uK4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726508AbgIKRe2 (ORCPT ); Fri, 11 Sep 2020 13:34:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:49242 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726042AbgIKMye (ORCPT ); Fri, 11 Sep 2020 08:54:34 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 C34EA2220D; Fri, 11 Sep 2020 12:53:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828821; bh=Gv2VQIAkxKkmOmKv38WwXifetJCw0j2sR9CStMuv2Os=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zqh7GBLGZgV7Spwd9v5kWvIu2sqPzCB9BuWLUXR2vC1LXQbhgM8Q/vZBk/FgrozeH oi55yMO3zYGh//NjceQ8GInhcU4Q+/k2fWAkN5F7oxd0Sj9+6ZdALM571QWhAWIXK/ gfmE6B5Y3VD1YLzDv0ra+jJXUta/bBXp1kN1ipN8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Zyngier , Benjamin Tissoires Subject: [PATCH 4.4 02/62] HID: core: Sanitize event code and type when mapping input Date: Fri, 11 Sep 2020 14:45:45 +0200 Message-Id: <20200911122502.519682420@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Marc Zyngier commit 35556bed836f8dc07ac55f69c8d17dce3e7f0e25 upstream. When calling into hid_map_usage(), the passed event code is blindly stored as is, even if it doesn't fit in the associated bitmap. This event code can come from a variety of sources, including devices masquerading as input devices, only a bit more "programmable". Instead of taking the event code at face value, check that it actually fits the corresponding bitmap, and if it doesn't: - spit out a warning so that we know which device is acting up - NULLify the bitmap pointer so that we catch unexpected uses Code paths that can make use of untrusted inputs can now check that the mapping was indeed correct and bail out if not. Cc: stable@vger.kernel.org Signed-off-by: Marc Zyngier Signed-off-by: Benjamin Tissoires Signed-off-by: Greg Kroah-Hartman --- drivers/hid/hid-input.c | 4 ++++ drivers/hid/hid-multitouch.c | 2 ++ include/linux/hid.h | 42 +++++++++++++++++++++++++++++------------- 3 files changed, 35 insertions(+), 13 deletions(-) --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c @@ -994,6 +994,10 @@ static void hidinput_configure_usage(str } mapped: + /* Mapping failed, bail out */ + if (!bit) + return; + if (device->driver->input_mapped && device->driver->input_mapped(device, hidinput, field, usage, &bit, &max) < 0) { --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c @@ -569,6 +569,8 @@ static int mt_touch_input_mapping(struct case HID_UP_BUTTON: code = BTN_MOUSE + ((usage->hid - 1) & HID_USAGE); hid_map_usage(hi, usage, bit, max, EV_KEY, code); + if (!*bit) + return -1; input_set_capability(hi->input, EV_KEY, code); return 1; --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -866,34 +866,49 @@ static inline void hid_device_io_stop(st * @max: maximal valid usage->code to consider later (out parameter) * @type: input event type (EV_KEY, EV_REL, ...) * @c: code which corresponds to this usage and type + * + * The value pointed to by @bit will be set to NULL if either @type is + * an unhandled event type, or if @c is out of range for @type. This + * can be used as an error condition. */ static inline void hid_map_usage(struct hid_input *hidinput, struct hid_usage *usage, unsigned long **bit, int *max, - __u8 type, __u16 c) + __u8 type, unsigned int c) { struct input_dev *input = hidinput->input; - - usage->type = type; - usage->code = c; + unsigned long *bmap = NULL; + unsigned int limit = 0; switch (type) { case EV_ABS: - *bit = input->absbit; - *max = ABS_MAX; + bmap = input->absbit; + limit = ABS_MAX; break; case EV_REL: - *bit = input->relbit; - *max = REL_MAX; + bmap = input->relbit; + limit = REL_MAX; break; case EV_KEY: - *bit = input->keybit; - *max = KEY_MAX; + bmap = input->keybit; + limit = KEY_MAX; break; case EV_LED: - *bit = input->ledbit; - *max = LED_MAX; + bmap = input->ledbit; + limit = LED_MAX; break; } + + if (unlikely(c > limit || !bmap)) { + pr_warn_ratelimited("%s: Invalid code %d type %d\n", + input->name, c, type); + *bit = NULL; + return; + } + + usage->type = type; + usage->code = c; + *max = limit; + *bit = bmap; } /** @@ -907,7 +922,8 @@ static inline void hid_map_usage_clear(s __u8 type, __u16 c) { hid_map_usage(hidinput, usage, bit, max, type, c); - clear_bit(c, *bit); + if (*bit) + clear_bit(usage->code, *bit); } /** From patchwork Fri Sep 11 12:45:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 264028 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=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 DAA98C43461 for ; Fri, 11 Sep 2020 17:32:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A3023221EB for ; Fri, 11 Sep 2020 17:32:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845573; bh=kruzOKCTPxnOTx70+MyuJMTS8UQqa8dxkdaLKKGd+l8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=JGfMJTZjbN7ObqdhW7YOYAkqyyA2z3RFn9oxLf9BQ3bFCDcIG82qoBMa+CUdvdWic A5n4FyMK4glhyKtP2t3nE3brwWBfXClQynTyEP0URNnYCAX5OhJDpD5DJAshEdV56C MzPs2N/xpYU9L4ujtkBxu+9rT/6mgfa6tYR7ZY0o= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726503AbgIKRcr (ORCPT ); Fri, 11 Sep 2020 13:32:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:49250 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726046AbgIKMye (ORCPT ); Fri, 11 Sep 2020 08:54:34 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 3744E22210; Fri, 11 Sep 2020 12:53:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828828; bh=kruzOKCTPxnOTx70+MyuJMTS8UQqa8dxkdaLKKGd+l8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iQxqpltcT7xD59DX+eek2pazPNtzFt7bVq+FJrsQy0iU3NiqGeSOYA3xaGGEx7OEb 0M4pEpeDpOOmJVRkWX0d7DJy5HkEWWrKo+7iLFxELU545oKAY8J0d4KFSfCCK+B7P1 hgPc+0zrUn8nsvRoxMQtGCveCH7Roc9KHhNUiaOg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kim Phillips , Adrian Hunter , Alexander Shishkin , Alexey Budankov , Ian Rogers , Jin Yao , Jiri Olsa , Mark Rutland , Namhyung Kim , Paul Clarke , Peter Zijlstra , Stephane Eranian , Tony Jones , Arnaldo Carvalho de Melo Subject: [PATCH 4.4 03/62] perf record/stat: Explicitly call out event modifiers in the documentation Date: Fri, 11 Sep 2020 14:45:46 +0200 Message-Id: <20200911122502.568324530@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Kim Phillips commit e48a73a312ebf19cc3d72aa74985db25c30757c1 upstream. Event modifiers are not mentioned in the perf record or perf stat manpages. Add them to orient new users more effectively by pointing them to the perf list manpage for details. Fixes: 2055fdaf8703 ("perf list: Document precise event sampling for AMD IBS") Signed-off-by: Kim Phillips Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Alexey Budankov Cc: Ian Rogers Cc: Jin Yao Cc: Jiri Olsa Cc: Mark Rutland Cc: Namhyung Kim Cc: Paul Clarke Cc: Peter Zijlstra Cc: Stephane Eranian Cc: Tony Jones Cc: stable@vger.kernel.org Link: http://lore.kernel.org/lkml/20200901215853.276234-1-kim.phillips@amd.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Greg Kroah-Hartman --- tools/perf/Documentation/perf-record.txt | 4 ++++ tools/perf/Documentation/perf-stat.txt | 4 ++++ 2 files changed, 8 insertions(+) --- a/tools/perf/Documentation/perf-record.txt +++ b/tools/perf/Documentation/perf-record.txt @@ -33,6 +33,10 @@ OPTIONS - a raw PMU event (eventsel+umask) in the form of rNNN where NNN is a hexadecimal event descriptor. + - a symbolic or raw PMU event followed by an optional colon + and a list of event modifiers, e.g., cpu-cycles:p. See the + linkperf:perf-list[1] man page for details on event modifiers. + - a symbolically formed PMU event like 'pmu/param1=0x3,param2/' where 'param1', 'param2', etc are defined as formats for the PMU in /sys/bus/event_sources/devices//format/*. --- a/tools/perf/Documentation/perf-stat.txt +++ b/tools/perf/Documentation/perf-stat.txt @@ -32,6 +32,10 @@ OPTIONS - a raw PMU event (eventsel+umask) in the form of rNNN where NNN is a hexadecimal event descriptor. + - a symbolic or raw PMU event followed by an optional colon + and a list of event modifiers, e.g., cpu-cycles:p. See the + linkperf:perf-list[1] man page for details on event modifiers. + - a symbolically formed event like 'pmu/param1=0x3,param2/' where param1 and param2 are defined as formats for the PMU in /sys/bus/event_sources/devices//format/* From patchwork Fri Sep 11 12:45:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 309849 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=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 CF1DBC43461 for ; Fri, 11 Sep 2020 12:55:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8880E22225 for ; Fri, 11 Sep 2020 12:55:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828939; bh=oGr46qlLv8X6ikVTrbl44cD9Uet5OSlJxQACmUVeejw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=0Zebsnhl/uuT1iXRD/OabP474qoXKAuWQjKkz6Ts+z3/ekFDrMh/XnaKP8eoRhFdL /+jPGf+6A8zmk63f0LxGxLgyQg8STFKPgDAqPvfJySO0SatvToFVHCBZ1m6rtFedf1 eOqrbosdGz0wLubpKSmy5xnTlYQSCy+UT5wsz3j0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726071AbgIKMzh (ORCPT ); Fri, 11 Sep 2020 08:55:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:48794 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726047AbgIKMye (ORCPT ); Fri, 11 Sep 2020 08:54:34 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 1141E2075E; Fri, 11 Sep 2020 12:53:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828831; bh=oGr46qlLv8X6ikVTrbl44cD9Uet5OSlJxQACmUVeejw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F9i4AChHmpor9FFYhbdtZsrYXOTIRQM7rKzrdZbohrEN/NRdO+uXHXff0FPRMvHb0 YZo033JTkMj7jZ6IyCCSqGUeDL0xBzEdkPOVq8MRYz4wy6r3C3pvsIvWw6JonWcpnr FBENyfqAdg8fcKGtGIASBvmur4Y9y3Sc5cvQwEzw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mel Gorman , Vlastimil Babka , Jesper Dangaard Brouer , Andrew Morton , Linus Torvalds , Daniel Wagner Subject: [PATCH 4.4 04/62] mm, page_alloc: remove unnecessary variable from free_pcppages_bulk Date: Fri, 11 Sep 2020 14:45:47 +0200 Message-Id: <20200911122502.615839890@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Mel Gorman commit e5b31ac2ca2cd0cf6bf2fcbb708ed01466c89aaa upstream. The original count is never reused so it can be removed. Signed-off-by: Mel Gorman Acked-by: Vlastimil Babka Cc: Jesper Dangaard Brouer Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds [dwagner: update context] Signed-off-by: Daniel Wagner Signed-off-by: Greg Kroah-Hartman --- mm/page_alloc.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -835,7 +835,6 @@ static void free_pcppages_bulk(struct zo { int migratetype = 0; int batch_free = 0; - int to_free = count; unsigned long nr_scanned; spin_lock(&zone->lock); @@ -848,7 +847,7 @@ static void free_pcppages_bulk(struct zo * below while (list_empty(list)) loop. */ count = min(pcp->count, count); - while (to_free) { + while (count) { struct page *page; struct list_head *list; @@ -868,7 +867,7 @@ static void free_pcppages_bulk(struct zo /* This is the only non-empty list. Free them all. */ if (batch_free == MIGRATE_PCPTYPES) - batch_free = to_free; + batch_free = count; do { int mt; /* migratetype of the to-be-freed page */ @@ -886,7 +885,7 @@ static void free_pcppages_bulk(struct zo __free_one_page(page, page_to_pfn(page), zone, 0, mt); trace_mm_page_pcpu_drain(page, 0, mt); - } while (--to_free && --batch_free && !list_empty(list)); + } while (--count && --batch_free && !list_empty(list)); } spin_unlock(&zone->lock); } From patchwork Fri Sep 11 12:45:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 264108 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 02098C433E2 for ; Fri, 11 Sep 2020 12:55:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A125F22225 for ; Fri, 11 Sep 2020 12:55:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828938; bh=T6IXcbTZtskK1L7YVm0OiBCn2pW7sfMMpBbYy0pK7wk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=sEVA23lcb6pQYUTZzHVxIXJd4LqH9p4bf+wo1vR8iC9O0849lfif5ELCo78aWW5p+ BJ4t7ujimF1LhVZO1N5aIQnUd3vDw+54FQz7MAExAPJ4ok18za6P/tIZ/UymP5qsci PnklieCRqSSHCYOZUXjD1oguTtOQ7DlQa3Mr6Zxs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726067AbgIKMzg (ORCPT ); Fri, 11 Sep 2020 08:55:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:48796 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726048AbgIKMye (ORCPT ); Fri, 11 Sep 2020 08:54:34 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 A5A5022225; Fri, 11 Sep 2020 12:53:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828834; bh=T6IXcbTZtskK1L7YVm0OiBCn2pW7sfMMpBbYy0pK7wk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zTyf7e3XSzfSf/OknASKWycUoEtX0M5E95kxXpCgWVWr3MKI2hERscvbWcjvYgHUn f+Lz3PvSibjaXk+fhBaBbTv1vRV0LsRVzOVh6BCtvFT2J6rcIr397dv1KYkJeFuown JXWGk39DfFF+Xlv8KmAHev/61we8Q4Dod7bkZDDo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tom Rix , Henrik Rydberg , Guenter Roeck , Sasha Levin Subject: [PATCH 4.4 05/62] hwmon: (applesmc) check status earlier. Date: Fri, 11 Sep 2020 14:45:48 +0200 Message-Id: <20200911122502.669077595@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Tom Rix [ Upstream commit cecf7560f00a8419396a2ed0f6e5d245ccb4feac ] clang static analysis reports this representative problem applesmc.c:758:10: warning: 1st function call argument is an uninitialized value left = be16_to_cpu(*(__be16 *)(buffer + 6)) >> 2; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ buffer is filled by the earlier call ret = applesmc_read_key(LIGHT_SENSOR_LEFT_KEY, ... This problem is reported because a goto skips the status check. Other similar problems use data from applesmc_read_key before checking the status. So move the checks to before the use. Signed-off-by: Tom Rix Reviewed-by: Henrik Rydberg Link: https://lore.kernel.org/r/20200820131932.10590-1-trix@redhat.com Signed-off-by: Guenter Roeck Signed-off-by: Sasha Levin --- drivers/hwmon/applesmc.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c index 0af7fd311979d..587fc5c686b3c 100644 --- a/drivers/hwmon/applesmc.c +++ b/drivers/hwmon/applesmc.c @@ -758,15 +758,18 @@ static ssize_t applesmc_light_show(struct device *dev, } ret = applesmc_read_key(LIGHT_SENSOR_LEFT_KEY, buffer, data_length); + if (ret) + goto out; /* newer macbooks report a single 10-bit bigendian value */ if (data_length == 10) { left = be16_to_cpu(*(__be16 *)(buffer + 6)) >> 2; goto out; } left = buffer[2]; + + ret = applesmc_read_key(LIGHT_SENSOR_RIGHT_KEY, buffer, data_length); if (ret) goto out; - ret = applesmc_read_key(LIGHT_SENSOR_RIGHT_KEY, buffer, data_length); right = buffer[2]; out: @@ -814,12 +817,11 @@ static ssize_t applesmc_show_fan_speed(struct device *dev, sprintf(newkey, fan_speed_fmt[to_option(attr)], to_index(attr)); ret = applesmc_read_key(newkey, buffer, 2); - speed = ((buffer[0] << 8 | buffer[1]) >> 2); - if (ret) return ret; - else - return snprintf(sysfsbuf, PAGE_SIZE, "%u\n", speed); + + speed = ((buffer[0] << 8 | buffer[1]) >> 2); + return snprintf(sysfsbuf, PAGE_SIZE, "%u\n", speed); } static ssize_t applesmc_store_fan_speed(struct device *dev, @@ -854,12 +856,11 @@ static ssize_t applesmc_show_fan_manual(struct device *dev, u8 buffer[2]; ret = applesmc_read_key(FANS_MANUAL, buffer, 2); - manual = ((buffer[0] << 8 | buffer[1]) >> to_index(attr)) & 0x01; - if (ret) return ret; - else - return snprintf(sysfsbuf, PAGE_SIZE, "%d\n", manual); + + manual = ((buffer[0] << 8 | buffer[1]) >> to_index(attr)) & 0x01; + return snprintf(sysfsbuf, PAGE_SIZE, "%d\n", manual); } static ssize_t applesmc_store_fan_manual(struct device *dev, @@ -875,10 +876,11 @@ static ssize_t applesmc_store_fan_manual(struct device *dev, return -EINVAL; ret = applesmc_read_key(FANS_MANUAL, buffer, 2); - val = (buffer[0] << 8 | buffer[1]); if (ret) goto out; + val = (buffer[0] << 8 | buffer[1]); + if (input) val = val | (0x01 << to_index(attr)); else @@ -954,13 +956,12 @@ static ssize_t applesmc_key_count_show(struct device *dev, u32 count; ret = applesmc_read_key(KEY_COUNT_KEY, buffer, 4); - count = ((u32)buffer[0]<<24) + ((u32)buffer[1]<<16) + - ((u32)buffer[2]<<8) + buffer[3]; - if (ret) return ret; - else - return snprintf(sysfsbuf, PAGE_SIZE, "%d\n", count); + + count = ((u32)buffer[0]<<24) + ((u32)buffer[1]<<16) + + ((u32)buffer[2]<<8) + buffer[3]; + return snprintf(sysfsbuf, PAGE_SIZE, "%d\n", count); } static ssize_t applesmc_key_at_index_read_show(struct device *dev, From patchwork Fri Sep 11 12:45:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 309770 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, 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 14EA6C433E2 for ; Fri, 11 Sep 2020 17:35:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BB162221E7 for ; Fri, 11 Sep 2020 17:35:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845750; bh=wo/9jfUs/QsfWHN0aWZWBzIi8v87Qpm/6HXW9VcwsdI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=HIcE0DHPUAIp0/mln3cBJHnYBa/dnZkzeLutqPk2616N6ntYl5deMuGBHwaCdpjG2 hKYt0nYxPnvv0v6inZ8pyazHaW14uKU8KftctZz4HQLC59MwxsfgzS8ax3am5lse1m ocXU2Mg2Zt5Ge3YDaoIusQ954TWCBnHJHDPbHOpo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726230AbgIKRe0 (ORCPT ); Fri, 11 Sep 2020 13:34:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:49260 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726050AbgIKMye (ORCPT ); Fri, 11 Sep 2020 08:54:34 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 4187022226; Fri, 11 Sep 2020 12:53:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828836; bh=wo/9jfUs/QsfWHN0aWZWBzIi8v87Qpm/6HXW9VcwsdI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j9VgQ+YiaSOt3ivWG0/baDmBcrg/vyXBC8xyq7QCpPc2L+K12KWYn4rIK0IjL0R7v OeTIwbngJtV8nSaTA6pzX2n2Mm/UlZdtArOHqUZFK5LoS6mJiUOcBmCZwkZXSxzUoP AR1c0dOlz1GEKMsNbbQnTCuOj/P60IjcPEfZ1Pto= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jeff Layton , Ilya Dryomov , Sasha Levin Subject: [PATCH 4.4 06/62] ceph: dont allow setlease on cephfs Date: Fri, 11 Sep 2020 14:45:49 +0200 Message-Id: <20200911122502.716707091@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jeff Layton [ Upstream commit 496ceaf12432b3d136dcdec48424312e71359ea7 ] Leases don't currently work correctly on kcephfs, as they are not broken when caps are revoked. They could eventually be implemented similarly to how we did them in libcephfs, but for now don't allow them. [ idryomov: no need for simple_nosetlease() in ceph_dir_fops and ceph_snapdir_fops ] Signed-off-by: Jeff Layton Reviewed-by: Ilya Dryomov Signed-off-by: Ilya Dryomov Signed-off-by: Sasha Levin --- fs/ceph/file.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/ceph/file.c b/fs/ceph/file.c index c8222bfe1e566..3e6ebe40f06fb 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -1433,6 +1433,7 @@ const struct file_operations ceph_file_fops = { .mmap = ceph_mmap, .fsync = ceph_fsync, .lock = ceph_lock, + .setlease = simple_nosetlease, .flock = ceph_flock, .splice_read = generic_file_splice_read, .splice_write = iter_file_splice_write, From patchwork Fri Sep 11 12:45:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 309774 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham 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 75202C433E2 for ; Fri, 11 Sep 2020 17:32:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3D8CF221EB for ; Fri, 11 Sep 2020 17:32:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845571; bh=fCVdosZO1rkBp7kMGjgfF4fYJai1euR5FjdmMj83NNk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=fqrfeXwQEMfY/LnilM7L2MetM9oXGzOP/qNLQZqfcQqFTXRnFaOAEbODEmEfNWuHV L0JEMVTRMTzap9M6MOmCPPD12XprTIrFpkeFMBv5ucYtj4JTrb6/KrNk2T7ow6IGjP hEhA2Nzlduul6UanK0j7mZqW2tDXjvLhBSHzWkYg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726486AbgIKRcr (ORCPT ); Fri, 11 Sep 2020 13:32:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:49262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726051AbgIKMyf (ORCPT ); Fri, 11 Sep 2020 08:54:35 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 E319C22228; Fri, 11 Sep 2020 12:53:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828839; bh=fCVdosZO1rkBp7kMGjgfF4fYJai1euR5FjdmMj83NNk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vz6YANq/QZqvWNXWGI9T5fvtQMAvUVW+3qO8p9GhJBjw84T8+BgJnG7Z7dHUD/uqH N+CP4+Wvkp1O/XaBGLayTXEmFcpp2tBtyZWEoBq3r4Alavk4COwnmPSxqrHFytl7g4 A3y6YafVcVCCC5NlzAFjEVQV5/p5+2+9HCWzx5Cs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sven Schnelle , Vasily Gorbik , Sasha Levin Subject: [PATCH 4.4 07/62] s390: dont trace preemption in percpu macros Date: Fri, 11 Sep 2020 14:45:50 +0200 Message-Id: <20200911122502.765956008@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Sven Schnelle [ Upstream commit 1196f12a2c960951d02262af25af0bb1775ebcc2 ] Since commit a21ee6055c30 ("lockdep: Change hardirq{s_enabled,_context} to per-cpu variables") the lockdep code itself uses percpu variables. This leads to recursions because the percpu macros are calling preempt_enable() which might call trace_preempt_on(). Signed-off-by: Sven Schnelle Reviewed-by: Vasily Gorbik Signed-off-by: Vasily Gorbik Signed-off-by: Sasha Levin --- arch/s390/include/asm/percpu.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/arch/s390/include/asm/percpu.h b/arch/s390/include/asm/percpu.h index 6d6556ca24aa2..f715419a72cf0 100644 --- a/arch/s390/include/asm/percpu.h +++ b/arch/s390/include/asm/percpu.h @@ -28,7 +28,7 @@ typedef typeof(pcp) pcp_op_T__; \ pcp_op_T__ old__, new__, prev__; \ pcp_op_T__ *ptr__; \ - preempt_disable(); \ + preempt_disable_notrace(); \ ptr__ = raw_cpu_ptr(&(pcp)); \ prev__ = *ptr__; \ do { \ @@ -36,7 +36,7 @@ new__ = old__ op (val); \ prev__ = cmpxchg(ptr__, old__, new__); \ } while (prev__ != old__); \ - preempt_enable(); \ + preempt_enable_notrace(); \ new__; \ }) @@ -67,7 +67,7 @@ typedef typeof(pcp) pcp_op_T__; \ pcp_op_T__ val__ = (val); \ pcp_op_T__ old__, *ptr__; \ - preempt_disable(); \ + preempt_disable_notrace(); \ ptr__ = raw_cpu_ptr(&(pcp)); \ if (__builtin_constant_p(val__) && \ ((szcast)val__ > -129) && ((szcast)val__ < 128)) { \ @@ -83,7 +83,7 @@ : [val__] "d" (val__) \ : "cc"); \ } \ - preempt_enable(); \ + preempt_enable_notrace(); \ } #define this_cpu_add_4(pcp, val) arch_this_cpu_add(pcp, val, "laa", "asi", int) @@ -94,14 +94,14 @@ typedef typeof(pcp) pcp_op_T__; \ pcp_op_T__ val__ = (val); \ pcp_op_T__ old__, *ptr__; \ - preempt_disable(); \ + preempt_disable_notrace(); \ ptr__ = raw_cpu_ptr(&(pcp)); \ asm volatile( \ op " %[old__],%[val__],%[ptr__]\n" \ : [old__] "=d" (old__), [ptr__] "+Q" (*ptr__) \ : [val__] "d" (val__) \ : "cc"); \ - preempt_enable(); \ + preempt_enable_notrace(); \ old__ + val__; \ }) @@ -113,14 +113,14 @@ typedef typeof(pcp) pcp_op_T__; \ pcp_op_T__ val__ = (val); \ pcp_op_T__ old__, *ptr__; \ - preempt_disable(); \ + preempt_disable_notrace(); \ ptr__ = raw_cpu_ptr(&(pcp)); \ asm volatile( \ op " %[old__],%[val__],%[ptr__]\n" \ : [old__] "=d" (old__), [ptr__] "+Q" (*ptr__) \ : [val__] "d" (val__) \ : "cc"); \ - preempt_enable(); \ + preempt_enable_notrace(); \ } #define this_cpu_and_4(pcp, val) arch_this_cpu_to_op(pcp, val, "lan") @@ -135,10 +135,10 @@ typedef typeof(pcp) pcp_op_T__; \ pcp_op_T__ ret__; \ pcp_op_T__ *ptr__; \ - preempt_disable(); \ + preempt_disable_notrace(); \ ptr__ = raw_cpu_ptr(&(pcp)); \ ret__ = cmpxchg(ptr__, oval, nval); \ - preempt_enable(); \ + preempt_enable_notrace(); \ ret__; \ }) @@ -151,10 +151,10 @@ ({ \ typeof(pcp) *ptr__; \ typeof(pcp) ret__; \ - preempt_disable(); \ + preempt_disable_notrace(); \ ptr__ = raw_cpu_ptr(&(pcp)); \ ret__ = xchg(ptr__, nval); \ - preempt_enable(); \ + preempt_enable_notrace(); \ ret__; \ }) @@ -170,11 +170,11 @@ typeof(pcp1) *p1__; \ typeof(pcp2) *p2__; \ int ret__; \ - preempt_disable(); \ + preempt_disable_notrace(); \ p1__ = raw_cpu_ptr(&(pcp1)); \ p2__ = raw_cpu_ptr(&(pcp2)); \ ret__ = __cmpxchg_double(p1__, p2__, o1__, o2__, n1__, n2__); \ - preempt_enable(); \ + preempt_enable_notrace(); \ ret__; \ }) From patchwork Fri Sep 11 12:45:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 309848 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 5C6DBC43461 for ; Fri, 11 Sep 2020 12:56:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E889E2222C for ; Fri, 11 Sep 2020 12:56:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828994; bh=+FACLGKqlSwMrilGYEKodDj+1GCcMCrZAibjV4DcC8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=HHjI8dQuk+8/NEJNbNMrc5nttsaZjTx3w75+WcEtwth2AD5aTWbdzSPDCnPxpQR7i 0e5Karswz2fSc1f2O2w0WE2LMj61lmGV3NAPQn+yf6+8uJxBIYY7pXnh193WlDb3fs cdpPVQYZk+EwnOxnp4/1dWTHA+EZ7QxASO9W5K88= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725949AbgIKM42 (ORCPT ); Fri, 11 Sep 2020 08:56:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:49206 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725980AbgIKMy4 (ORCPT ); Fri, 11 Sep 2020 08:54:56 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 AA38F22229; Fri, 11 Sep 2020 12:54:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828842; bh=+FACLGKqlSwMrilGYEKodDj+1GCcMCrZAibjV4DcC8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BwQl0wOOmtG7L8o82R9Y56Cq5vTqBFV4eyQk/0KYarXUghAiqe6Yxj1o7igqRYjVH RTVVmMJJ3o5P9b+fR9SzLCjz9s/QmFvlptNbG4x3EVz/c58i4X8X6IVZxQS8ovlAMB TO8TM/se3D+T55SKUBFQGc7AwQzvoABnLxor1efI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Simon Leiner , Stefano Stabellini , Juergen Gross , Sasha Levin Subject: [PATCH 4.4 08/62] xen/xenbus: Fix granting of vmallocd memory Date: Fri, 11 Sep 2020 14:45:51 +0200 Message-Id: <20200911122502.815647141@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Simon Leiner [ Upstream commit d742db70033c745e410523e00522ee0cfe2aa416 ] On some architectures (like ARM), virt_to_gfn cannot be used for vmalloc'd memory because of its reliance on virt_to_phys. This patch introduces a check for vmalloc'd addresses and obtains the PFN using vmalloc_to_pfn in that case. Signed-off-by: Simon Leiner Reviewed-by: Stefano Stabellini Link: https://lore.kernel.org/r/20200825093153.35500-1-simon@leiner.me Signed-off-by: Juergen Gross Signed-off-by: Sasha Levin --- drivers/xen/xenbus/xenbus_client.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/xen/xenbus/xenbus_client.c b/drivers/xen/xenbus/xenbus_client.c index df27cefb2fa35..266f446ba331c 100644 --- a/drivers/xen/xenbus/xenbus_client.c +++ b/drivers/xen/xenbus/xenbus_client.c @@ -384,8 +384,14 @@ int xenbus_grant_ring(struct xenbus_device *dev, void *vaddr, int i, j; for (i = 0; i < nr_pages; i++) { - err = gnttab_grant_foreign_access(dev->otherend_id, - virt_to_gfn(vaddr), 0); + unsigned long gfn; + + if (is_vmalloc_addr(vaddr)) + gfn = pfn_to_gfn(vmalloc_to_pfn(vaddr)); + else + gfn = virt_to_gfn(vaddr); + + err = gnttab_grant_foreign_access(dev->otherend_id, gfn, 0); if (err < 0) { xenbus_dev_fatal(dev, err, "granting access to ring page"); From patchwork Fri Sep 11 12:45:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 249722 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ecf:0:0:0:0 with SMTP id i15csp1631517ilk; Fri, 11 Sep 2020 05:56:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRK0FZ9hIDOnFiWv7v0a3bAXDiIiWnNITXcJ5BvrJ994RGcdVD3qb6ZqMm62S1gvEYyh1h X-Received: by 2002:a50:d802:: with SMTP id o2mr1893345edj.152.1599828991900; Fri, 11 Sep 2020 05:56:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599828991; cv=none; d=google.com; s=arc-20160816; b=hx7JCMEUQ9wJC0pJTt12JEQlTjPxX3kstqimqehSRAXxgCPNQtyx089HNX3EhCUEr2 NJ+bGfgZOO/xh2kgJZohoB438uXM+Zim92dOtFeTeCCkHwWOE8XmBsKT+JRTdxvSSX+9 JLvF5F5vu05LyF6a+GzqaSNsEemTv4Q6KYXRjKI1rOvryTWZVuag8uOmc9DnuB8gG7Hk SJ+RK33OSDHw1ulcC9Nb92YfnsNMWj+YjJUouqPR1Y4sFrw5+QiYU52rvA0hW0b+irv6 rf5hizDdK2H9DeX8zBc15s3/UB0UxIAEWuFtaGVk53arwpmV02KxEdedOtA/8gVV5dR5 Vd+Q== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lbLTtCynfayH2/2ifxSR2CeQXtvhYXHOMLUK6C405b0=; b=BRQZs6Rv0qvG8gh+OHi7xDH2U6SORQZpMmZcglHZTNUan6bKl5h4g2SGC6u5m8YNrk GzFiHw+T3ApZubBHYZ7ER3wNt0AGJ0DlLxoMZxrdIoQeF6QzxH6AThC/RVRpd6USKVkq BmQ5sCZmH+bOJNmuHXzvaSJw5Z/C23xFz+b5s1WGniBugNJOsLmYSiLkFBDaC+8ruvql MYmRmuvJHerDRHjgfGZv2/ra+rp5H1cp7IwuEYw/pJnWk+bhvlTpW5werfEdc82ddRH6 1j6VKKaHbpmhseCiLIqZPCZyQdFt41yH6mks69/6Lhlyx1J/B0/srBginjxYc8RmEKxj t7Sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=a8S4YYZw; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x23si1197590ejc.63.2020.09.11.05.56.31; Fri, 11 Sep 2020 05:56:31 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=a8S4YYZw; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726077AbgIKM4W (ORCPT + 15 others); Fri, 11 Sep 2020 08:56:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:49480 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726014AbgIKMyz (ORCPT ); Fri, 11 Sep 2020 08:54:55 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 58B9D2222B; Fri, 11 Sep 2020 12:54:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828844; bh=751jnFFiPM7Rz+YvYy29f9LhzmeeTfNIcCziFRBD/40=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a8S4YYZwBmoM16gSK3nqYYpW00eNrTiAMU7kNMNaphllIDgfu4m7Gn4zIoZc6XuLs pJOMrb2nOvIRZBMLIK5cApDWWFEuDBqnNRgJ0CLcGZ1Chy7WY0OoGld2nu/mhUE9rg ADr4MXntVtkKJEY1BxzPZinfeyI5n+b0jFIiivvc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Ujfalusi , Vinod Koul , Sasha Levin Subject: [PATCH 4.4 09/62] dmaengine: of-dma: Fix of_dma_router_xlates of_dma_xlate handling Date: Fri, 11 Sep 2020 14:45:52 +0200 Message-Id: <20200911122502.855779713@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Peter Ujfalusi [ Upstream commit 5b2aa9f918f6837ae943557f8cec02c34fcf80e7 ] of_dma_xlate callback can return ERR_PTR as well NULL in case of failure. If error code is returned (not NULL) then the route should be released and the router should not be registered for the channel. Fixes: 56f13c0d9524c ("dmaengine: of_dma: Support for DMA routers") Signed-off-by: Peter Ujfalusi Link: https://lore.kernel.org/r/20200806104928.25975-1-peter.ujfalusi@ti.com Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/dma/of-dma.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.25.1 diff --git a/drivers/dma/of-dma.c b/drivers/dma/of-dma.c index 1e1f2986eba8f..86c591481dfe9 100644 --- a/drivers/dma/of-dma.c +++ b/drivers/dma/of-dma.c @@ -72,12 +72,12 @@ static struct dma_chan *of_dma_router_xlate(struct of_phandle_args *dma_spec, return NULL; chan = ofdma_target->of_dma_xlate(&dma_spec_target, ofdma_target); - if (chan) { - chan->router = ofdma->dma_router; - chan->route_data = route_data; - } else { + if (IS_ERR_OR_NULL(chan)) { ofdma->dma_router->route_free(ofdma->dma_router->dev, route_data); + } else { + chan->router = ofdma->dma_router; + chan->route_data = route_data; } /* From patchwork Fri Sep 11 12:45:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 309767 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, 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 F085CC43461 for ; Fri, 11 Sep 2020 17:36:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A765D221EF for ; Fri, 11 Sep 2020 17:36:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845817; bh=DFDRKke5vROvEQcUa5OL+LpykKysm/Lz5k45FUhZR8M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=aN5u93xuKHnldPXPo2Amj2APqzTCv3el48coi36jGZ0xmmoywnMA3CaXVdthUFRTt cz5j2RHdzCe5Mv6ZDjgk48j95uzsX+mDey0bSnciCidxdVxSdJ/8P8XHeJTT89sOFd GEKJ+orqBnGK8e3tb+T69IBwylI0SeL/lsXz86g0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726351AbgIKRgO (ORCPT ); Fri, 11 Sep 2020 13:36:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:48356 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725928AbgIKMxc (ORCPT ); Fri, 11 Sep 2020 08:53:32 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 A1472221E3; Fri, 11 Sep 2020 12:53:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828796; bh=DFDRKke5vROvEQcUa5OL+LpykKysm/Lz5k45FUhZR8M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nUMMaZYmOP/zlfAFQdlBCZSkzAkZGT5HpekTHrrStYnozoeelK3pWW3ZyFDZtHChS OXZ/yMvXVEqlco6SnHvAgsbKzx3gKa6a41VMRygWEFcElciK8z9PzCl+6YOM4rpiLL AV6HJLLvCWz1QuShi+Fe9X6My9N4gTan4N2eZT9g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+ab16e463b903f5a37036@syzkaller.appspotmail.com, Sven Eckelmann , Antonio Quartulli , Simon Wunderlich , Sasha Levin Subject: [PATCH 4.4 10/62] batman-adv: Avoid uninitialized chaddr when handling DHCP Date: Fri, 11 Sep 2020 14:45:53 +0200 Message-Id: <20200911122502.905848423@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Sven Eckelmann [ Upstream commit 303216e76dcab6049c9d42390b1032f0649a8206 ] The gateway client code can try to optimize the delivery of DHCP packets to avoid broadcasting them through the whole mesh. But also transmissions to the client can be optimized by looking up the destination via the chaddr of the DHCP packet. But the chaddr is currently only done when chaddr is fully inside the non-paged area of the skbuff. Otherwise it will not be initialized and the unoptimized path should have been taken. But the implementation didn't handle this correctly. It didn't retrieve the correct chaddr but still tried to perform the TT lookup with this uninitialized memory. Reported-by: syzbot+ab16e463b903f5a37036@syzkaller.appspotmail.com Fixes: 6c413b1c22a2 ("batman-adv: send every DHCP packet as bat-unicast") Signed-off-by: Sven Eckelmann Acked-by: Antonio Quartulli Signed-off-by: Simon Wunderlich Signed-off-by: Sasha Levin --- net/batman-adv/gateway_client.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c index a88b529b7ca08..5fdb88f72b68f 100644 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c @@ -757,8 +757,10 @@ batadv_gw_dhcp_recipient_get(struct sk_buff *skb, unsigned int *header_len, chaddr_offset = *header_len + BATADV_DHCP_CHADDR_OFFSET; /* store the client address if the message is going to a client */ - if (ret == BATADV_DHCP_TO_CLIENT && - pskb_may_pull(skb, chaddr_offset + ETH_ALEN)) { + if (ret == BATADV_DHCP_TO_CLIENT) { + if (!pskb_may_pull(skb, chaddr_offset + ETH_ALEN)) + return BATADV_DHCP_NO; + /* check if the DHCP packet carries an Ethernet DHCP */ p = skb->data + *header_len + BATADV_DHCP_HTYPE_OFFSET; if (*p != BATADV_DHCP_HTYPE_ETHERNET) From patchwork Fri Sep 11 12:45:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 309766 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, 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 6C8DEC2BC11 for ; Fri, 11 Sep 2020 17:37:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2ADAB221E7 for ; Fri, 11 Sep 2020 17:37:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845826; bh=kiSrsTIrdXRGEnNSgk/vKpZvsLrP0+0TT4GLeyXZybI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=bAB/YmsHfGivDYcRDpRnGI28fPhcNDTDrrhH7QiHMwxKElIma5gkNCX9RxFSTnq3X zGdLA5fWkGbuJxaUw1+M/6cCdtWq+XL3UXbpJe1NnIP3b+QQ1+4g5aem70tgF/yY5Q hV3onlEwZ2gGn/FMkBc1LokDMnaddD28p/n3XK5E= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725997AbgIKRg5 (ORCPT ); Fri, 11 Sep 2020 13:36:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:48392 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726031AbgIKMxc (ORCPT ); Fri, 11 Sep 2020 08:53:32 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 160DC22204; Fri, 11 Sep 2020 12:53:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828798; bh=kiSrsTIrdXRGEnNSgk/vKpZvsLrP0+0TT4GLeyXZybI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m+y6z/N6hPCw1wft2z0IlWAMXPoOQVPlcWIbY9phU62EtffSqyQ9gv6B41LjPxtsW v9FQ5mRvVC6jiGhI8rj/50+S26rMCee4WyAps+nrgsCC02grQMXuTmaQDSOdwuLO8C 1dpCPiTz13j7UeloOyy2Pv/AokJt3O+I+K8ZfpNg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jussi Kivilinna , Sven Eckelmann , Simon Wunderlich , Sasha Levin Subject: [PATCH 4.4 11/62] batman-adv: bla: use netif_rx_ni when not in interrupt context Date: Fri, 11 Sep 2020 14:45:54 +0200 Message-Id: <20200911122502.956523709@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jussi Kivilinna [ Upstream commit 279e89b2281af3b1a9f04906e157992c19c9f163 ] batadv_bla_send_claim() gets called from worker thread context through batadv_bla_periodic_work(), thus netif_rx_ni needs to be used in that case. This fixes "NOHZ: local_softirq_pending 08" log messages seen when batman-adv is enabled. Fixes: 23721387c409 ("batman-adv: add basic bridge loop avoidance code") Signed-off-by: Jussi Kivilinna Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich Signed-off-by: Sasha Levin --- net/batman-adv/bridge_loop_avoidance.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c index cea7fdeac5aa2..9aa5daa551273 100644 --- a/net/batman-adv/bridge_loop_avoidance.c +++ b/net/batman-adv/bridge_loop_avoidance.c @@ -380,7 +380,10 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, u8 *mac, skb->len + ETH_HLEN); soft_iface->last_rx = jiffies; - netif_rx(skb); + if (in_interrupt()) + netif_rx(skb); + else + netif_rx_ni(skb); out: if (primary_if) batadv_hardif_free_ref(primary_if); From patchwork Fri Sep 11 12:45:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 264021 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, 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 42E1FC43461 for ; Fri, 11 Sep 2020 17:37:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1269D221ED for ; Fri, 11 Sep 2020 17:37:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845825; bh=1orYyBviryLot7PLY1H5LUc+zE1ffz4NBxzSk/+s7l8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=er6XibuG+U5KEUG9wIo+3hRynpEu8nlTFPkt65zzMk+RmLeD0RynXND44Pnw3SOrY O1doiPikzkkMRsgmcxu5N86DSyX2X7OcabCf235Ba7MPQ8tDbAGzjQq7ukRQos/WFZ OyEkiP7yiaEsqU7btEYciX62+gTUDCG7oJT21RP8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726353AbgIKRg5 (ORCPT ); Fri, 11 Sep 2020 13:36:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:48420 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726032AbgIKMxc (ORCPT ); Fri, 11 Sep 2020 08:53:32 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 99E9C2075E; Fri, 11 Sep 2020 12:53:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828801; bh=1orYyBviryLot7PLY1H5LUc+zE1ffz4NBxzSk/+s7l8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pifVRIPZqNggEu0ubofW4pPQYwbXuaJ4TGKiBypAX8hzajybkeC2g8MGc4d9KOwk3 A9HEnZtmIh/HBVUzzToc2HGwaOE8QUrt/6BnTTCkuoGNgaXwbhRbalDpbqhWvX2txv Q4Rls4vLL7ERLh+uIy62IO2xrQJnF4IYLIVMZ2uA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yu Kuai , Vinod Koul , Sasha Levin Subject: [PATCH 4.4 12/62] dmaengine: at_hdmac: check return value of of_find_device_by_node() in at_dma_xlate() Date: Fri, 11 Sep 2020 14:45:55 +0200 Message-Id: <20200911122503.003948091@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Yu Kuai [ Upstream commit 0cef8e2c5a07d482ec907249dbd6687e8697677f ] The reurn value of of_find_device_by_node() is not checked, thus null pointer dereference will be triggered if of_find_device_by_node() failed. Fixes: bbe89c8e3d59 ("at_hdmac: move to generic DMA binding") Signed-off-by: Yu Kuai Link: https://lore.kernel.org/r/20200817115728.1706719-2-yukuai3@huawei.com Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/dma/at_hdmac.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c index 941ace0521306..5276074d0e364 100644 --- a/drivers/dma/at_hdmac.c +++ b/drivers/dma/at_hdmac.c @@ -1817,6 +1817,8 @@ static struct dma_chan *at_dma_xlate(struct of_phandle_args *dma_spec, return NULL; dmac_pdev = of_find_device_by_node(dma_spec->np); + if (!dmac_pdev) + return NULL; dma_cap_zero(mask); dma_cap_set(DMA_SLAVE, mask); From patchwork Fri Sep 11 12:45:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 264022 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 61CB6C433E2 for ; Fri, 11 Sep 2020 17:36:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 18641221EF for ; Fri, 11 Sep 2020 17:36:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845778; bh=uSb8C13w13wjjf8j9yWAfgsPzepRHcI0SMTOKWGF890=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=lh44TiqWoPmPd/whBNvaAU0PcDRvTR71OiB79wP6tAeV6RICdlbHHIakq35uenhe7 C9XCKv0hpC4I0rpqepNjcrwKsqFDWDahixhL+KFqAMuCi9SDTZdHwLNrQjVQq5cCnA I+MAogYo9ifxJBzl3ZSCTiq0eRYfj5QVtUV94HGs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725850AbgIKRgP (ORCPT ); Fri, 11 Sep 2020 13:36:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:48452 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726033AbgIKMxc (ORCPT ); Fri, 11 Sep 2020 08:53:32 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 229F422207; Fri, 11 Sep 2020 12:53:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828803; bh=uSb8C13w13wjjf8j9yWAfgsPzepRHcI0SMTOKWGF890=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zO4cAGPcrUvhTxW0rMKdUKD6PRxiciNJS7Z7ANvdotDFx4Gs7eEZBx1n4bCPVPF1Y q7KCttm+HgoaGpPjMgzsuqZmCpe8w8mzLs/pO8M6oHz3IgkoqNoGGXJ1rXlbNtFK9v OjxlsSflzCMNRCmn1+uadvcSTXQGwYnKigOeAVYc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 4.4 13/62] netfilter: nf_tables: incorrect enum nft_list_attributes definition Date: Fri, 11 Sep 2020 14:45:56 +0200 Message-Id: <20200911122503.052822823@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Pablo Neira Ayuso [ Upstream commit da9125df854ea48a6240c66e8a67be06e2c12c03 ] This should be NFTA_LIST_UNSPEC instead of NFTA_LIST_UNPEC, all other similar attribute definitions are postfixed with _UNSPEC. Fixes: 96518518cc41 ("netfilter: add nftables") Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- include/uapi/linux/netfilter/nf_tables.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/uapi/linux/netfilter/nf_tables.h b/include/uapi/linux/netfilter/nf_tables.h index d8c8a7c9d88a7..b0a1c33d4a153 100644 --- a/include/uapi/linux/netfilter/nf_tables.h +++ b/include/uapi/linux/netfilter/nf_tables.h @@ -111,7 +111,7 @@ enum nf_tables_msg_types { * @NFTA_LIST_ELEM: list element (NLA_NESTED) */ enum nft_list_attributes { - NFTA_LIST_UNPEC, + NFTA_LIST_UNSPEC, NFTA_LIST_ELEM, __NFTA_LIST_MAX }; From patchwork Fri Sep 11 12:45:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 264023 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, 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 40E70C433E2 for ; Fri, 11 Sep 2020 17:36:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E584C221EF for ; Fri, 11 Sep 2020 17:36:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845775; bh=OH61CQn9Ef0/pltN2NgBawZDEuRvAv6bc2xigzixR9o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=mQ+NbQWzpC6Fi/yKM/RJC1nXg8j6bPoErdUDPxprkH5Qc3VAUnixki3HFefrvaCWP IKdorD+FS7cBd15RkYKeZtMc5+Eum99NIXLMAzkpHqzmxxt2DqWCcJV2tvnFIOq8BU pTrJg7kZhKfxcj3xgTV09txcx8b/1RZKKqCZkXdI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726038AbgIKRgC (ORCPT ); Fri, 11 Sep 2020 13:36:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:48794 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725966AbgIKMxu (ORCPT ); Fri, 11 Sep 2020 08:53:50 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 BCADF22206; Fri, 11 Sep 2020 12:53:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828806; bh=OH61CQn9Ef0/pltN2NgBawZDEuRvAv6bc2xigzixR9o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RSoM3VZ3Fq6iCXw+mpsnzi/ls3pl+yj9DCvrq3bUuNO9jt+UEoCKXKzrtZVmjxbXs +kW77VRNWjM78kto43jRz6VgjwOG71LwHJku/mGYCEHWZXQzf2G3i6Jb4FdYc7Ljex 2pCId0v+fGtQEuJdgIcVwbmtLe+aZY7HXK/IOTwE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Florian Westphal , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 4.4 14/62] netfilter: nf_tables: fix destination register zeroing Date: Fri, 11 Sep 2020 14:45:57 +0200 Message-Id: <20200911122503.104564961@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Florian Westphal [ Upstream commit 1e105e6afa6c3d32bfb52c00ffa393894a525c27 ] Following bug was reported via irc: nft list ruleset set knock_candidates_ipv4 { type ipv4_addr . inet_service size 65535 elements = { 127.0.0.1 . 123, 127.0.0.1 . 123 } } .. udp dport 123 add @knock_candidates_ipv4 { ip saddr . 123 } udp dport 123 add @knock_candidates_ipv4 { ip saddr . udp dport } It should not have been possible to add a duplicate set entry. After some debugging it turned out that the problem is the immediate value (123) in the second-to-last rule. Concatenations use 32bit registers, i.e. the elements are 8 bytes each, not 6 and it turns out the kernel inserted inet firewall @knock_candidates_ipv4 element 0100007f ffff7b00 : 0 [end] element 0100007f 00007b00 : 0 [end] Note the non-zero upper bits of the first element. It turns out that nft_immediate doesn't zero the destination register, but this is needed when the length isn't a multiple of 4. Furthermore, the zeroing in nft_payload is broken. We can't use [len / 4] = 0 -- if len is a multiple of 4, index is off by one. Skip zeroing in this case and use a conditional instead of (len -1) / 4. Fixes: 49499c3e6e18 ("netfilter: nf_tables: switch registers to 32 bit addressing") Signed-off-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- include/net/netfilter/nf_tables.h | 2 ++ net/netfilter/nft_payload.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h index b96df7499600f..bee9031a40066 100644 --- a/include/net/netfilter/nf_tables.h +++ b/include/net/netfilter/nf_tables.h @@ -74,6 +74,8 @@ struct nft_regs { static inline void nft_data_copy(u32 *dst, const struct nft_data *src, unsigned int len) { + if (len % NFT_REG32_SIZE) + dst[len / NFT_REG32_SIZE] = 0; memcpy(dst, src, len); } diff --git a/net/netfilter/nft_payload.c b/net/netfilter/nft_payload.c index 09b4b07eb6764..ab3e7b14de09b 100644 --- a/net/netfilter/nft_payload.c +++ b/net/netfilter/nft_payload.c @@ -74,7 +74,9 @@ static void nft_payload_eval(const struct nft_expr *expr, u32 *dest = ®s->data[priv->dreg]; int offset; - dest[priv->len / NFT_REG32_SIZE] = 0; + if (priv->len % NFT_REG32_SIZE) + dest[priv->len / NFT_REG32_SIZE] = 0; + switch (priv->base) { case NFT_PAYLOAD_LL_HEADER: if (!skb_mac_header_was_set(skb)) From patchwork Fri Sep 11 12:45:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 249732 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ecf:0:0:0:0 with SMTP id i15csp81125ilk; Fri, 11 Sep 2020 10:36:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFsIldomlpW/xpmuLuqZ2+vdaE4pDhq7QDEKxesOLTz4RWXbS9Hekgkual4QCKsMyeUuoL X-Received: by 2002:a50:fa88:: with SMTP id w8mr3367954edr.179.1599845764909; Fri, 11 Sep 2020 10:36:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599845764; cv=none; d=google.com; s=arc-20160816; b=vK8WmV72pviUZw/db0a/jKM7cbu2dx0DACBU3C6AUciB3xMe+wWHmzOa93Ji9UOVUl krLI0l23mYIdAaHWiWwXQvTEhqsD3nAKs2aSXu+L5j2DoABut16e+mU8Uj+8ZBsfO35u C3xNUG9ipOcKqUdqyPSSKhHLNPegTn8ST5h0cjpcGRJP6cSJRmEnqutlZzh6d6r3zGru eyo9Ddhjrak7bJKR+UDxZ6FJX1IpZHAnZH1VZUQqMTE6krWYDv+LzNR6oAkB3NuEGf0M dT0DgJneYCWQT5bYAusytA6yYJcsiZNj68gtse90Jbz7bgSsgmutwA4G3Iv4ovfx/Udg cLXg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pbaA6tky+/tNCqREJwHKvQWSx81zWMuGI4tQOQAPf9A=; b=hl2h6x8ifj/1V+rtIPJfWnMuKbyRz0mcf13yC/qHWdQhfWWmGNq4X6TyQckifFD8y/ 2pjt55dusGYZGwcADNSdsEFz4EV5yfLG7fquTuF4b5cX7AJ2Ni+0YpavkxlRmKjA2l2S QRCcbzdhWuXe2vJP1Xil/bVjgq2CocKirCqbJgGEYYqfGZn4KAM4BYug2UcwQi80Sr6S C0Gddv6YwN2UfhgDQu0GbceXVtaTmsGpkf69T7cU0UGxyZxkUqlxrT/Ajcrq6ZIOl4MC /NjqsdMoqF4mSsKloUS9wVz34oOzramZWTHHtCKVe2tOz7ldyNfaUpAx/iekZSiQVLR7 5mug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Dp1LDyVi; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id do18si1858421ejc.13.2020.09.11.10.36.04; Fri, 11 Sep 2020 10:36:04 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Dp1LDyVi; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726133AbgIKRgC (ORCPT + 15 others); Fri, 11 Sep 2020 13:36:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:48796 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725997AbgIKMxu (ORCPT ); Fri, 11 Sep 2020 08:53:50 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 1B3AF22208; Fri, 11 Sep 2020 12:53:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828808; bh=g0zJtYnnfddzXvQnXj1hdkbR8XKhy5A5v7rFK/bguOo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dp1LDyVi9/O3CpowSM6ITCak1x0TYgS8UnIUyEYa6Fd3fMVmxyWU3Bd2ZJaty9SP4 MTwNkQwoIQil4i19AcATV0BCEsXZyfb01yiG59uCYGT6W6LK4kVBO6hZmbMbX6azWp IbtYhrBzQ5SJ0nEd04zaJzi9lx0tTgckXjR8gvi8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , Marek Szyprowski , Vinod Koul , Sasha Levin Subject: [PATCH 4.4 15/62] dmaengine: pl330: Fix burst length if burst size is smaller than bus width Date: Fri, 11 Sep 2020 14:45:58 +0200 Message-Id: <20200911122503.149221163@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Marek Szyprowski [ Upstream commit 0661cef675d37e2c4b66a996389ebeae8568e49e ] Move the burst len fixup after setting the generic value for it. This finally enables the fixup introduced by commit 137bd11090d8 ("dmaengine: pl330: Align DMA memcpy operations to MFIFO width"), which otherwise was overwritten by the generic value. Reported-by: kernel test robot Fixes: 137bd11090d8 ("dmaengine: pl330: Align DMA memcpy operations to MFIFO width") Signed-off-by: Marek Szyprowski Link: https://lore.kernel.org/r/20200825064617.16193-1-m.szyprowski@samsung.com Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/dma/pl330.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.25.1 diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index 799c182c3eacc..9aa57b37381a9 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c @@ -2629,6 +2629,7 @@ pl330_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dst, while (burst != (1 << desc->rqcfg.brst_size)) desc->rqcfg.brst_size++; + desc->rqcfg.brst_len = get_burst_len(desc, len); /* * If burst size is smaller than bus width then make sure we only * transfer one at a time to avoid a burst stradling an MFIFO entry. @@ -2636,7 +2637,6 @@ pl330_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dst, if (desc->rqcfg.brst_size * 8 < pl330->pcfg.data_bus_width) desc->rqcfg.brst_len = 1; - desc->rqcfg.brst_len = get_burst_len(desc, len); desc->bytes_requested = len; desc->txd.flags = flags; From patchwork Fri Sep 11 12:45:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 309769 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 CEFD6C433E2 for ; Fri, 11 Sep 2020 17:35:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8CB3220855 for ; Fri, 11 Sep 2020 17:35:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845752; bh=vEi4E0w4uSHquCmKGvA81A6p95Ge5UOUtUwzKnVs9DY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Xrr+mjpQwbl5qm//D5DT67ia6BSSll6kH9rvQ48ERj80kEqfuLTcE36kPPTBIy6B7 7BlwcS2p5k4zoZKtm8pfP4wDrnOtHPwWQqr1oXn6RVXqnbgCcGLhfqlqO0w7kQvnM4 1G4ZorF0azsXo7fx1zS6wyvyHrmwUPTvizp0E8ro= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725881AbgIKRfv (ORCPT ); Fri, 11 Sep 2020 13:35:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:49208 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726039AbgIKMye (ORCPT ); Fri, 11 Sep 2020 08:54:34 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 960B022209; Fri, 11 Sep 2020 12:53:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828811; bh=vEi4E0w4uSHquCmKGvA81A6p95Ge5UOUtUwzKnVs9DY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Arkx8DQDx+ehSLlXH/1EiS6/w6XGkLalZN0kzenet/Jn0RBKe1MsTN8lDPKzgeSGV K01XtnFXqxRPxfuZ5MA1QXHPXYpwvA/0YMU/4oIYkcuII9ZBIdlwABdLva7n/8p8yb UsTxZ8Gjl/0fy7NUXp6Xxf/SwTEib4s/yVXQcfxU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vasundhara Volam , Michael Chan , "David S. Miller" , Sasha Levin Subject: [PATCH 4.4 16/62] bnxt_en: Check for zero dir entries in NVRAM. Date: Fri, 11 Sep 2020 14:45:59 +0200 Message-Id: <20200911122503.197604642@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Vasundhara Volam [ Upstream commit dbbfa96ad920c50d58bcaefa57f5f33ceef9d00e ] If firmware goes into unstable state, HWRM_NVM_GET_DIR_INFO firmware command may return zero dir entries. Return error in such case to avoid zero length dma buffer request. Fixes: c0c050c58d84 ("bnxt_en: New Broadcom ethernet driver.") Signed-off-by: Vasundhara Volam Signed-off-by: Michael Chan Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index 45bd628eaf3aa..416fb16686a61 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -991,6 +991,9 @@ static int bnxt_get_nvram_directory(struct net_device *dev, u32 len, u8 *data) if (rc != 0) return rc; + if (!dir_entries || !entry_length) + return -EIO; + /* Insert 2 bytes of directory info (count and size of entries) */ if (len < 2) return -EINVAL; From patchwork Fri Sep 11 12:46:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 264024 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, 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 5DACFC433E2 for ; Fri, 11 Sep 2020 17:36:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0DD05221EF for ; Fri, 11 Sep 2020 17:36:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845762; bh=q5AMvphCxcmQP1H/0lgF/CoRmF8mzY/oFlElmY/dmv4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=LnJ75YMDrlvk82WaoCnrQlDhnkl3rBmrLFJtO8bI/W2mRicloD2uGOuMxHQ7ESz4L D/Gfqg6N2ebBZ/eTnNWT8GGyWCbr/UHEfbDsGX8DHcsiSKcr4UD3l9zVC9dcZE9F20 8o/as63erbFFq2Eo0XDoPOhAa5t6EB42A9bOnavc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726043AbgIKRfv (ORCPT ); Fri, 11 Sep 2020 13:35:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:49206 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726038AbgIKMye (ORCPT ); Fri, 11 Sep 2020 08:54:34 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 1D98F2220A; Fri, 11 Sep 2020 12:53:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828813; bh=q5AMvphCxcmQP1H/0lgF/CoRmF8mzY/oFlElmY/dmv4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gPEC023Vr/vTYUnsRLN4twMUZ9/iZVFxYufDbuhVXPYlx7qW4UH6nK9wUiqxa5axE OJHjbAXR5DyAkk2fXQzxUe+4EtDJp3Zc0m4xfwtp3njUnpzFqSL5YFneN5omErZZ3A g2h22WU/bTLON6vFPbhJuEq4+7g+0QgkXeUtHXbk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Zyngier , Al Viro , Sasha Levin Subject: [PATCH 4.4 17/62] fix regression in "epoll: Keep a reference on files added to the check list" Date: Fri, 11 Sep 2020 14:46:00 +0200 Message-Id: <20200911122503.245259147@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Al Viro [ Upstream commit 77f4689de17c0887775bb77896f4cc11a39bf848 ] epoll_loop_check_proc() can run into a file already committed to destruction; we can't grab a reference on those and don't need to add them to the set for reverse path check anyway. Tested-by: Marc Zyngier Fixes: a9ed4a6560b8 ("epoll: Keep a reference on files added to the check list") Signed-off-by: Al Viro Signed-off-by: Sasha Levin --- fs/eventpoll.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/eventpoll.c b/fs/eventpoll.c index b8959d0d4c723..e5324642023d6 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -1720,9 +1720,9 @@ static int ep_loop_check_proc(void *priv, void *cookie, int call_nests) * during ep_insert(). */ if (list_empty(&epi->ffd.file->f_tfile_llink)) { - get_file(epi->ffd.file); - list_add(&epi->ffd.file->f_tfile_llink, - &tfile_check_list); + if (get_file_rcu(epi->ffd.file)) + list_add(&epi->ffd.file->f_tfile_llink, + &tfile_check_list); } } } From patchwork Fri Sep 11 12:46:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 264026 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, 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 14D9DC43461 for ; Fri, 11 Sep 2020 17:35:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C9F1A22205 for ; Fri, 11 Sep 2020 17:35:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845748; bh=Idp+qWzw4A7rf3pUCN+jGJqQy3TiLBI4wkg+aNJ5o6A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=CJy6Zlh8GxdUgR2xXat9FCUnx50vh8G3W0WwSDe1PSC1ZjcnKM2AX71aU37/+Nfd8 Iq95rw9cgnLUoHk/lX8enePAZWPp/T+ZLrnqne8tIH0rvvWpukcjvFXrnTeW1FvKdA DXBGM9s5i7bXL/GtP5LfVD1eWlYPP5H1w6So0idM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725848AbgIKRe2 (ORCPT ); Fri, 11 Sep 2020 13:34:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:49240 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726044AbgIKMye (ORCPT ); Fri, 11 Sep 2020 08:54:34 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 9F9522220E; Fri, 11 Sep 2020 12:53:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828816; bh=Idp+qWzw4A7rf3pUCN+jGJqQy3TiLBI4wkg+aNJ5o6A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RoTRw7rvxuI2sHOsk9mUUJr3VnI+/45h7WV4s6UjPbUp9rIXRp1iXF8NrnrbU5IYm hlSmPkIZ8tC5E9MkxCgrW+5F2bmC7jfvvmL5cZwGlm3Q3ba/ILJ5QvbkEbYJLBOBlg EhJnHW5Wf+0/I/fSYU6U4yiAII8HtoeCzUxPuZ0I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Christensen , Baptiste Covolato , Michael Chan , "David S. Miller" , Sasha Levin Subject: [PATCH 4.4 18/62] tg3: Fix soft lockup when tg3_reset_task() fails. Date: Fri, 11 Sep 2020 14:46:01 +0200 Message-Id: <20200911122503.306946260@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Michael Chan [ Upstream commit 556699341efa98243e08e34401b3f601da91f5a3 ] If tg3_reset_task() fails, the device state is left in an inconsistent state with IFF_RUNNING still set but NAPI state not enabled. A subsequent operation, such as ifdown or AER error can cause it to soft lock up when it tries to disable NAPI state. Fix it by bringing down the device to !IFF_RUNNING state when tg3_reset_task() fails. tg3_reset_task() running from workqueue will now call tg3_close() when the reset fails. We need to modify tg3_reset_task_cancel() slightly to avoid tg3_close() calling cancel_work_sync() to cancel tg3_reset_task(). Otherwise cancel_work_sync() will wait forever for tg3_reset_task() to finish. Reported-by: David Christensen Reported-by: Baptiste Covolato Fixes: db2199737990 ("tg3: Schedule at most one tg3_reset_task run") Signed-off-by: Michael Chan Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/broadcom/tg3.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index e198427d0f292..2ee2b6e858283 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -7203,8 +7203,8 @@ static inline void tg3_reset_task_schedule(struct tg3 *tp) static inline void tg3_reset_task_cancel(struct tg3 *tp) { - cancel_work_sync(&tp->reset_task); - tg3_flag_clear(tp, RESET_TASK_PENDING); + if (test_and_clear_bit(TG3_FLAG_RESET_TASK_PENDING, tp->tg3_flags)) + cancel_work_sync(&tp->reset_task); tg3_flag_clear(tp, TX_RECOVERY_PENDING); } @@ -11176,18 +11176,27 @@ static void tg3_reset_task(struct work_struct *work) tg3_halt(tp, RESET_KIND_SHUTDOWN, 0); err = tg3_init_hw(tp, true); - if (err) + if (err) { + tg3_full_unlock(tp); + tp->irq_sync = 0; + tg3_napi_enable(tp); + /* Clear this flag so that tg3_reset_task_cancel() will not + * call cancel_work_sync() and wait forever. + */ + tg3_flag_clear(tp, RESET_TASK_PENDING); + dev_close(tp->dev); goto out; + } tg3_netif_start(tp); -out: tg3_full_unlock(tp); if (!err) tg3_phy_start(tp); tg3_flag_clear(tp, RESET_TASK_PENDING); +out: rtnl_unlock(); } From patchwork Fri Sep 11 12:46:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 264027 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 6A327C43461 for ; Fri, 11 Sep 2020 17:34:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2EABF22205 for ; Fri, 11 Sep 2020 17:34:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845657; bh=nCJ/LEhl7wKjpj2NUqkEt2s1w9T0+lXZhzCNOn9f6bo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=14U0RfLtw5ffuBi8vD0cXKZgyeaGMX02KFEsgfIcTYtGT3gIHl9CVBLJjS3cUK9ed qRCtPXDern1hrH2yn4jgccznKc3PLybVe9xqlPMDKiRe8AGc5rD1A/f62ckLM4n9cz RqkyHDVtYUzCDmfztbDEX1OfGhPKBMErkQ+FPBVg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726479AbgIKReP (ORCPT ); Fri, 11 Sep 2020 13:34:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:49244 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726045AbgIKMye (ORCPT ); Fri, 11 Sep 2020 08:54:34 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 39DC32220F; Fri, 11 Sep 2020 12:53:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828818; bh=nCJ/LEhl7wKjpj2NUqkEt2s1w9T0+lXZhzCNOn9f6bo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q9r0F86c7pxSfxeOpPlGbG+d4YYkFf97Z4O2E8FgrCNHQVTmPN9lcGSvNLZVZ/bCT jPF4hrxMhb2CChRm4pHZJIU9aXfr4Z8xOZ+775j6LOQTw27zD72rn9twiZww/geCqP 9yj+LcETPcE4z4PjoDk7isB3azZLmvGbFFM8du1g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lu Baolu , Kevin Tian , Andy Lutomirski , Jacob Pan , Ashok Raj , Joerg Roedel , Sasha Levin Subject: [PATCH 4.4 19/62] iommu/vt-d: Serialize IOMMU GCMD register modifications Date: Fri, 11 Sep 2020 14:46:02 +0200 Message-Id: <20200911122503.354193819@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Lu Baolu [ Upstream commit 6e4e9ec65078093165463c13d4eb92b3e8d7b2e8 ] The VT-d spec requires (10.4.4 Global Command Register, GCMD_REG General Description) that: If multiple control fields in this register need to be modified, software must serialize the modifications through multiple writes to this register. However, in irq_remapping.c, modifications of IRE and CFI are done in one write. We need to do two separate writes with STS checking after each. It also checks the status register before writing command register to avoid unnecessary register write. Fixes: af8d102f999a4 ("x86/intel/irq_remapping: Clean up x2apic opt-out security warning mess") Signed-off-by: Lu Baolu Reviewed-by: Kevin Tian Cc: Andy Lutomirski Cc: Jacob Pan Cc: Kevin Tian Cc: Ashok Raj Link: https://lore.kernel.org/r/20200828000615.8281-1-baolu.lu@linux.intel.com Signed-off-by: Joerg Roedel Signed-off-by: Sasha Levin --- drivers/iommu/intel_irq_remapping.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/intel_irq_remapping.c b/drivers/iommu/intel_irq_remapping.c index ac596928f6b40..ce125ec23d2a5 100644 --- a/drivers/iommu/intel_irq_remapping.c +++ b/drivers/iommu/intel_irq_remapping.c @@ -486,12 +486,18 @@ static void iommu_enable_irq_remapping(struct intel_iommu *iommu) /* Enable interrupt-remapping */ iommu->gcmd |= DMA_GCMD_IRE; - iommu->gcmd &= ~DMA_GCMD_CFI; /* Block compatibility-format MSIs */ writel(iommu->gcmd, iommu->reg + DMAR_GCMD_REG); - IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG, readl, (sts & DMA_GSTS_IRES), sts); + /* Block compatibility-format MSIs */ + if (sts & DMA_GSTS_CFIS) { + iommu->gcmd &= ~DMA_GCMD_CFI; + writel(iommu->gcmd, iommu->reg + DMAR_GCMD_REG); + IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG, + readl, !(sts & DMA_GSTS_CFIS), sts); + } + /* * With CFI clear in the Global Command register, we should be * protected from dangerous (i.e. compatibility) interrupts From patchwork Fri Sep 11 12:46:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 309773 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, 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 B2780C43461 for ; Fri, 11 Sep 2020 17:34:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7F552221E7 for ; Fri, 11 Sep 2020 17:34:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845643; bh=6eXHt2jB/snH3r/mLZTCOH4m0HKadZRGmIKJEw5N2DQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Npn71rMVfgPbhc/BmJ14XrbIOTLotIlAubtD7cklmCtQQRXR9czLOT6XrbquvVM1t n+/vj1pusrI2X/XqEIlcHDCqbG3RSqCizs5C5YWeJTGoghivg60moNvnCrBn8NEDii +3n27oxe7uQscWWnCG2V6Z5mh8EqU0VdGoPG91U0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726476AbgIKRcr (ORCPT ); Fri, 11 Sep 2020 13:32:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:49246 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726043AbgIKMyf (ORCPT ); Fri, 11 Sep 2020 08:54:35 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 32B5E22211; Fri, 11 Sep 2020 12:53:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828823; bh=6eXHt2jB/snH3r/mLZTCOH4m0HKadZRGmIKJEw5N2DQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1gXrtyrecJLWHQVp3EEgI0MWT4ScRSUvN+DRBQEQ136EVJ6xh8BXJjGJ+v4fXy2wR CkMZHLqbnp3srBIJ4vm4Si1nap6sjg6CBBF8eotn/5QXTaBgFzkxoUK0/BKGCRAVeJ z4YKRFo5ELrwH8YbJ+oH5D1sVcZrSBNCtUx+LjSI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Merlijn Wajer , Pavel Machek , Sebastian Reichel , Tony Lindgren , Daniel Lezcano , Sasha Levin Subject: [PATCH 4.4 20/62] thermal: ti-soc-thermal: Fix bogus thermal shutdowns for omap4430 Date: Fri, 11 Sep 2020 14:46:03 +0200 Message-Id: <20200911122503.404464140@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Tony Lindgren [ Upstream commit 30d24faba0532d6972df79a1bf060601994b5873 ] We can sometimes get bogus thermal shutdowns on omap4430 at least with droid4 running idle with a battery charger connected: thermal thermal_zone0: critical temperature reached (143 C), shutting down Dumping out the register values shows we can occasionally get a 0x7f value that is outside the TRM listed values in the ADC conversion table. And then we get a normal value when reading again after that. Reading the register multiple times does not seem help avoiding the bogus values as they stay until the next sample is ready. Looking at the TRM chapter "18.4.10.2.3 ADC Codes Versus Temperature", we should have values from 13 to 107 listed with a total of 95 values. But looking at the omap4430_adc_to_temp array, the values are off, and the end values are missing. And it seems that the 4430 ADC table is similar to omap3630 rather than omap4460. Let's fix the issue by using values based on the omap3630 table and just ignoring invalid values. Compared to the 4430 TRM, the omap3630 table has the missing values added while the TRM table only shows every second value. Note that sometimes the ADC register values within the valid table can also be way off for about 1 out of 10 values. But it seems that those just show about 25 C too low values rather than too high values. So those do not cause a bogus thermal shutdown. Fixes: 1a31270e54d7 ("staging: omap-thermal: add OMAP4 data structures") Cc: Merlijn Wajer Cc: Pavel Machek Cc: Sebastian Reichel Signed-off-by: Tony Lindgren Signed-off-by: Daniel Lezcano Link: https://lore.kernel.org/r/20200706183338.25622-1-tony@atomide.com Signed-off-by: Sasha Levin --- .../ti-soc-thermal/omap4-thermal-data.c | 23 ++++++++++--------- .../thermal/ti-soc-thermal/omap4xxx-bandgap.h | 10 +++++--- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/drivers/thermal/ti-soc-thermal/omap4-thermal-data.c b/drivers/thermal/ti-soc-thermal/omap4-thermal-data.c index d255d33da9eb3..02e71d461d5c5 100644 --- a/drivers/thermal/ti-soc-thermal/omap4-thermal-data.c +++ b/drivers/thermal/ti-soc-thermal/omap4-thermal-data.c @@ -49,20 +49,21 @@ static struct temp_sensor_data omap4430_mpu_temp_sensor_data = { /* * Temperature values in milli degree celsius - * ADC code values from 530 to 923 + * ADC code values from 13 to 107, see TRM + * "18.4.10.2.3 ADC Codes Versus Temperature". */ static const int omap4430_adc_to_temp[OMAP4430_ADC_END_VALUE - OMAP4430_ADC_START_VALUE + 1] = { - -38000, -35000, -34000, -32000, -30000, -28000, -26000, -24000, -22000, - -20000, -18000, -17000, -15000, -13000, -12000, -10000, -8000, -6000, - -5000, -3000, -1000, 0, 2000, 3000, 5000, 6000, 8000, 10000, 12000, - 13000, 15000, 17000, 19000, 21000, 23000, 25000, 27000, 28000, 30000, - 32000, 33000, 35000, 37000, 38000, 40000, 42000, 43000, 45000, 47000, - 48000, 50000, 52000, 53000, 55000, 57000, 58000, 60000, 62000, 64000, - 66000, 68000, 70000, 71000, 73000, 75000, 77000, 78000, 80000, 82000, - 83000, 85000, 87000, 88000, 90000, 92000, 93000, 95000, 97000, 98000, - 100000, 102000, 103000, 105000, 107000, 109000, 111000, 113000, 115000, - 117000, 118000, 120000, 122000, 123000, + -40000, -38000, -35000, -34000, -32000, -30000, -28000, -26000, -24000, + -22000, -20000, -18500, -17000, -15000, -13500, -12000, -10000, -8000, + -6500, -5000, -3500, -1500, 0, 2000, 3500, 5000, 6500, 8500, 10000, + 12000, 13500, 15000, 17000, 19000, 21000, 23000, 25000, 27000, 28500, + 30000, 32000, 33500, 35000, 37000, 38500, 40000, 42000, 43500, 45000, + 47000, 48500, 50000, 52000, 53500, 55000, 57000, 58500, 60000, 62000, + 64000, 66000, 68000, 70000, 71500, 73500, 75000, 77000, 78500, 80000, + 82000, 83500, 85000, 87000, 88500, 90000, 92000, 93500, 95000, 97000, + 98500, 100000, 102000, 103500, 105000, 107000, 109000, 111000, 113000, + 115000, 117000, 118500, 120000, 122000, 123500, 125000, }; /* OMAP4430 data */ diff --git a/drivers/thermal/ti-soc-thermal/omap4xxx-bandgap.h b/drivers/thermal/ti-soc-thermal/omap4xxx-bandgap.h index 6f2de3a3356d4..86850082b24b9 100644 --- a/drivers/thermal/ti-soc-thermal/omap4xxx-bandgap.h +++ b/drivers/thermal/ti-soc-thermal/omap4xxx-bandgap.h @@ -67,9 +67,13 @@ * and thresholds for OMAP4430. */ -/* ADC conversion table limits */ -#define OMAP4430_ADC_START_VALUE 0 -#define OMAP4430_ADC_END_VALUE 127 +/* + * ADC conversion table limits. Ignore values outside the TRM listed + * range to avoid bogus thermal shutdowns. See omap4430 TRM chapter + * "18.4.10.2.3 ADC Codes Versus Temperature". + */ +#define OMAP4430_ADC_START_VALUE 13 +#define OMAP4430_ADC_END_VALUE 107 /* bandgap clock limits (no control on 4430) */ #define OMAP4430_MAX_FREQ 32768 #define OMAP4430_MIN_FREQ 32768 From patchwork Fri Sep 11 12:46:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 264025 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, 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 459DAC43461 for ; Fri, 11 Sep 2020 17:35:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ED6BA22206 for ; Fri, 11 Sep 2020 17:35:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845751; bh=6XiXYf1OQACfz6Pl7MUVTDtIWF63t2t/6FVZNrXz7CA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=NR+TGjKXesmeQJwXz+A7DJvImmWNlwnJ/b61w3x5r7eFEQY4TpCR04oipDdfx9a4U rBP33a7nEnVLqJGAdbDQB5FhFwsJgdOkz0Wm12Q+8Cdq8LSN4WovIz3FJo+U7QEOhG VUj4utgC5W5Mzd7WbywMni+G+8age/+zTyOfTbW8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726392AbgIKRe2 (ORCPT ); Fri, 11 Sep 2020 13:34:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:49248 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726049AbgIKMye (ORCPT ); Fri, 11 Sep 2020 08:54:34 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 DDE9322224; Fri, 11 Sep 2020 12:53:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828826; bh=6XiXYf1OQACfz6Pl7MUVTDtIWF63t2t/6FVZNrXz7CA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uaF+PvC5UNj0WBHqx/w/06nh8qLQomtAQuWPqTvwtkZuYB+PFIW+jzj15CM5rsG5P COH4Y8bKm3PU1Gy/1HMXf10Lfo52v4bJZy7LE2ipWl78dYKErxO1MsO/W6KRWJmuKX rjC/b5jXUbBFyyjCoMwNckKk4m+7n809kWM+mQCo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jason Gunthorpe , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 4.4 21/62] include/linux/log2.h: add missing () around n in roundup_pow_of_two() Date: Fri, 11 Sep 2020 14:46:04 +0200 Message-Id: <20200911122503.452592088@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jason Gunthorpe [ Upstream commit 428fc0aff4e59399ec719ffcc1f7a5d29a4ee476 ] Otherwise gcc generates warnings if the expression is complicated. Fixes: 312a0c170945 ("[PATCH] LOG2: Alter roundup_pow_of_two() so that it can use a ilog2() on a constant") Signed-off-by: Jason Gunthorpe Signed-off-by: Andrew Morton Link: https://lkml.kernel.org/r/0-v1-8a2697e3c003+41165-log_brackets_jgg@nvidia.com Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- include/linux/log2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/log2.h b/include/linux/log2.h index c373295f359fa..cca606609e1bc 100644 --- a/include/linux/log2.h +++ b/include/linux/log2.h @@ -159,7 +159,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n) #define roundup_pow_of_two(n) \ ( \ __builtin_constant_p(n) ? ( \ - (n == 1) ? 1 : \ + ((n) == 1) ? 1 : \ (1UL << (ilog2((n) - 1) + 1)) \ ) : \ __roundup_pow_of_two(n) \ From patchwork Fri Sep 11 12:46:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 264102 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=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 EF7A3C433E2 for ; Fri, 11 Sep 2020 13:00:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A170C22473 for ; Fri, 11 Sep 2020 13:00:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599829250; bh=svXOEzPwRsOn0YI0r7BxwC0NFoM3u0CxMt9i8WkVgH4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=c++7U8auo44qU1h0kb95BldEU4h5S9o7+G8XNGmk1mdW74Zp8qcpvO29dt2OCBdI2 VcluhpvlY/xjqx9wO3b1if2HUufHXegoPnllSkAsLog603Rjw+l9PqFm0Dv4aLLhU1 XHZLwTkI+AEDZCKNs8p+kfYlMJiAYuY4c0vdRmAc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726004AbgIKNAn (ORCPT ); Fri, 11 Sep 2020 09:00:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:49906 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726102AbgIKM6D (ORCPT ); Fri, 11 Sep 2020 08:58:03 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 9F0CF22224; Fri, 11 Sep 2020 12:55:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828928; bh=svXOEzPwRsOn0YI0r7BxwC0NFoM3u0CxMt9i8WkVgH4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ca93ihv4rvVaCGLaDDq1gK9uswGZXub9ToYRU69uzPC8lYvhMB/T5ahG2Ek5RUsC4 xpGPaJiyczckn1j29KFfc0pFKMkBGPPZtmP/5RMyC88P0aZ+SsXQE6tKPV94luRnBW 3w/gbqD/JqnrEK+27h96RT5xgNtUwVc3q5LAjoVo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Filipe Manana , Josef Bacik , David Sterba Subject: [PATCH 4.4 22/62] btrfs: drop path before adding new uuid tree entry Date: Fri, 11 Sep 2020 14:46:05 +0200 Message-Id: <20200911122503.503512875@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Josef Bacik commit 9771a5cf937129307d9f58922d60484d58ababe7 upstream. With the conversion of the tree locks to rwsem I got the following lockdep splat: ====================================================== WARNING: possible circular locking dependency detected 5.8.0-rc7-00167-g0d7ba0c5b375-dirty #925 Not tainted ------------------------------------------------------ btrfs-uuid/7955 is trying to acquire lock: ffff88bfbafec0f8 (btrfs-root-00){++++}-{3:3}, at: __btrfs_tree_read_lock+0x39/0x180 but task is already holding lock: ffff88bfbafef2a8 (btrfs-uuid-00){++++}-{3:3}, at: __btrfs_tree_read_lock+0x39/0x180 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #1 (btrfs-uuid-00){++++}-{3:3}: down_read_nested+0x3e/0x140 __btrfs_tree_read_lock+0x39/0x180 __btrfs_read_lock_root_node+0x3a/0x50 btrfs_search_slot+0x4bd/0x990 btrfs_uuid_tree_add+0x89/0x2d0 btrfs_uuid_scan_kthread+0x330/0x390 kthread+0x133/0x150 ret_from_fork+0x1f/0x30 -> #0 (btrfs-root-00){++++}-{3:3}: __lock_acquire+0x1272/0x2310 lock_acquire+0x9e/0x360 down_read_nested+0x3e/0x140 __btrfs_tree_read_lock+0x39/0x180 __btrfs_read_lock_root_node+0x3a/0x50 btrfs_search_slot+0x4bd/0x990 btrfs_find_root+0x45/0x1b0 btrfs_read_tree_root+0x61/0x100 btrfs_get_root_ref.part.50+0x143/0x630 btrfs_uuid_tree_iterate+0x207/0x314 btrfs_uuid_rescan_kthread+0x12/0x50 kthread+0x133/0x150 ret_from_fork+0x1f/0x30 other info that might help us debug this: Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(btrfs-uuid-00); lock(btrfs-root-00); lock(btrfs-uuid-00); lock(btrfs-root-00); *** DEADLOCK *** 1 lock held by btrfs-uuid/7955: #0: ffff88bfbafef2a8 (btrfs-uuid-00){++++}-{3:3}, at: __btrfs_tree_read_lock+0x39/0x180 stack backtrace: CPU: 73 PID: 7955 Comm: btrfs-uuid Kdump: loaded Not tainted 5.8.0-rc7-00167-g0d7ba0c5b375-dirty #925 Hardware name: Quanta Tioga Pass Single Side 01-0030993006/Tioga Pass Single Side, BIOS F08_3A18 12/20/2018 Call Trace: dump_stack+0x78/0xa0 check_noncircular+0x165/0x180 __lock_acquire+0x1272/0x2310 lock_acquire+0x9e/0x360 ? __btrfs_tree_read_lock+0x39/0x180 ? btrfs_root_node+0x1c/0x1d0 down_read_nested+0x3e/0x140 ? __btrfs_tree_read_lock+0x39/0x180 __btrfs_tree_read_lock+0x39/0x180 __btrfs_read_lock_root_node+0x3a/0x50 btrfs_search_slot+0x4bd/0x990 btrfs_find_root+0x45/0x1b0 btrfs_read_tree_root+0x61/0x100 btrfs_get_root_ref.part.50+0x143/0x630 btrfs_uuid_tree_iterate+0x207/0x314 ? btree_readpage+0x20/0x20 btrfs_uuid_rescan_kthread+0x12/0x50 kthread+0x133/0x150 ? kthread_create_on_node+0x60/0x60 ret_from_fork+0x1f/0x30 This problem exists because we have two different rescan threads, btrfs_uuid_scan_kthread which creates the uuid tree, and btrfs_uuid_tree_iterate that goes through and updates or deletes any out of date roots. The problem is they both do things in different order. btrfs_uuid_scan_kthread() reads the tree_root, and then inserts entries into the uuid_root. btrfs_uuid_tree_iterate() scans the uuid_root, but then does a btrfs_get_fs_root() which can read from the tree_root. It's actually easy enough to not be holding the path in btrfs_uuid_scan_kthread() when we add a uuid entry, as we already drop it further down and re-start the search when we loop. So simply move the path release before we add our entry to the uuid tree. This also fixes a problem where we're holding a path open after we do btrfs_end_transaction(), which has it's own problems. CC: stable@vger.kernel.org # 4.4+ Reviewed-by: Filipe Manana Signed-off-by: Josef Bacik Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/volumes.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -4065,6 +4065,7 @@ static int btrfs_uuid_scan_kthread(void goto skip; } update_tree: + btrfs_release_path(path); if (!btrfs_is_empty_uuid(root_item.uuid)) { ret = btrfs_uuid_tree_add(trans, fs_info->uuid_root, root_item.uuid, @@ -4090,6 +4091,7 @@ update_tree: } skip: + btrfs_release_path(path); if (trans) { ret = btrfs_end_transaction(trans, fs_info->uuid_root); trans = NULL; @@ -4097,7 +4099,6 @@ skip: break; } - btrfs_release_path(path); if (key.offset < (u64)-1) { key.offset++; } else if (key.type < BTRFS_ROOT_ITEM_KEY) { From patchwork Fri Sep 11 12:46:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 264106 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 BCE6DC43461 for ; Fri, 11 Sep 2020 12:56:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5F9B822273 for ; Fri, 11 Sep 2020 12:56:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828999; bh=YXvxJU50/o7JM1lhiqRe+v3U3CdBUoWn/IcA6FOdLtY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=mPRjNcoLyAS7Mepjrxtl4AoYgM4MW/dpailU5asToOlVXWrrbqZdBLVMc92Rcgs3m yA7lEz/SAEM3uJXLHNR21yUmMyEs7jktzPpN9YCOD9hYJQRowSlljDO/wBIY3S38gx kniCrj/e7ov7VEN8F+ni1Xb7LTLHB1nscZSnIzCU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726010AbgIKM4e (ORCPT ); Fri, 11 Sep 2020 08:56:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:49208 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725992AbgIKMzD (ORCPT ); Fri, 11 Sep 2020 08:55:03 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 747A12222C; Fri, 11 Sep 2020 12:54:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828849; bh=YXvxJU50/o7JM1lhiqRe+v3U3CdBUoWn/IcA6FOdLtY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2kayIAgVnjSzg52/+yfMhtFCLplH4sRKNJ+qdKO/8mGfDOR/bk0uYe7zQ1cXuCKBe fZNSGMu4up59QrMnAoWtmlhHHFBMymR4my6zcrSyPw57uKtOTSmZdT87IDr4XubbsO DeGHwW5WaZl4hUPCg7nRys00sI6IDwjXi8mf59S0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nikolay Borisov , David Sterba , Sasha Levin Subject: [PATCH 4.4 23/62] btrfs: Remove redundant extent_buffer_get in get_old_root Date: Fri, 11 Sep 2020 14:46:06 +0200 Message-Id: <20200911122503.553102172@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Nikolay Borisov [ Upstream commit 6c122e2a0c515cfb3f3a9cefb5dad4cb62109c78 ] get_old_root used used only by btrfs_search_old_slot to initialise the path structure. The old root is always a cloned buffer (either via alloc dummy or via btrfs_clone_extent_buffer) and its reference count is 2: 1 from allocation, 1 from extent_buffer_get call in get_old_root. This latter explicit ref count acquire operation is in fact unnecessary since the semantic is such that the newly allocated buffer is handed over to the btrfs_path for lifetime management. Considering this just remove the extra extent_buffer_get in get_old_root. Signed-off-by: Nikolay Borisov Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/ctree.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 8eac5f75bca36..8765312743f16 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -1441,7 +1441,6 @@ get_old_root(struct btrfs_root *root, u64 time_seq) if (!eb) return NULL; - extent_buffer_get(eb); btrfs_tree_read_lock(eb); if (old_root) { btrfs_set_header_bytenr(eb, eb->start); From patchwork Fri Sep 11 12:46:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 264032 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, 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 5216FC433E2 for ; Fri, 11 Sep 2020 17:32:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1C4D2221ED for ; Fri, 11 Sep 2020 17:32:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845535; bh=IsVOSbbTfRCzjXHFy6RzbyMiobywS2BfjcvnnzG8+hQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=vFiv5GXqFBH79fXTjInA6vbGjoBbI4gFIw/k24IPRWta5kIWFhA5ARTqDOb28nAAM AVdxtoK3mytj96/zeiUUl1LVFlDgqTLfCV0XWmY+BsLZV1Hh3xjFfHTW2PjhbSodqC T3h34I2KhGSDBuGXR6iVlflcZkyBtCu105KgNzCM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726260AbgIKRbP (ORCPT ); Fri, 11 Sep 2020 13:31:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:48794 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726065AbgIKMze (ORCPT ); Fri, 11 Sep 2020 08:55:34 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 547CE221E3; Fri, 11 Sep 2020 12:54:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828877; bh=IsVOSbbTfRCzjXHFy6RzbyMiobywS2BfjcvnnzG8+hQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0socJZ5QKHmoj0nneIB66rAjGkkLARY6TU+tOf3DnrjpC6FO2xLUpCLR2LxbKqLnX 6irWkMvLfixNJjy5IYzCJ5yIxvQpGED7St5s6/tpZpQ/TdX/FlNHoDI4Q4NTnSFQli fpVZD4ws1BCxVb2PFumk4tld1mO763NosgJB2GBY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nikolay Borisov , David Sterba , Sasha Levin Subject: [PATCH 4.4 24/62] btrfs: Remove extraneous extent_buffer_get from tree_mod_log_rewind Date: Fri, 11 Sep 2020 14:46:07 +0200 Message-Id: <20200911122503.601915915@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Nikolay Borisov [ Upstream commit 24cee18a1c1d7c731ea5987e0c99daea22ae7f4a ] When a rewound buffer is created it already has a ref count of 1 and the dummy flag set. Then another ref is taken bumping the count to 2. Finally when this buffer is released from btrfs_release_path the extra reference is decremented by the special handling code in free_extent_buffer. However, this special code is in fact redundant sinca ref count of 1 is still correct since the buffer is only accessed via btrfs_path struct. This paves the way forward of removing the special handling in free_extent_buffer. Signed-off-by: Nikolay Borisov Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/ctree.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 8765312743f16..a8660b503bf36 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -1372,7 +1372,6 @@ tree_mod_log_rewind(struct btrfs_fs_info *fs_info, struct btrfs_path *path, btrfs_tree_read_unlock_blocking(eb); free_extent_buffer(eb); - extent_buffer_get(eb_rewin); btrfs_tree_read_lock(eb_rewin); __tree_mod_log_rewind(fs_info, eb_rewin, time_seq, tm); WARN_ON(btrfs_header_nritems(eb_rewin) > From patchwork Fri Sep 11 12:46:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 309845 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 EACB4C43461 for ; Fri, 11 Sep 2020 12:59:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A4BE02224C for ; Fri, 11 Sep 2020 12:59:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599829193; bh=3Xp9RG7H9f6vJ/0asV5Bznrrs7o5QSHfreAmm28wEZw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=xjDNyHZXia5MXDwx+QDOhOrJsanu754/e1WafOzZANWFkl6VkIszA9W1tkBgwgki5 HM5dv1TYrMsc968bHaSkM6fh3G9d7vB1fBhGgVOnOayPKPZH53FTvec0bwhFAwv1tI KMDQP6KA/13vhVe9Hm/ayf3fyEnPpcsokh20Y5SI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726117AbgIKM7J (ORCPT ); Fri, 11 Sep 2020 08:59:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:49674 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725920AbgIKM4n (ORCPT ); Fri, 11 Sep 2020 08:56:43 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 0196C22209; Fri, 11 Sep 2020 12:55:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828905; bh=3Xp9RG7H9f6vJ/0asV5Bznrrs7o5QSHfreAmm28wEZw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M9+AYMQb/msA8Sw8CGg9ytEhWIVFbBIUiRMe5NzV6DeYqYUDMhXm0EwUI2UfIcTnJ BFSBEGkYxBBja9ap6NdALB3sCXzLoMhjdvbztgrnepSKdfTliCsDZykpMpRMHTzHV+ Ftv++MU4gXvzZwwej0kaDFKes9CFLrVkbQCxb/Ng= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Filipe Manana , Josef Bacik , David Sterba , Sasha Levin Subject: [PATCH 4.4 25/62] btrfs: set the lockdep class for log tree extent buffers Date: Fri, 11 Sep 2020 14:46:08 +0200 Message-Id: <20200911122503.652693757@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Josef Bacik [ Upstream commit d3beaa253fd6fa40b8b18a216398e6e5376a9d21 ] These are special extent buffers that get rewound in order to lookup the state of the tree at a specific point in time. As such they do not go through the normal initialization paths that set their lockdep class, so handle them appropriately when they are created and before they are locked. CC: stable@vger.kernel.org # 4.4+ Reviewed-by: Filipe Manana Signed-off-by: Josef Bacik Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/ctree.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index a8660b503bf36..3fa0515d76851 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -1372,6 +1372,8 @@ tree_mod_log_rewind(struct btrfs_fs_info *fs_info, struct btrfs_path *path, btrfs_tree_read_unlock_blocking(eb); free_extent_buffer(eb); + btrfs_set_buffer_lockdep_class(btrfs_header_owner(eb_rewin), + eb_rewin, btrfs_header_level(eb_rewin)); btrfs_tree_read_lock(eb_rewin); __tree_mod_log_rewind(fs_info, eb_rewin, time_seq, tm); WARN_ON(btrfs_header_nritems(eb_rewin) > @@ -1440,7 +1442,6 @@ get_old_root(struct btrfs_root *root, u64 time_seq) if (!eb) return NULL; - btrfs_tree_read_lock(eb); if (old_root) { btrfs_set_header_bytenr(eb, eb->start); btrfs_set_header_backref_rev(eb, BTRFS_MIXED_BACKREF_REV); @@ -1448,6 +1449,9 @@ get_old_root(struct btrfs_root *root, u64 time_seq) btrfs_set_header_level(eb, old_root->level); btrfs_set_header_generation(eb, old_generation); } + btrfs_set_buffer_lockdep_class(btrfs_header_owner(eb), eb, + btrfs_header_level(eb)); + btrfs_tree_read_lock(eb); if (tm) __tree_mod_log_rewind(root->fs_info, eb, time_seq, tm); else From patchwork Fri Sep 11 12:46:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 309784 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 19C94C43461 for ; Fri, 11 Sep 2020 17:30:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D9A38221E7 for ; Fri, 11 Sep 2020 17:30:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845404; bh=/NMriXmTJHYbVM8FzcBa2rfk3gnru0cH8mbUu2GEgKE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=T+QZsCIDzg4CizBahUP1Wbk1/uLsfvAMwE0CSxOWSceQNJxvNUUxkwxbzRvRkQFL2 2JkMi0LgN/cVwBcuh9WGL6T4KeXx79xfpiKG4YP4FA8c2Qbv7D2+PS8mprNwVZUGdE znls8w7vPC5E1AFnp6Njvv8F2idHR4OUjL+a3ffI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726504AbgIKRaC (ORCPT ); Fri, 11 Sep 2020 13:30:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:49244 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726090AbgIKM5a (ORCPT ); Fri, 11 Sep 2020 08:57:30 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 790F02224B; Fri, 11 Sep 2020 12:55:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828913; bh=/NMriXmTJHYbVM8FzcBa2rfk3gnru0cH8mbUu2GEgKE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I9RIRa+5hmGFZQeXbBHsCM9tmBmUxCF5Bh4oMeopLQu1DccNih1rJCqGE4Kv01rJP QnpFHBbskQ13Mmcg4AYROfp98oDF1NuDrpPQirnrxbP/GMn0sAqJG4Xr8D08I5wjLy ITKNIOorKQVla/bTCvFiBXlOvjAkMev8d4DQM/FA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ingo Molnar , Masami Hiramatsu , "Steven Rostedt (VMware)" , Sasha Levin Subject: [PATCH 4.4 26/62] uaccess: Add non-pagefault user-space read functions Date: Fri, 11 Sep 2020 14:46:09 +0200 Message-Id: <20200911122503.694005999@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Masami Hiramatsu [ Upstream commit 3d7081822f7f9eab867d9bcc8fd635208ec438e0 ] Add probe_user_read(), strncpy_from_unsafe_user() and strnlen_unsafe_user() which allows caller to access user-space in IRQ context. Current probe_kernel_read() and strncpy_from_unsafe() are not available for user-space memory, because it sets KERNEL_DS while accessing data. On some arch, user address space and kernel address space can be co-exist, but others can not. In that case, setting KERNEL_DS means given address is treated as a kernel address space. Also strnlen_user() is only available from user context since it can sleep if pagefault is enabled. To access user-space memory without pagefault, we need these new functions which sets USER_DS while accessing the data. Link: http://lkml.kernel.org/r/155789869802.26965.4940338412595759063.stgit@devnote2 Acked-by: Ingo Molnar Signed-off-by: Masami Hiramatsu Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Sasha Levin --- include/linux/uaccess.h | 14 +++++ mm/maccess.c | 122 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 130 insertions(+), 6 deletions(-) diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h index 15c7b5420d8aa..b9e538176349c 100644 --- a/include/linux/uaccess.h +++ b/include/linux/uaccess.h @@ -90,6 +90,17 @@ static inline unsigned long __copy_from_user_nocache(void *to, extern long probe_kernel_read(void *dst, const void *src, size_t size); extern long __probe_kernel_read(void *dst, const void *src, size_t size); +/* + * probe_user_read(): safely attempt to read from a location in user space + * @dst: pointer to the buffer that shall take the data + * @src: address to read from + * @size: size of the data chunk + * + * Safely read from address @src to the buffer at @dst. If a kernel fault + * happens, handle that and return -EFAULT. + */ +extern long probe_user_read(void *dst, const void __user *src, size_t size); + /* * probe_kernel_write(): safely attempt to write to a location * @dst: address to write to @@ -103,6 +114,9 @@ extern long notrace probe_kernel_write(void *dst, const void *src, size_t size); extern long notrace __probe_kernel_write(void *dst, const void *src, size_t size); extern long strncpy_from_unsafe(char *dst, const void *unsafe_addr, long count); +extern long strncpy_from_unsafe_user(char *dst, const void __user *unsafe_addr, + long count); +extern long strnlen_unsafe_user(const void __user *unsafe_addr, long count); /** * probe_kernel_address(): safely attempt to read from a location diff --git a/mm/maccess.c b/mm/maccess.c index d159b1c96e484..78add1654b41a 100644 --- a/mm/maccess.c +++ b/mm/maccess.c @@ -5,8 +5,20 @@ #include #include +static __always_inline long +probe_read_common(void *dst, const void __user *src, size_t size) +{ + long ret; + + pagefault_disable(); + ret = __copy_from_user_inatomic(dst, src, size); + pagefault_enable(); + + return ret ? -EFAULT : 0; +} + /** - * probe_kernel_read(): safely attempt to read from a location + * probe_kernel_read(): safely attempt to read from a kernel-space location * @dst: pointer to the buffer that shall take the data * @src: address to read from * @size: size of the data chunk @@ -29,16 +41,40 @@ long __probe_kernel_read(void *dst, const void *src, size_t size) mm_segment_t old_fs = get_fs(); set_fs(KERNEL_DS); - pagefault_disable(); - ret = __copy_from_user_inatomic(dst, - (__force const void __user *)src, size); - pagefault_enable(); + ret = probe_read_common(dst, (__force const void __user *)src, size); set_fs(old_fs); - return ret ? -EFAULT : 0; + return ret; } EXPORT_SYMBOL_GPL(probe_kernel_read); +/** + * probe_user_read(): safely attempt to read from a user-space location + * @dst: pointer to the buffer that shall take the data + * @src: address to read from. This must be a user address. + * @size: size of the data chunk + * + * Safely read from user address @src to the buffer at @dst. If a kernel fault + * happens, handle that and return -EFAULT. + */ + +long __weak probe_user_read(void *dst, const void __user *src, size_t size) + __attribute__((alias("__probe_user_read"))); + +long __probe_user_read(void *dst, const void __user *src, size_t size) +{ + long ret = -EFAULT; + mm_segment_t old_fs = get_fs(); + + set_fs(USER_DS); + if (access_ok(VERIFY_READ, src, size)) + ret = probe_read_common(dst, src, size); + set_fs(old_fs); + + return ret; +} +EXPORT_SYMBOL_GPL(probe_user_read); + /** * probe_kernel_write(): safely attempt to write to a location * @dst: address to write to @@ -66,6 +102,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size) } EXPORT_SYMBOL_GPL(probe_kernel_write); + /** * strncpy_from_unsafe: - Copy a NUL terminated string from unsafe address. * @dst: Destination address, in kernel space. This buffer must be at @@ -106,3 +143,76 @@ long strncpy_from_unsafe(char *dst, const void *unsafe_addr, long count) return ret ? -EFAULT : src - unsafe_addr; } + +/** + * strncpy_from_unsafe_user: - Copy a NUL terminated string from unsafe user + * address. + * @dst: Destination address, in kernel space. This buffer must be at + * least @count bytes long. + * @unsafe_addr: Unsafe user address. + * @count: Maximum number of bytes to copy, including the trailing NUL. + * + * Copies a NUL-terminated string from unsafe user address to kernel buffer. + * + * On success, returns the length of the string INCLUDING the trailing NUL. + * + * If access fails, returns -EFAULT (some data may have been copied + * and the trailing NUL added). + * + * If @count is smaller than the length of the string, copies @count-1 bytes, + * sets the last byte of @dst buffer to NUL and returns @count. + */ +long strncpy_from_unsafe_user(char *dst, const void __user *unsafe_addr, + long count) +{ + mm_segment_t old_fs = get_fs(); + long ret; + + if (unlikely(count <= 0)) + return 0; + + set_fs(USER_DS); + pagefault_disable(); + ret = strncpy_from_user(dst, unsafe_addr, count); + pagefault_enable(); + set_fs(old_fs); + + if (ret >= count) { + ret = count; + dst[ret - 1] = '\0'; + } else if (ret > 0) { + ret++; + } + + return ret; +} + +/** + * strnlen_unsafe_user: - Get the size of a user string INCLUDING final NUL. + * @unsafe_addr: The string to measure. + * @count: Maximum count (including NUL) + * + * Get the size of a NUL-terminated string in user space without pagefault. + * + * Returns the size of the string INCLUDING the terminating NUL. + * + * If the string is too long, returns a number larger than @count. User + * has to check the return value against "> count". + * On exception (or invalid count), returns 0. + * + * Unlike strnlen_user, this can be used from IRQ handler etc. because + * it disables pagefaults. + */ +long strnlen_unsafe_user(const void __user *unsafe_addr, long count) +{ + mm_segment_t old_fs = get_fs(); + int ret; + + set_fs(USER_DS); + pagefault_disable(); + ret = strnlen_user(unsafe_addr, count); + pagefault_enable(); + set_fs(old_fs); + + return ret; +} From patchwork Fri Sep 11 12:46:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 309783 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, 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 502CDC43461 for ; Fri, 11 Sep 2020 17:30:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 186B721D91 for ; Fri, 11 Sep 2020 17:30:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845436; bh=Uwbfi8W/Cl7IDwfcCRT5yuJmKg1LKpGoXBrox13rh+A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Sgf+bp4xtCnWJeZE4FGjDzqU7pAlpWUS/pkU8+Ym0FHDRtkwJ0jLM6fQknOerxIM8 sp1F26cHMb3yQABUP8ChymOiqEpTWHrYPEQTXLBoBQrG55AI1YNOtbzXl6I6ahef98 JUqczuDviiQ9f76uixDa3k8PbAf1FA4sm8sU5+fQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726123AbgIKRaB (ORCPT ); Fri, 11 Sep 2020 13:30:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:49840 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726091AbgIKM5a (ORCPT ); Fri, 11 Sep 2020 08:57:30 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 0B8F52224C; Fri, 11 Sep 2020 12:55:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828915; bh=Uwbfi8W/Cl7IDwfcCRT5yuJmKg1LKpGoXBrox13rh+A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yi3GgI6ma5pdTLb7J2HbuMUK9zcmsAxlbXgf9Z8/Er4WZSpBvD5mr1rzQ/sF6/0Lz dUssWO/HkV7w2/23QC1IS3O1/I6JhhOvSkFlPr1U7DyvxhzsxnaC08l9FRlOwGpXIz o3XnkGH5mt1eYqlpJpw83TRefoi76wbu2uSPgj5I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Borkmann , Alexei Starovoitov , Andrii Nakryiko , Masami Hiramatsu , Sasha Levin Subject: [PATCH 4.4 27/62] uaccess: Add non-pagefault user-space write function Date: Fri, 11 Sep 2020 14:46:10 +0200 Message-Id: <20200911122503.743743910@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Daniel Borkmann [ Upstream commit 1d1585ca0f48fe7ed95c3571f3e4a82b2b5045dc ] Commit 3d7081822f7f ("uaccess: Add non-pagefault user-space read functions") missed to add probe write function, therefore factor out a probe_write_common() helper with most logic of probe_kernel_write() except setting KERNEL_DS, and add a new probe_user_write() helper so it can be used from BPF side. Again, on some archs, the user address space and kernel address space can co-exist and be overlapping, so in such case, setting KERNEL_DS would mean that the given address is treated as being in kernel address space. Signed-off-by: Daniel Borkmann Signed-off-by: Alexei Starovoitov Acked-by: Andrii Nakryiko Cc: Masami Hiramatsu Link: https://lore.kernel.org/bpf/9df2542e68141bfa3addde631441ee45503856a8.1572649915.git.daniel@iogearbox.net Signed-off-by: Sasha Levin --- include/linux/uaccess.h | 12 +++++++++++ mm/maccess.c | 45 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h index b9e538176349c..c82dcea216b15 100644 --- a/include/linux/uaccess.h +++ b/include/linux/uaccess.h @@ -113,6 +113,18 @@ extern long probe_user_read(void *dst, const void __user *src, size_t size); extern long notrace probe_kernel_write(void *dst, const void *src, size_t size); extern long notrace __probe_kernel_write(void *dst, const void *src, size_t size); +/* + * probe_user_write(): safely attempt to write to a location in user space + * @dst: address to write to + * @src: pointer to the data that shall be written + * @size: size of the data chunk + * + * Safely write to address @dst from the buffer at @src. If a kernel fault + * happens, handle that and return -EFAULT. + */ +extern long notrace probe_user_write(void __user *dst, const void *src, size_t size); +extern long notrace __probe_user_write(void __user *dst, const void *src, size_t size); + extern long strncpy_from_unsafe(char *dst, const void *unsafe_addr, long count); extern long strncpy_from_unsafe_user(char *dst, const void __user *unsafe_addr, long count); diff --git a/mm/maccess.c b/mm/maccess.c index 78add1654b41a..18717e893a758 100644 --- a/mm/maccess.c +++ b/mm/maccess.c @@ -17,6 +17,18 @@ probe_read_common(void *dst, const void __user *src, size_t size) return ret ? -EFAULT : 0; } +static __always_inline long +probe_write_common(void __user *dst, const void *src, size_t size) +{ + long ret; + + pagefault_disable(); + ret = __copy_to_user_inatomic(dst, src, size); + pagefault_enable(); + + return ret ? -EFAULT : 0; +} + /** * probe_kernel_read(): safely attempt to read from a kernel-space location * @dst: pointer to the buffer that shall take the data @@ -84,6 +96,7 @@ EXPORT_SYMBOL_GPL(probe_user_read); * Safely write to address @dst from the buffer at @src. If a kernel fault * happens, handle that and return -EFAULT. */ + long __weak probe_kernel_write(void *dst, const void *src, size_t size) __attribute__((alias("__probe_kernel_write"))); @@ -93,15 +106,39 @@ long __probe_kernel_write(void *dst, const void *src, size_t size) mm_segment_t old_fs = get_fs(); set_fs(KERNEL_DS); - pagefault_disable(); - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size); - pagefault_enable(); + ret = probe_write_common((__force void __user *)dst, src, size); set_fs(old_fs); - return ret ? -EFAULT : 0; + return ret; } EXPORT_SYMBOL_GPL(probe_kernel_write); +/** + * probe_user_write(): safely attempt to write to a user-space location + * @dst: address to write to + * @src: pointer to the data that shall be written + * @size: size of the data chunk + * + * Safely write to address @dst from the buffer at @src. If a kernel fault + * happens, handle that and return -EFAULT. + */ + +long __weak probe_user_write(void __user *dst, const void *src, size_t size) + __attribute__((alias("__probe_user_write"))); + +long __probe_user_write(void __user *dst, const void *src, size_t size) +{ + long ret = -EFAULT; + mm_segment_t old_fs = get_fs(); + + set_fs(USER_DS); + if (access_ok(VERIFY_WRITE, dst, size)) + ret = probe_write_common(dst, src, size); + set_fs(old_fs); + + return ret; +} +EXPORT_SYMBOL_GPL(probe_user_write); /** * strncpy_from_unsafe: - Copy a NUL terminated string from unsafe address. From patchwork Fri Sep 11 12:46:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 264037 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 B265DC2BC11 for ; Fri, 11 Sep 2020 17:30:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6959D21D91 for ; Fri, 11 Sep 2020 17:30:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845437; bh=EiiP0Cy7h2YSUN8YWK8knFCIrF6N6SZO+8rzOImC+A8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=jxyxeOIYmAvHp3qE/mWSvl5bS2R3xFjB6J/oFB3+/lorf3emWkxBahlYMXEoCJpFD 1jF0drlqvTNx94eF5ssp/CDcyiOndr/V3NuBw0NMPPgxnJr+iNM7Q27p5Lk+l+LCJX jnx1yp1iyyn2ZaDgPJ8/DZblnYxUfUEOzzVqM+no= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726089AbgIKRag (ORCPT ); Fri, 11 Sep 2020 13:30:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:49260 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726093AbgIKM5a (ORCPT ); Fri, 11 Sep 2020 08:57:30 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 989012224D; Fri, 11 Sep 2020 12:55:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828918; bh=EiiP0Cy7h2YSUN8YWK8knFCIrF6N6SZO+8rzOImC+A8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oHpRx+RJ2MtHpXURPDa+CbY3F75sXvvp5XtypS6Mk3Ynip8u0olRu0Z2UzRYxo3eh YzpL9uXop1ipln3TSgOHNosVPEPEqQUJ4npC9VNrc5QlT3QeHmRMXgrPJYunxhJ08F ISa0LEZh1m5VJQ382pfMdLM/QkYdfjTvINI/TtZk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Filipe Manana , Josef Bacik , David Sterba , Sasha Levin Subject: [PATCH 4.4 28/62] btrfs: fix potential deadlock in the search ioctl Date: Fri, 11 Sep 2020 14:46:11 +0200 Message-Id: <20200911122503.793716871@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Josef Bacik [ Upstream commit a48b73eca4ceb9b8a4b97f290a065335dbcd8a04 ] With the conversion of the tree locks to rwsem I got the following lockdep splat: ====================================================== WARNING: possible circular locking dependency detected 5.8.0-rc7-00165-g04ec4da5f45f-dirty #922 Not tainted ------------------------------------------------------ compsize/11122 is trying to acquire lock: ffff889fabca8768 (&mm->mmap_lock#2){++++}-{3:3}, at: __might_fault+0x3e/0x90 but task is already holding lock: ffff889fe720fe40 (btrfs-fs-00){++++}-{3:3}, at: __btrfs_tree_read_lock+0x39/0x180 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #2 (btrfs-fs-00){++++}-{3:3}: down_write_nested+0x3b/0x70 __btrfs_tree_lock+0x24/0x120 btrfs_search_slot+0x756/0x990 btrfs_lookup_inode+0x3a/0xb4 __btrfs_update_delayed_inode+0x93/0x270 btrfs_async_run_delayed_root+0x168/0x230 btrfs_work_helper+0xd4/0x570 process_one_work+0x2ad/0x5f0 worker_thread+0x3a/0x3d0 kthread+0x133/0x150 ret_from_fork+0x1f/0x30 -> #1 (&delayed_node->mutex){+.+.}-{3:3}: __mutex_lock+0x9f/0x930 btrfs_delayed_update_inode+0x50/0x440 btrfs_update_inode+0x8a/0xf0 btrfs_dirty_inode+0x5b/0xd0 touch_atime+0xa1/0xd0 btrfs_file_mmap+0x3f/0x60 mmap_region+0x3a4/0x640 do_mmap+0x376/0x580 vm_mmap_pgoff+0xd5/0x120 ksys_mmap_pgoff+0x193/0x230 do_syscall_64+0x50/0x90 entry_SYSCALL_64_after_hwframe+0x44/0xa9 -> #0 (&mm->mmap_lock#2){++++}-{3:3}: __lock_acquire+0x1272/0x2310 lock_acquire+0x9e/0x360 __might_fault+0x68/0x90 _copy_to_user+0x1e/0x80 copy_to_sk.isra.32+0x121/0x300 search_ioctl+0x106/0x200 btrfs_ioctl_tree_search_v2+0x7b/0xf0 btrfs_ioctl+0x106f/0x30a0 ksys_ioctl+0x83/0xc0 __x64_sys_ioctl+0x16/0x20 do_syscall_64+0x50/0x90 entry_SYSCALL_64_after_hwframe+0x44/0xa9 other info that might help us debug this: Chain exists of: &mm->mmap_lock#2 --> &delayed_node->mutex --> btrfs-fs-00 Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(btrfs-fs-00); lock(&delayed_node->mutex); lock(btrfs-fs-00); lock(&mm->mmap_lock#2); *** DEADLOCK *** 1 lock held by compsize/11122: #0: ffff889fe720fe40 (btrfs-fs-00){++++}-{3:3}, at: __btrfs_tree_read_lock+0x39/0x180 stack backtrace: CPU: 17 PID: 11122 Comm: compsize Kdump: loaded Not tainted 5.8.0-rc7-00165-g04ec4da5f45f-dirty #922 Hardware name: Quanta Tioga Pass Single Side 01-0030993006/Tioga Pass Single Side, BIOS F08_3A18 12/20/2018 Call Trace: dump_stack+0x78/0xa0 check_noncircular+0x165/0x180 __lock_acquire+0x1272/0x2310 lock_acquire+0x9e/0x360 ? __might_fault+0x3e/0x90 ? find_held_lock+0x72/0x90 __might_fault+0x68/0x90 ? __might_fault+0x3e/0x90 _copy_to_user+0x1e/0x80 copy_to_sk.isra.32+0x121/0x300 ? btrfs_search_forward+0x2a6/0x360 search_ioctl+0x106/0x200 btrfs_ioctl_tree_search_v2+0x7b/0xf0 btrfs_ioctl+0x106f/0x30a0 ? __do_sys_newfstat+0x5a/0x70 ? ksys_ioctl+0x83/0xc0 ksys_ioctl+0x83/0xc0 __x64_sys_ioctl+0x16/0x20 do_syscall_64+0x50/0x90 entry_SYSCALL_64_after_hwframe+0x44/0xa9 The problem is we're doing a copy_to_user() while holding tree locks, which can deadlock if we have to do a page fault for the copy_to_user(). This exists even without my locking changes, so it needs to be fixed. Rework the search ioctl to do the pre-fault and then copy_to_user_nofault for the copying. CC: stable@vger.kernel.org # 4.4+ Reviewed-by: Filipe Manana Signed-off-by: Josef Bacik Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/extent_io.c | 8 ++++---- fs/btrfs/extent_io.h | 6 +++--- fs/btrfs/ioctl.c | 27 ++++++++++++++++++++------- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 2f9f738ecf84a..97a80238fdee3 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -5431,9 +5431,9 @@ void read_extent_buffer(const struct extent_buffer *eb, void *dstv, } } -int read_extent_buffer_to_user(const struct extent_buffer *eb, - void __user *dstv, - unsigned long start, unsigned long len) +int read_extent_buffer_to_user_nofault(const struct extent_buffer *eb, + void __user *dstv, + unsigned long start, unsigned long len) { size_t cur; size_t offset; @@ -5454,7 +5454,7 @@ int read_extent_buffer_to_user(const struct extent_buffer *eb, cur = min(len, (PAGE_CACHE_SIZE - offset)); kaddr = page_address(page); - if (copy_to_user(dst, kaddr + offset, cur)) { + if (probe_user_write(dst, kaddr + offset, cur)) { ret = -EFAULT; break; } diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h index 751435967724e..9631be7fc9e24 100644 --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h @@ -313,9 +313,9 @@ int memcmp_extent_buffer(const struct extent_buffer *eb, const void *ptrv, void read_extent_buffer(const struct extent_buffer *eb, void *dst, unsigned long start, unsigned long len); -int read_extent_buffer_to_user(const struct extent_buffer *eb, - void __user *dst, unsigned long start, - unsigned long len); +int read_extent_buffer_to_user_nofault(const struct extent_buffer *eb, + void __user *dst, unsigned long start, + unsigned long len); void write_extent_buffer(struct extent_buffer *eb, const void *src, unsigned long start, unsigned long len); void copy_extent_buffer(struct extent_buffer *dst, struct extent_buffer *src, diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 245a50f490f63..91a45ef69152d 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -2017,9 +2017,14 @@ static noinline int copy_to_sk(struct btrfs_root *root, sh.len = item_len; sh.transid = found_transid; - /* copy search result header */ - if (copy_to_user(ubuf + *sk_offset, &sh, sizeof(sh))) { - ret = -EFAULT; + /* + * Copy search result header. If we fault then loop again so we + * can fault in the pages and -EFAULT there if there's a + * problem. Otherwise we'll fault and then copy the buffer in + * properly this next time through + */ + if (probe_user_write(ubuf + *sk_offset, &sh, sizeof(sh))) { + ret = 0; goto out; } @@ -2027,10 +2032,14 @@ static noinline int copy_to_sk(struct btrfs_root *root, if (item_len) { char __user *up = ubuf + *sk_offset; - /* copy the item */ - if (read_extent_buffer_to_user(leaf, up, - item_off, item_len)) { - ret = -EFAULT; + /* + * Copy the item, same behavior as above, but reset the + * * sk_offset so we copy the full thing again. + */ + if (read_extent_buffer_to_user_nofault(leaf, up, + item_off, item_len)) { + ret = 0; + *sk_offset -= sizeof(sh); goto out; } @@ -2120,6 +2129,10 @@ static noinline int search_ioctl(struct inode *inode, key.offset = sk->min_offset; while (1) { + ret = fault_in_pages_writeable(ubuf, *buf_size - sk_offset); + if (ret) + break; + ret = btrfs_search_forward(root, &key, path, sk->min_transid); if (ret != 0) { if (ret > 0) From patchwork Fri Sep 11 12:46:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 309788 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, 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 8790FC43461 for ; Fri, 11 Sep 2020 17:28:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 486F5221E7 for ; Fri, 11 Sep 2020 17:28:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845284; bh=QVdzqYJERNYRtJmuQaJEbs6c3WcsGmTTOuf7J3MmMTo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=eU3UG6AjiGnzilqnpiT71MR7vU6cSENK9wZFQS2Kut6zYFpghCwfQ/6rTqGdOupOh atbY9GVsLrLIwzzRpZFuwoRLx40cOGInYUPZxPQjoJ+o/nCiFQWi1QVBcw3sSRKxlj pgING1Z6pt3AQSyr5DlNCCaS7zev1Ii3sJcW63ws= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726113AbgIKR1A (ORCPT ); Fri, 11 Sep 2020 13:27:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:49870 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726098AbgIKM6D (ORCPT ); Fri, 11 Sep 2020 08:58:03 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 2C8632224E; Fri, 11 Sep 2020 12:55:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828920; bh=QVdzqYJERNYRtJmuQaJEbs6c3WcsGmTTOuf7J3MmMTo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QVWUOM7qk0sep5DlD4ZqSFVSAGfC7X2F0QStWmFnnDTpsVVDb2C95c4znMmyLap6U DWyhiaDkbwCskEjM7EBETq0nidnhyNUmbAOm27bzeA8QEYFAjT/qDjiI8tX1q8kSuh DVmQFTdJWaVDjlkS2FHj6oYnINr2eOoSyzqzBdhk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?utf-8?q?Bj=C3=B8rn_Mork?= , "David S. Miller" , Sasha Levin Subject: [PATCH 4.4 29/62] net: qmi_wwan: MDM9x30 specific power management Date: Fri, 11 Sep 2020 14:46:12 +0200 Message-Id: <20200911122503.848342627@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Bjørn Mork [ Upstream commit 93725149794d3d418cf1eddcae60c7b536c5faa1 ] MDM9x30 based modems appear to go into a deeper sleep when suspended without "Remote Wakeup" enabled. The QMI interface will not respond unless a "set DTR" control request is sent on resume. The effect is similar to a QMI_CTL SYNC request, resetting (some of) the firmware state. We allow userspace sessions to span multiple character device open/close sequences. This means that userspace can depend on firmware state while both the netdev and the character device are closed. We have disabled "needs_remote_wakeup" at this point to allow devices without remote wakeup support to be auto-suspended. To make sure the MDM9x30 keeps firmware state, we need to keep "needs_remote_wakeup" always set. We also need to issue a "set DTR" request to enable the QMI interface. Signed-off-by: Bjørn Mork Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/usb/qmi_wwan.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c index 4391430e25273..b8b15deb94bdb 100644 --- a/drivers/net/usb/qmi_wwan.c +++ b/drivers/net/usb/qmi_wwan.c @@ -223,6 +223,20 @@ err: return rv; } +/* Send CDC SetControlLineState request, setting or clearing the DTR. + * "Required for Autoconnect and 9x30 to wake up" according to the + * GobiNet driver. The requirement has been verified on an MDM9230 + * based Sierra Wireless MC7455 + */ +static int qmi_wwan_change_dtr(struct usbnet *dev, bool on) +{ + u8 intf = dev->intf->cur_altsetting->desc.bInterfaceNumber; + + return usbnet_write_cmd(dev, USB_CDC_REQ_SET_CONTROL_LINE_STATE, + USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, + on ? 0x01 : 0x00, intf, NULL, 0); +} + static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf) { int status = -1; @@ -280,6 +294,24 @@ static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf) usb_driver_release_interface(driver, info->data); } + /* disabling remote wakeup on MDM9x30 devices has the same + * effect as clearing DTR. The device will not respond to QMI + * requests until we set DTR again. This is similar to a + * QMI_CTL SYNC request, clearing a lot of firmware state + * including the client ID allocations. + * + * Our usage model allows a session to span multiple + * open/close events, so we must prevent the firmware from + * clearing out state the clients might need. + * + * MDM9x30 is the first QMI chipset with USB3 support. Abuse + * this fact to enable the quirk. + */ + if (le16_to_cpu(dev->udev->descriptor.bcdUSB) >= 0x0201) { + qmi_wwan_manage_power(dev, 1); + qmi_wwan_change_dtr(dev, true); + } + /* Never use the same address on both ends of the link, even if the * buggy firmware told us to. Or, if device is assigned the well-known * buggy firmware MAC address, replace it with a random address, @@ -307,6 +339,12 @@ static void qmi_wwan_unbind(struct usbnet *dev, struct usb_interface *intf) if (info->subdriver && info->subdriver->disconnect) info->subdriver->disconnect(info->control); + /* disable MDM9x30 quirk */ + if (le16_to_cpu(dev->udev->descriptor.bcdUSB) >= 0x0201) { + qmi_wwan_change_dtr(dev, false); + qmi_wwan_manage_power(dev, 0); + } + /* allow user to unbind using either control or data */ if (intf == info->control) other = info->data; From patchwork Fri Sep 11 12:46:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 309789 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, 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 89FF8C43461 for ; Fri, 11 Sep 2020 17:27:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3656122207 for ; Fri, 11 Sep 2020 17:27:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845271; bh=ErgS5X/gUlqE1NGx7KCtUCChZKuAqXCDjwsW1zl/zAM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=f4T+58lg1grkp7BC4Zcgq1a7Iq2KLTjcSbLXPQiKlPk+lEzkHI+jAiy060My6Ng2J GQa6zzlGtrP5yGSmiq0DQGpgrBykMoSgppQOAGB03xPmiaZfvp2ZLQLkbct2rhJNaR OSqq/EDZJCkSMVa2CDWv9JE1ywk60hdR+uf/XeS8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726306AbgIKR1B (ORCPT ); Fri, 11 Sep 2020 13:27:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:49248 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726099AbgIKM6C (ORCPT ); Fri, 11 Sep 2020 08:58:02 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 C2C462220D; Fri, 11 Sep 2020 12:55:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828923; bh=ErgS5X/gUlqE1NGx7KCtUCChZKuAqXCDjwsW1zl/zAM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dbA1Ifgis9lU9+crGon2Ry/XFdfXY8LjkrzzwTpg2keATBlQxhIlTauSaSQAMZ6oS GKhId1VEQxMYhSuD1wEUZRl/pIq+iRYG1x0l+SAn8UeAcfOkUqcNwjze/xNOHGkbUk DLLSnQNciTOObJtBiVfzd3x8nzVfgB99k+9GVFX4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?utf-8?q?Bj=C3=B8rn_Mork?= , "David S. Miller" , Sasha Levin Subject: [PATCH 4.4 30/62] net: qmi_wwan: support "raw IP" mode Date: Fri, 11 Sep 2020 14:46:13 +0200 Message-Id: <20200911122503.897520687@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Bjørn Mork [ Upstream commit 32f7adf633b9f99ad5089901bc7ebff57704aaa9 ] QMI wwan devices have traditionally emulated ethernet devices by default. But they have always had the capability of operating without any L2 header at all, transmitting and receiving "raw" IP packets over the USB link. This firmware feature used to be configurable through the QMI management protocol. Traditionally there was no way to verify the firmware mode without attempting to change it. And the firmware would often disallow changes anyway, i.e. due to a session already being established. In some cases, this could be a hidden firmware internal session, completely outside host control. For these reasons, sticking with the "well known" default mode was safest. But newer generations of QMI hardware and firmware have moved towards defaulting to "raw IP" mode instead, followed by an increasing number of bugs in the already buggy "802.3" firmware implementation. At the same time, the QMI management protocol gained the ability to detect the current mode. This has enabled the userspace QMI management application to verify the current firmware mode without trying to modify it. Following this development, the latest QMI hardware and firmware (the MDM9x30 generation) has dropped support for "802.3" mode entirely. Support for "raw IP" framing in the driver is therefore necessary for these devices, and to a certain degree to work around problems with the previous generation, This patch adds support for "raw IP" framing for QMI devices, changing the netdev from an ethernet device to an ARPHRD_NONE p-t-p device when "raw IP" framing is enabled. The firmware setup is fully delegated to the QMI userspace management application, through simple tunneling of the QMI protocol. The driver will therefore not know which mode has been "negotiated" between firmware and userspace. Allowing userspace to inform the driver of the result through a sysfs switch is considered a better alternative than to change the well established clean delegation of firmware management to userspace. Signed-off-by: Bjørn Mork Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/usb/qmi_wwan.c | 98 +++++++++++++++++++++++++++++++++++++- 1 file changed, 97 insertions(+), 1 deletion(-) diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c index b8b15deb94bdb..d6ecb3ac25b6c 100644 --- a/drivers/net/usb/qmi_wwan.c +++ b/drivers/net/usb/qmi_wwan.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -48,11 +49,93 @@ struct qmi_wwan_state { struct usb_driver *subdriver; atomic_t pmcount; - unsigned long unused; + unsigned long flags; struct usb_interface *control; struct usb_interface *data; }; +enum qmi_wwan_flags { + QMI_WWAN_FLAG_RAWIP = 1 << 0, +}; + +static void qmi_wwan_netdev_setup(struct net_device *net) +{ + struct usbnet *dev = netdev_priv(net); + struct qmi_wwan_state *info = (void *)&dev->data; + + if (info->flags & QMI_WWAN_FLAG_RAWIP) { + net->header_ops = NULL; /* No header */ + net->type = ARPHRD_NONE; + net->hard_header_len = 0; + net->addr_len = 0; + net->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST; + netdev_dbg(net, "mode: raw IP\n"); + } else if (!net->header_ops) { /* don't bother if already set */ + ether_setup(net); + netdev_dbg(net, "mode: Ethernet\n"); + } + + /* recalculate buffers after changing hard_header_len */ + usbnet_change_mtu(net, net->mtu); +} + +static ssize_t raw_ip_show(struct device *d, struct device_attribute *attr, char *buf) +{ + struct usbnet *dev = netdev_priv(to_net_dev(d)); + struct qmi_wwan_state *info = (void *)&dev->data; + + return sprintf(buf, "%c\n", info->flags & QMI_WWAN_FLAG_RAWIP ? 'Y' : 'N'); +} + +static ssize_t raw_ip_store(struct device *d, struct device_attribute *attr, const char *buf, size_t len) +{ + struct usbnet *dev = netdev_priv(to_net_dev(d)); + struct qmi_wwan_state *info = (void *)&dev->data; + bool enable; + int err; + + if (strtobool(buf, &enable)) + return -EINVAL; + + /* no change? */ + if (enable == (info->flags & QMI_WWAN_FLAG_RAWIP)) + return len; + + /* we don't want to modify a running netdev */ + if (netif_running(dev->net)) { + netdev_err(dev->net, "Cannot change a running device\n"); + return -EBUSY; + } + + /* let other drivers deny the change */ + err = call_netdevice_notifiers(NETDEV_PRE_TYPE_CHANGE, dev->net); + err = notifier_to_errno(err); + if (err) { + netdev_err(dev->net, "Type change was refused\n"); + return err; + } + + if (enable) + info->flags |= QMI_WWAN_FLAG_RAWIP; + else + info->flags &= ~QMI_WWAN_FLAG_RAWIP; + qmi_wwan_netdev_setup(dev->net); + call_netdevice_notifiers(NETDEV_POST_TYPE_CHANGE, dev->net); + return len; +} + +static DEVICE_ATTR_RW(raw_ip); + +static struct attribute *qmi_wwan_sysfs_attrs[] = { + &dev_attr_raw_ip.attr, + NULL, +}; + +static struct attribute_group qmi_wwan_sysfs_attr_group = { + .name = "qmi", + .attrs = qmi_wwan_sysfs_attrs, +}; + /* default ethernet address used by the modem */ static const u8 default_modem_addr[ETH_ALEN] = {0x02, 0x50, 0xf3}; @@ -80,6 +163,8 @@ static const u8 buggy_fw_addr[ETH_ALEN] = {0x00, 0xa0, 0xc6, 0x00, 0x00, 0x00}; */ static int qmi_wwan_rx_fixup(struct usbnet *dev, struct sk_buff *skb) { + struct qmi_wwan_state *info = (void *)&dev->data; + bool rawip = info->flags & QMI_WWAN_FLAG_RAWIP; __be16 proto; /* This check is no longer done by usbnet */ @@ -94,15 +179,25 @@ static int qmi_wwan_rx_fixup(struct usbnet *dev, struct sk_buff *skb) proto = htons(ETH_P_IPV6); break; case 0x00: + if (rawip) + return 0; if (is_multicast_ether_addr(skb->data)) return 1; /* possibly bogus destination - rewrite just in case */ skb_reset_mac_header(skb); goto fix_dest; default: + if (rawip) + return 0; /* pass along other packets without modifications */ return 1; } + if (rawip) { + skb->dev = dev->net; /* normally set by eth_type_trans */ + skb->protocol = proto; + return 1; + } + if (skb_headroom(skb) < ETH_HLEN) return 0; skb_push(skb, ETH_HLEN); @@ -326,6 +421,7 @@ static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf) dev->net->dev_addr[0] &= 0xbf; /* clear "IP" bit */ } dev->net->netdev_ops = &qmi_wwan_netdev_ops; + dev->net->sysfs_groups[0] = &qmi_wwan_sysfs_attr_group; err: return status; } From patchwork Fri Sep 11 12:46:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 309844 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 3441FC43461 for ; Fri, 11 Sep 2020 13:00:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CDC8F22225 for ; Fri, 11 Sep 2020 13:00:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599829214; bh=brcKNu2ORnGKULw+kDsMkGQh6xr/uZBWwy3gj7LfanI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ptPQYPbSXm2SwKdCIUDHs8wvcywWKfCm8c1Z+mOp10MnTHM6/ceeyP4QHU/0RwEdQ b37saBsdpcRE6MEOf2CWvrBbeXwUoxar2jVVBX/wLbSLe8wb+TvbefXWpubd2C0flT EyiPmsGgXwSUhp5kNNv/Wza/EjBXmQUWP29x0k3E= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726141AbgIKNAG (ORCPT ); Fri, 11 Sep 2020 09:00:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:49868 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726108AbgIKM6D (ORCPT ); Fri, 11 Sep 2020 08:58:03 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 469FE22250; Fri, 11 Sep 2020 12:55:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828925; bh=brcKNu2ORnGKULw+kDsMkGQh6xr/uZBWwy3gj7LfanI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R15wBlCPCeK4eXCSlUrinJuQ7DB5cbCTL7xGOT/vA1OX8NtxQasrLf5U7B2icP5cL XBl988WtpUwYiRDkcOrAkFG0+1Hgimpc2VlA4tAkQVKrwbkEutx5tk+OjN5GE3W6Zq V652JmDZgSnmpWG1WIOhWMi7Z1RPTLeySO+lEQds= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?utf-8?q?Bj=C3=B8rn_Mork?= , "David S. Miller" , Sasha Levin Subject: [PATCH 4.4 31/62] net: qmi_wwan: should hold RTNL while changing netdev type Date: Fri, 11 Sep 2020 14:46:14 +0200 Message-Id: <20200911122503.945511729@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Bjørn Mork [ Upstream commit 6c730080e663b1d629f8aa89348291fbcdc46cd9 ] The notifier calls were thrown in as a last-minute fix for an imagined "this device could be part of a bridge" problem. That revealed a certain lack of locking. Not to mention testing... Avoid this splat: RTNL: assertion failed at net/core/dev.c (1639) CPU: 0 PID: 4293 Comm: bash Not tainted 4.4.0-rc3+ #358 Hardware name: LENOVO 2776LEG/2776LEG, BIOS 6EET55WW (3.15 ) 12/19/2011 0000000000000000 ffff8800ad253d60 ffffffff8122f7cf ffff8800ad253d98 ffff8800ad253d88 ffffffff813833ab 0000000000000002 ffff880230f48560 ffff880230a12900 ffff8800ad253da0 ffffffff813833da 0000000000000002 Call Trace: [] dump_stack+0x4b/0x63 [] call_netdevice_notifiers_info+0x3d/0x59 [] call_netdevice_notifiers+0x13/0x15 [] raw_ip_store+0x81/0x193 [qmi_wwan] [] dev_attr_store+0x20/0x22 [] sysfs_kf_write+0x49/0x50 [] kernfs_fop_write+0x10a/0x151 [] __vfs_write+0x26/0xa5 [] ? percpu_down_read+0x53/0x7f [] ? __sb_start_write+0x5f/0xb0 [] ? __sb_start_write+0x5f/0xb0 [] vfs_write+0xa3/0xe7 [] SyS_write+0x50/0x7e [] entry_SYSCALL_64_fastpath+0x12/0x6f Fixes: 32f7adf633b9 ("net: qmi_wwan: support "raw IP" mode") Signed-off-by: Bjørn Mork Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/usb/qmi_wwan.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c index d6ecb3ac25b6c..e75e984483bc5 100644 --- a/drivers/net/usb/qmi_wwan.c +++ b/drivers/net/usb/qmi_wwan.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -92,7 +93,7 @@ static ssize_t raw_ip_store(struct device *d, struct device_attribute *attr, co struct usbnet *dev = netdev_priv(to_net_dev(d)); struct qmi_wwan_state *info = (void *)&dev->data; bool enable; - int err; + int ret; if (strtobool(buf, &enable)) return -EINVAL; @@ -101,18 +102,22 @@ static ssize_t raw_ip_store(struct device *d, struct device_attribute *attr, co if (enable == (info->flags & QMI_WWAN_FLAG_RAWIP)) return len; + if (!rtnl_trylock()) + return restart_syscall(); + /* we don't want to modify a running netdev */ if (netif_running(dev->net)) { netdev_err(dev->net, "Cannot change a running device\n"); - return -EBUSY; + ret = -EBUSY; + goto err; } /* let other drivers deny the change */ - err = call_netdevice_notifiers(NETDEV_PRE_TYPE_CHANGE, dev->net); - err = notifier_to_errno(err); - if (err) { + ret = call_netdevice_notifiers(NETDEV_PRE_TYPE_CHANGE, dev->net); + ret = notifier_to_errno(ret); + if (ret) { netdev_err(dev->net, "Type change was refused\n"); - return err; + goto err; } if (enable) @@ -121,7 +126,10 @@ static ssize_t raw_ip_store(struct device *d, struct device_attribute *attr, co info->flags &= ~QMI_WWAN_FLAG_RAWIP; qmi_wwan_netdev_setup(dev->net); call_netdevice_notifiers(NETDEV_POST_TYPE_CHANGE, dev->net); - return len; + ret = len; +err: + rtnl_unlock(); + return ret; } static DEVICE_ATTR_RW(raw_ip); From patchwork Fri Sep 11 12:46:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 309772 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, 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 57AF2C43461 for ; Fri, 11 Sep 2020 17:34:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 14F97221E7 for ; Fri, 11 Sep 2020 17:34:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845655; bh=ks8FBRzzE0qli1nkpe2h0FyERehMi7N5X63Tf043nKE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=plV/yQrep1X+HXu2UAYIJ+KbtittELwf19hKLERMSWyVqYO1QDAm/AzawUB2Bmzcg 84ocRGgHq0RF9e5rsgkeNKCJg2KHdByOFjZhwwWUf1TvP1a919EIJSAfuYwdVQW4SI ykFX5juXwbuGmopxPlAkLCzmM/pqg3+aJ6U85RIs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726387AbgIKRcq (ORCPT ); Fri, 11 Sep 2020 13:32:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:49240 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726018AbgIKMzK (ORCPT ); Fri, 11 Sep 2020 08:55:10 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 0C2962222D; Fri, 11 Sep 2020 12:54:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828852; bh=ks8FBRzzE0qli1nkpe2h0FyERehMi7N5X63Tf043nKE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f9Ry2WnfRW0mrjuEH9qCDadX/JQJuTn3XliQ/iiDtDXuO8UBFjLVJHr/3M6fkd236 Dr0x0+tuoxpVQYfpE36igcAn3+1Ppv7+rwa9LyTOzsaVmi4geXNAqNZ8QP1uShkj7Q 3dF+051x2Igr5IHRg5as1/mgHhoF5zDcd1kHkb6U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kanerva Topi , =?utf-8?q?Bj=C3=B8rn_Mork?= , "David S. Miller" , Sasha Levin Subject: [PATCH 4.4 32/62] net: qmi_wwan: ignore bogus CDC Union descriptors Date: Fri, 11 Sep 2020 14:46:15 +0200 Message-Id: <20200911122503.996071501@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Bjørn Mork [ Upstream commit 34a55d5e858e81a20d33fd9490149d6a1058be0c ] The CDC descriptors found on these vendor specific functions should not be considered authoritative. They seem to be ignored by drivers for other systems, and the quality is therefore low. One device (1e0e:9001) has been reported to have such a bogus union descriptor on the QMI function, making it fail probing even if the device id was dynamically added. The report was not complete enough to allow adding a device entry for this modem. But this should at least fix the dynamic id probing problem. Reported-by: Kanerva Topi Signed-off-by: Bjørn Mork Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/usb/qmi_wwan.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c index e75e984483bc5..f8d00846b4a59 100644 --- a/drivers/net/usb/qmi_wwan.c +++ b/drivers/net/usb/qmi_wwan.c @@ -374,7 +374,10 @@ static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf) "bogus CDC Union: master=%u, slave=%u\n", cdc_union->bMasterInterface0, cdc_union->bSlaveInterface0); - goto err; + + /* ignore and continue... */ + cdc_union = NULL; + info->data = intf; } } From patchwork Fri Sep 11 12:46:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 309847 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 3DCCAC43461 for ; Fri, 11 Sep 2020 12:57:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E744D222B8 for ; Fri, 11 Sep 2020 12:57:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599829034; bh=PzYoJXKrSnqCth4TYncDPbCZXJWhG5/jzJXPUlAr6dE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=wyFLNl5tL16f9uu0iO+eidHL297d0EJEZy9dSVWVzLpq7AptmBhS+jCUBLckqL7Kt uHRg1BHdfe0+UYJF9fMi9h6Bk8bmlARIQobFzF0vG2xVHA6Dx8OtDkEKCNNn8IhBm4 AS6ELOhbh9U9rHevP603P4m+wjId+TgrVL7CaKT4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726086AbgIKM4v (ORCPT ); Fri, 11 Sep 2020 08:56:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:49674 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726021AbgIKMzK (ORCPT ); Fri, 11 Sep 2020 08:55:10 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 88DC62222E; Fri, 11 Sep 2020 12:54:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828855; bh=PzYoJXKrSnqCth4TYncDPbCZXJWhG5/jzJXPUlAr6dE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gERwoZzxJ1XsJJ/JJHER8cIsnBZu914M2DkriOFuHWhfDkdiPjg7stxg0PcZPfcUl PGyEM8uJXObP/4Q20uIh3MOWQ/g93+dHXcz4iPFojgd75/3FAOMOcR3WbzSt9hnEjL S1ql0f1TqhmAxXTiFa5QPAPcprJ5a9GpChH+5MoI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Patrik Halfar , "David S. Miller" , Sasha Levin Subject: [PATCH 4.4 33/62] Add Dell Wireless 5809e Gobi 4G HSPA+ Mobile Broadband Card (rev3) to qmi_wwan Date: Fri, 11 Sep 2020 14:46:16 +0200 Message-Id: <20200911122504.043662497@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Patrik Halfar [ Upstream commit fb5eb24cdd5cdb83be77d3e4b2f16e92e06bd9e9 ] New revison of Dell Wireless 5809e Gobi 4G HSPA+ Mobile Broadband Card has new idProduct Bus 002 Device 006: ID 413c:81b3 Dell Computer Corp. Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 0 bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 64 idVendor 0x413c Dell Computer Corp. idProduct 0x81b3 bcdDevice 0.06 iManufacturer 1 Sierra Wireless, Incorporated iProduct 2 Dell Wireless 5809e Gobiâ„¢ 4G HSPA+ Mobile Broadband Card iSerial 3 bNumConfigurations 2 Signed-off-by: Patrik Halfar Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/usb/qmi_wwan.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c index f8d00846b4a59..977df611164a6 100644 --- a/drivers/net/usb/qmi_wwan.c +++ b/drivers/net/usb/qmi_wwan.c @@ -913,6 +913,7 @@ static const struct usb_device_id products[] = { {QMI_FIXED_INTF(0x413c, 0x81a8, 8)}, /* Dell Wireless 5808 Gobi(TM) 4G LTE Mobile Broadband Card */ {QMI_FIXED_INTF(0x413c, 0x81a9, 8)}, /* Dell Wireless 5808e Gobi(TM) 4G LTE Mobile Broadband Card */ {QMI_FIXED_INTF(0x413c, 0x81b1, 8)}, /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card */ + {QMI_FIXED_INTF(0x413c, 0x81b3, 8)}, /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card (rev3) */ {QMI_FIXED_INTF(0x03f0, 0x4e1d, 8)}, /* HP lt4111 LTE/EV-DO/HSPA+ Gobi 4G Module */ {QMI_FIXED_INTF(0x03f0, 0x9d1d, 1)}, /* HP lt4120 Snapdragon X5 LTE */ {QMI_FIXED_INTF(0x22de, 0x9061, 3)}, /* WeTelecom WPD-600N */ From patchwork Fri Sep 11 12:46:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 264029 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 33E52C433E2 for ; Fri, 11 Sep 2020 17:32:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EBF2A221E7 for ; Fri, 11 Sep 2020 17:32:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845567; bh=QPYBtG8DEvhAdZkAPODVw70d/QOR5jMrzDGOOq4q1Zc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=mItOrdhnTJEksdPamkfRgFA1lf2sHyIROQTzGYKIwF2QgWxE0dQBnf6W7DOcTG4ct ghxVv6o83FiE47FPRZnRUylSuRkb3mk/H56bVQQXJh+x+6KGq33XxBItdiWSp4Du2w cDb74EKJ5AO7bJDH6qFrqwZIeHaZdPzmPp6eIfqI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726058AbgIKRcq (ORCPT ); Fri, 11 Sep 2020 13:32:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:49242 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726054AbgIKMzU (ORCPT ); Fri, 11 Sep 2020 08:55:20 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 EB1872223C; Fri, 11 Sep 2020 12:54:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828857; bh=QPYBtG8DEvhAdZkAPODVw70d/QOR5jMrzDGOOq4q1Zc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DtUR3Kzu29+0Nlc7AI0tIhyDdRmkDNzuoL+NznLTPezCFuEhBxhnD+qBgxlbDKqX8 j/VrKlWTUk732prE7rhzWSFVGZm2tywYobv78IagBD799Ll83RkWpik+y0l0ubCxig DX2r1W2LwEwyio4agIfW6/L6G6gWfw+LLz14pDS4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hans-Christoph Schemmel , =?utf-8?q?Bj=C3=B8rn_Mork?= , "David S. Miller" , Sasha Levin Subject: [PATCH 4.4 34/62] qmi_wwan: Added support for Gemaltos Cinterion PHxx WWAN interface Date: Fri, 11 Sep 2020 14:46:17 +0200 Message-Id: <20200911122504.092114873@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Schemmel Hans-Christoph [ Upstream commit bd9e33508c5e1eb5d807d11d7bfc52125fcdb04e ] Added support for Gemalto's Cinterion PHxx WWAN interfaces by adding QMI_FIXED_INTF with Cinterion's VID and PID. PHxx can have: 2 RmNet Interfaces (PID 0x0082) or 1 RmNet + 1 USB Audio interface (PID 0x0083). Signed-off-by: Hans-Christoph Schemmel Acked-by: Bjørn Mork Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/usb/qmi_wwan.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c index 977df611164a6..ec03cf1f107bc 100644 --- a/drivers/net/usb/qmi_wwan.c +++ b/drivers/net/usb/qmi_wwan.c @@ -907,6 +907,9 @@ static const struct usb_device_id products[] = { {QMI_FIXED_INTF(0x0b3c, 0xc00b, 4)}, /* Olivetti Olicard 500 */ {QMI_FIXED_INTF(0x1e2d, 0x0060, 4)}, /* Cinterion PLxx */ {QMI_FIXED_INTF(0x1e2d, 0x0053, 4)}, /* Cinterion PHxx,PXxx */ + {QMI_FIXED_INTF(0x1e2d, 0x0082, 4)}, /* Cinterion PHxx,PXxx (2 RmNet) */ + {QMI_FIXED_INTF(0x1e2d, 0x0082, 5)}, /* Cinterion PHxx,PXxx (2 RmNet) */ + {QMI_FIXED_INTF(0x1e2d, 0x0083, 4)}, /* Cinterion PHxx,PXxx (1 RmNet + USB Audio)*/ {QMI_FIXED_INTF(0x413c, 0x81a2, 8)}, /* Dell Wireless 5806 Gobi(TM) 4G LTE Mobile Broadband Card */ {QMI_FIXED_INTF(0x413c, 0x81a3, 8)}, /* Dell Wireless 5570 HSPA+ (42Mbps) Mobile Broadband Card */ {QMI_FIXED_INTF(0x413c, 0x81a4, 8)}, /* Dell Wireless 5570e HSPA+ (42Mbps) Mobile Broadband Card */ From patchwork Fri Sep 11 12:46:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 264105 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 25F84C43461 for ; Fri, 11 Sep 2020 12:58:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B82B4223D6 for ; Fri, 11 Sep 2020 12:58:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599829114; bh=6NJTXH9H75nCwxHAINVLGrcAIuAzlW7RQ8pGyZWdLZo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=XZ812meOdJ3GQB9VX4vvC7XbLxhMT7wUm7k3ekFTqbaG7tnxTwOqfER0Kd6VNHiwx Uz/Zg9DNUQ9vBZlpcfIyzwK3r1QGNrhbOWCtmMYEF0S393mLUyt9P9lBCUZBVs7UA/ Nb5QBuFWB6BQAtH4Ezyds0k5VMSVUCl663KgKLIs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726048AbgIKM6C (ORCPT ); Fri, 11 Sep 2020 08:58:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:49794 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726055AbgIKMzU (ORCPT ); Fri, 11 Sep 2020 08:55:20 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 941762223E; Fri, 11 Sep 2020 12:54:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828860; bh=6NJTXH9H75nCwxHAINVLGrcAIuAzlW7RQ8pGyZWdLZo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d3Svc6qNVfScrk9sX2zjawfqjfvsAUq+H8amrKG3U8o/wfyfV+CwyReJpmGnElWvl 1LgnvlwPSDLKqzRiOPmZHmoeu75ECxG08b+N1rhleK2G36bD0lgumMrMHV2gXuan66 r5WzkF1LZNuBhhTwxsadMtHvmdorWCfd8N3SKJTw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?utf-8?q?Bj=C3=B8rn_Mork?= , "David S. Miller" , Sasha Levin , Sebastian Sjoholm Subject: [PATCH 4.4 35/62] qmi_wwan: add support for Quectel EC21 and EC25 Date: Fri, 11 Sep 2020 14:46:18 +0200 Message-Id: <20200911122504.143707128@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Bjørn Mork [ Upstream commit 9a765881bf3dcd32847d7108cf48cb04a4ed993f ] The Quectel EC21 and EC25 need the same "set DTR" request as devices based on the MDM9230 chipset, but has no USB3 support. Our best guess is that the "set DTR" functionality depends on chipset and/or baseband firmware generation. But USB3 is still an optional feature. Since we cannot enable this unconditionally for all older devices, and there doesn't appear to be anything we can use in the USB descriptors to identify these chips, we are forced to use a device specific quirk flag. Reported-and-tested-by: Sebastian Sjoholm Signed-off-by: Bjørn Mork Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/usb/qmi_wwan.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c index ec03cf1f107bc..ffb2499a222da 100644 --- a/drivers/net/usb/qmi_wwan.c +++ b/drivers/net/usb/qmi_wwan.c @@ -59,6 +59,10 @@ enum qmi_wwan_flags { QMI_WWAN_FLAG_RAWIP = 1 << 0, }; +enum qmi_wwan_quirks { + QMI_WWAN_QUIRK_DTR = 1 << 0, /* needs "set DTR" request */ +}; + static void qmi_wwan_netdev_setup(struct net_device *net) { struct usbnet *dev = netdev_priv(net); @@ -411,9 +415,14 @@ static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf) * clearing out state the clients might need. * * MDM9x30 is the first QMI chipset with USB3 support. Abuse - * this fact to enable the quirk. + * this fact to enable the quirk for all USB3 devices. + * + * There are also chipsets with the same "set DTR" requirement + * but without USB3 support. Devices based on these chips + * need a quirk flag in the device ID table. */ - if (le16_to_cpu(dev->udev->descriptor.bcdUSB) >= 0x0201) { + if (dev->driver_info->data & QMI_WWAN_QUIRK_DTR || + le16_to_cpu(dev->udev->descriptor.bcdUSB) >= 0x0201) { qmi_wwan_manage_power(dev, 1); qmi_wwan_change_dtr(dev, true); } @@ -526,6 +535,16 @@ static const struct driver_info qmi_wwan_info = { .rx_fixup = qmi_wwan_rx_fixup, }; +static const struct driver_info qmi_wwan_info_quirk_dtr = { + .description = "WWAN/QMI device", + .flags = FLAG_WWAN, + .bind = qmi_wwan_bind, + .unbind = qmi_wwan_unbind, + .manage_power = qmi_wwan_manage_power, + .rx_fixup = qmi_wwan_rx_fixup, + .data = QMI_WWAN_QUIRK_DTR, +}; + #define HUAWEI_VENDOR_ID 0x12D1 /* map QMI/wwan function by a fixed interface number */ @@ -533,6 +552,11 @@ static const struct driver_info qmi_wwan_info = { USB_DEVICE_INTERFACE_NUMBER(vend, prod, num), \ .driver_info = (unsigned long)&qmi_wwan_info +/* devices requiring "set DTR" quirk */ +#define QMI_QUIRK_SET_DTR(vend, prod, num) \ + USB_DEVICE_INTERFACE_NUMBER(vend, prod, num), \ + .driver_info = (unsigned long)&qmi_wwan_info_quirk_dtr + /* Gobi 1000 QMI/wwan interface number is 3 according to qcserial */ #define QMI_GOBI1K_DEVICE(vend, prod) \ QMI_FIXED_INTF(vend, prod, 3) @@ -921,6 +945,8 @@ static const struct usb_device_id products[] = { {QMI_FIXED_INTF(0x03f0, 0x9d1d, 1)}, /* HP lt4120 Snapdragon X5 LTE */ {QMI_FIXED_INTF(0x22de, 0x9061, 3)}, /* WeTelecom WPD-600N */ {QMI_FIXED_INTF(0x1e0e, 0x9001, 5)}, /* SIMCom 7230E */ + {QMI_QUIRK_SET_DTR(0x2c7c, 0x0125, 4)}, /* Quectel EC25, EC20 R2.0 Mini PCIe */ + {QMI_QUIRK_SET_DTR(0x2c7c, 0x0121, 4)}, /* Quectel EC21 Mini PCIe */ /* 4. Gobi 1000 devices */ {QMI_GOBI1K_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */ From patchwork Fri Sep 11 12:46:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 264033 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 02025C433E2 for ; Fri, 11 Sep 2020 17:31:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B8BBA22205 for ; Fri, 11 Sep 2020 17:31:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845476; bh=OvGlPySaLooJfRF8h/ybUnhPjoQM+UqHv0gL8PVKjwc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=JDl3v41gFiZnVgWGfHBWPfjnWFf2BXpTVOO4k+hISyrRciSxdyraoILz5fy11uKIc J5ulj5R0sFg0O/yNr8wxRALwarflqMYrlThOIn3Mby+UvKdzGYkKnC9DQNi9CzUDpq GJ+82kt0S85t+ZN+ON+1M2sEVJmNz+9vI/1Fky3A= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726198AbgIKRbO (ORCPT ); Fri, 11 Sep 2020 13:31:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:49868 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726063AbgIKMzd (ORCPT ); Fri, 11 Sep 2020 08:55:33 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 0103022240; Fri, 11 Sep 2020 12:54:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828862; bh=OvGlPySaLooJfRF8h/ybUnhPjoQM+UqHv0gL8PVKjwc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xZ6M1AD/jecOA8YFcXrs6z9LBo8FhynAH+eiWPElcXHbKFVkIN8wyXiEZwxAdVqsO 7GK5MtxmNJIImEjNihks5M9S1qIH/Fhn/LppYf9NoPHL06//Lf8wR/6uuTNUj0vJ7/ 6xjbsd56T5Ehgntw4ptCmPvGIWgC64CgFDc47HJ0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniele Palmas , =?utf-8?q?Bj=C3=B8rn_Mork?= , "David S. Miller" , Sasha Levin Subject: [PATCH 4.4 36/62] NET: usb: qmi_wwan: add support for Telit LE922A PID 0x1040 Date: Fri, 11 Sep 2020 14:46:19 +0200 Message-Id: <20200911122504.192780631@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Daniele Palmas [ Upstream commit 9bd813da24cd49d749911d7fdc0e9ae9a673d746 ] This patch adds support for PID 0x1040 of Telit LE922A. The qmi adapter requires to have DTR set for proper working, so QMI_WWAN_QUIRK_DTR has been enabled. Signed-off-by: Daniele Palmas Acked-by: Bjørn Mork Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/usb/qmi_wwan.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c index ffb2499a222da..d48639cfec370 100644 --- a/drivers/net/usb/qmi_wwan.c +++ b/drivers/net/usb/qmi_wwan.c @@ -919,6 +919,7 @@ static const struct usb_device_id products[] = { {QMI_FIXED_INTF(0x1bbb, 0x0203, 2)}, /* Alcatel L800MA */ {QMI_FIXED_INTF(0x2357, 0x0201, 4)}, /* TP-LINK HSUPA Modem MA180 */ {QMI_FIXED_INTF(0x2357, 0x9000, 4)}, /* TP-LINK MA260 */ + {QMI_QUIRK_SET_DTR(0x1bc7, 0x1040, 2)}, /* Telit LE922A */ {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)}, /* Telit LE920 */ {QMI_FIXED_INTF(0x1bc7, 0x1201, 2)}, /* Telit LE920 */ {QMI_FIXED_INTF(0x1c9e, 0x9b01, 3)}, /* XS Stick W100-2 from 4G Systems */ From patchwork Fri Sep 11 12:46:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 309777 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 20083C2BC11 for ; Fri, 11 Sep 2020 17:32:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D05D8221ED for ; Fri, 11 Sep 2020 17:32:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845540; bh=3/V59JfWy1R9Sb/dRths/mhlZVe96k+zlNpcN3dIM5Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=wQ8YIwLpVlKm8BEYwLPItNFDY2awCpSd3ndJnMhlrCjMOu1ofXUwBqKl5gkCR7rrO LAy1B8SJGrGRdOk/36bLMsKVih3KWPHqdjbWaWuzPUkRg+U2hxVLcLl2brdADHsmH2 MZYzlAEMZvBBWn4tvrBXJHJY1ghqDTQh887+2tUY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726119AbgIKRcP (ORCPT ); Fri, 11 Sep 2020 13:32:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:49870 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726061AbgIKMzd (ORCPT ); Fri, 11 Sep 2020 08:55:33 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 9412122241; Fri, 11 Sep 2020 12:54:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828865; bh=3/V59JfWy1R9Sb/dRths/mhlZVe96k+zlNpcN3dIM5Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qxqjIa0I9TMjkZkgMZta7OczexKzhdmD8o2wjg9ns5QKn82CgOjPcF9qQU0ZtY8ip 7H3lb62OYk4JNfcfePaCosvpi6j+Obu6ACSsfjb3W7Fjzh/NQKlCZpSRubg935v6T9 quy/CEWvDqvD676mp5Sb9fCp6KAPFDcquTsKuVss= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniele Palmas , "David S. Miller" , Sasha Levin Subject: [PATCH 4.4 37/62] drivers: net: usb: qmi_wwan: add QMI_QUIRK_SET_DTR for Telit PID 0x1201 Date: Fri, 11 Sep 2020 14:46:20 +0200 Message-Id: <20200911122504.243362582@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Daniele Palmas [ Upstream commit 14cf4a771b3098e431d2677e3533bdd962e478d8 ] Telit LE920A4 uses the same pid 0x1201 of LE920, but modem implementation is different, since it requires DTR to be set for answering to qmi messages. This patch replaces QMI_FIXED_INTF with QMI_QUIRK_SET_DTR: tests on LE920 have been performed in order to verify backward compatibility. Signed-off-by: Daniele Palmas Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/usb/qmi_wwan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c index d48639cfec370..36aadc89175f8 100644 --- a/drivers/net/usb/qmi_wwan.c +++ b/drivers/net/usb/qmi_wwan.c @@ -921,7 +921,7 @@ static const struct usb_device_id products[] = { {QMI_FIXED_INTF(0x2357, 0x9000, 4)}, /* TP-LINK MA260 */ {QMI_QUIRK_SET_DTR(0x1bc7, 0x1040, 2)}, /* Telit LE922A */ {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)}, /* Telit LE920 */ - {QMI_FIXED_INTF(0x1bc7, 0x1201, 2)}, /* Telit LE920 */ + {QMI_QUIRK_SET_DTR(0x1bc7, 0x1201, 2)}, /* Telit LE920, LE920A4 */ {QMI_FIXED_INTF(0x1c9e, 0x9b01, 3)}, /* XS Stick W100-2 from 4G Systems */ {QMI_FIXED_INTF(0x0b3c, 0xc000, 4)}, /* Olivetti Olicard 100 */ {QMI_FIXED_INTF(0x0b3c, 0xc001, 4)}, /* Olivetti Olicard 120 */ From patchwork Fri Sep 11 12:46:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 264031 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 9FED2C433E2 for ; Fri, 11 Sep 2020 17:32:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 64304221ED for ; Fri, 11 Sep 2020 17:32:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845541; bh=lZ5TKnTvsDFLdz1tt3WI/zKtO1wcb+Jobwo0hp1g1GQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=w1kLlfv19uT+SKCDW7K/Pw1hLRNN+AT/a94gR4nYpD0S4eKrmuLNdDqe2mDRWQuOE cPMKz3pnnNfslO3giMEtFZc5s0A6UYZD4guGSbvRNrcUpSD5DOUTrJl9nZmpGVwYP9 77BUdmzRpxtG2wrfcjNeybISfYf3QgnO7a0K9Mgw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726304AbgIKRcR (ORCPT ); Fri, 11 Sep 2020 13:32:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:49260 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726059AbgIKMzZ (ORCPT ); Fri, 11 Sep 2020 08:55:25 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 F236122242; Fri, 11 Sep 2020 12:54:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828867; bh=lZ5TKnTvsDFLdz1tt3WI/zKtO1wcb+Jobwo0hp1g1GQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OzvjdlILZUYaqX77EnGyJhw4E+zLxdL3wsZye+0vAR9liNIGzEr3yABcfjlUNzuWq EDi3FIBwien6Q/JV2UbZuQ+F72hcF1rjR/EE41ghHfdLIzG1SJHUe2d2qmT7Oh1LF1 /t4fF8ZwW3DILZsWbSJN7Ie5r7CNHTgtoHJATAe0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rogan Dawes , "David S. Miller" , Sasha Levin Subject: [PATCH 4.4 38/62] usb: qmi_wwan: add D-Link DWM-222 A2 device ID Date: Fri, 11 Sep 2020 14:46:21 +0200 Message-Id: <20200911122504.292512553@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Rogan Dawes [ Upstream commit 7d6053097311643545a8118100175a39bd6fa637 ] Signed-off-by: Rogan Dawes Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/usb/qmi_wwan.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c index 36aadc89175f8..ce3b810395224 100644 --- a/drivers/net/usb/qmi_wwan.c +++ b/drivers/net/usb/qmi_wwan.c @@ -886,6 +886,7 @@ static const struct usb_device_id products[] = { {QMI_FIXED_INTF(0x19d2, 0x2002, 4)}, /* ZTE (Vodafone) K3765-Z */ {QMI_FIXED_INTF(0x2001, 0x7e19, 4)}, /* D-Link DWM-221 B1 */ {QMI_FIXED_INTF(0x2001, 0x7e35, 4)}, /* D-Link DWM-222 */ + {QMI_FIXED_INTF(0x2001, 0x7e3d, 4)}, /* D-Link DWM-222 A2 */ {QMI_FIXED_INTF(0x2020, 0x2031, 4)}, /* Olicard 600 */ {QMI_FIXED_INTF(0x2020, 0x2033, 4)}, /* BroadMobi BM806U */ {QMI_FIXED_INTF(0x2020, 0x2060, 4)}, /* BroadMobi BM818 */ From patchwork Fri Sep 11 12:46:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 309776 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 43C94C43461 for ; Fri, 11 Sep 2020 17:32:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 05F59221E7 for ; Fri, 11 Sep 2020 17:32:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845546; bh=RMtP8Iwp68EL2Eh3y6PGWnoyQ3InvTXOA/Ug+UA7llw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=i3osnAx6MbnJaHQBDpcjhigbMNNEjbsjMHHrG4pMc1ST4GoUEEl8C4fISD8fghFd+ kWLI+HQMT/6w824HedW7VI74yBGXI26eHQtNvWoM0whueFcFKr24t6FmA7vxYUmffo 00wmXIs/MdDO7X5Wyy5AjZaNImvkCQgJNIYoC0VE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726389AbgIKRcV (ORCPT ); Fri, 11 Sep 2020 13:32:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:49244 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726058AbgIKMzZ (ORCPT ); Fri, 11 Sep 2020 08:55:25 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 A58E022243; Fri, 11 Sep 2020 12:54:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828870; bh=RMtP8Iwp68EL2Eh3y6PGWnoyQ3InvTXOA/Ug+UA7llw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L8hSeFU06pS4iIIjPgvufXgSsIopZciSGBdc8ofzVpXeEfAJma1ch3oMhr3bMLk91 vqvf8SxYJyPA3CGyzi52vdmV83OKKEEk4/2U7f5urVMq0EZq9B00UFfWflba8SuBQE I5z/u2Vy9qaIR+FYLcdqvDx0n9+5avCpBdUdaywI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniele Palmas , =?utf-8?q?Bj=C3=B8rn_Mork?= , "David S. Miller" , Sasha Levin Subject: [PATCH 4.4 39/62] net: usb: qmi_wwan: add Telit ME910 support Date: Fri, 11 Sep 2020 14:46:22 +0200 Message-Id: <20200911122504.341258188@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Daniele Palmas [ Upstream commit 4c54dc0277d0d55a9248c43aebd31858f926a056 ] This patch adds support for Telit ME910 PID 0x1100. Signed-off-by: Daniele Palmas Acked-by: Bjørn Mork Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/usb/qmi_wwan.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c index ce3b810395224..c5c8224fc8cb3 100644 --- a/drivers/net/usb/qmi_wwan.c +++ b/drivers/net/usb/qmi_wwan.c @@ -921,6 +921,7 @@ static const struct usb_device_id products[] = { {QMI_FIXED_INTF(0x2357, 0x0201, 4)}, /* TP-LINK HSUPA Modem MA180 */ {QMI_FIXED_INTF(0x2357, 0x9000, 4)}, /* TP-LINK MA260 */ {QMI_QUIRK_SET_DTR(0x1bc7, 0x1040, 2)}, /* Telit LE922A */ + {QMI_FIXED_INTF(0x1bc7, 0x1100, 3)}, /* Telit ME910 */ {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)}, /* Telit LE920 */ {QMI_QUIRK_SET_DTR(0x1bc7, 0x1201, 2)}, /* Telit LE920, LE920A4 */ {QMI_FIXED_INTF(0x1c9e, 0x9b01, 3)}, /* XS Stick W100-2 from 4G Systems */ From patchwork Fri Sep 11 12:46:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 309775 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, 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 E5900C43461 for ; Fri, 11 Sep 2020 17:32:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AE57F221EB for ; Fri, 11 Sep 2020 17:32:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845565; bh=3wphDCQfksWEC24dbHSdjgOWMcG6fIcBp5Zbl1HjnXI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=z2/+pT3MXPCLr/rvIRr2fbS4JdUYOYn4SSSYDsAxq1kCB2Wvp0muCy/CjLvbxIYVk iS+iuNCgizUe4/nEosQvXu7MMje4SS7xtBssNMhUCLHvc2lUCQ9a2ntpsS5dha3O66 pEyonoWZMQao/BjJtZVb5Lbb0MJgvrj4zyH4FpcI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726269AbgIKRcU (ORCPT ); Fri, 11 Sep 2020 13:32:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:49248 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726057AbgIKMzZ (ORCPT ); Fri, 11 Sep 2020 08:55:25 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 4A7E922204; Fri, 11 Sep 2020 12:54:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828872; bh=3wphDCQfksWEC24dbHSdjgOWMcG6fIcBp5Zbl1HjnXI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=01TvQgFVDZe0xTuxjczz2JqquAJAy/+7bkevFr/8qdoqgjnv/ecM2BI0XVQ26SOQt 8rrDx5yTjld/PkNWNVIB2gEts+xx+RLwHHX9DcZAKBQ50wgOKt2bX487rn3uwWejzC m9/f70bYYPXUxwzbpV8wE6QIYOqgjzxt6g7/puQQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniele Palmas , =?utf-8?q?Bj=C3=B8rn_Mork?= , Jakub Kicinski , Sasha Levin Subject: [PATCH 4.4 40/62] net: usb: qmi_wwan: add Telit 0x1050 composition Date: Fri, 11 Sep 2020 14:46:23 +0200 Message-Id: <20200911122504.390780247@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Daniele Palmas [ Upstream commit e0ae2c578d3909e60e9448207f5d83f785f1129f ] This patch adds support for Telit FN980 0x1050 composition 0x1050: tty, adb, rmnet, tty, tty, tty, tty Signed-off-by: Daniele Palmas Acked-by: Bjørn Mork Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/usb/qmi_wwan.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c index c5c8224fc8cb3..14eca1f80ce36 100644 --- a/drivers/net/usb/qmi_wwan.c +++ b/drivers/net/usb/qmi_wwan.c @@ -921,6 +921,7 @@ static const struct usb_device_id products[] = { {QMI_FIXED_INTF(0x2357, 0x0201, 4)}, /* TP-LINK HSUPA Modem MA180 */ {QMI_FIXED_INTF(0x2357, 0x9000, 4)}, /* TP-LINK MA260 */ {QMI_QUIRK_SET_DTR(0x1bc7, 0x1040, 2)}, /* Telit LE922A */ + {QMI_QUIRK_SET_DTR(0x1bc7, 0x1050, 2)}, /* Telit FN980 */ {QMI_FIXED_INTF(0x1bc7, 0x1100, 3)}, /* Telit ME910 */ {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)}, /* Telit LE920 */ {QMI_QUIRK_SET_DTR(0x1bc7, 0x1201, 2)}, /* Telit LE920, LE920A4 */ From patchwork Fri Sep 11 12:46:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 264030 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=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,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 16D66C43461 for ; Fri, 11 Sep 2020 17:32:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C66BD221E7 for ; Fri, 11 Sep 2020 17:32:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845547; bh=/EX9EiUO7EKKl32UqMlP7UBxy3ovcwPdEaANNdKgzLU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=r7N9e7V2vuK/C0RfiADlrkVkwC9mKJ7y77bmVyCgEy0W/stZd7V9STfO+jRESgYdU Ew6z2JSB5VSlp8x1ocVCuz9uLTO9z8Ca9EaMUsYiQ0HRdhDYEa591xm0SHM4Svb/uW 5YjhHr3wuqwv4D5JFxMqrvdHtWqK21HIctHsf+dA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726212AbgIKRcV (ORCPT ); Fri, 11 Sep 2020 13:32:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:49840 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726060AbgIKMzZ (ORCPT ); Fri, 11 Sep 2020 08:55:25 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 A9E9620758; Fri, 11 Sep 2020 12:54:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828875; bh=/EX9EiUO7EKKl32UqMlP7UBxy3ovcwPdEaANNdKgzLU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QvPGZuIJGzqhMPOBdsEIshLXhKl9o6p/S5NhSJP7h2mwD9Zp4RVhhEvr7S7rWCkSz OFiscFVZo5fLsw+7gjeaAkFAFemfG7KVaCdsF/bPW6UjHLJZRgcm40jei0eUCeLIyL XdKbkgm6iCqdjdtjhCPHr7rASFLa0y/kK9kIKV0Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tong Zhang , Takashi Iwai Subject: [PATCH 4.4 41/62] ALSA: ca0106: fix error code handling Date: Fri, 11 Sep 2020 14:46:24 +0200 Message-Id: <20200911122504.442560573@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Tong Zhang commit ee0761d1d8222bcc5c86bf10849dc86cf008557c upstream. snd_ca0106_spi_write() returns 1 on error, snd_ca0106_pcm_power_dac() is returning the error code directly, and the caller is expecting an negative error code Signed-off-by: Tong Zhang Cc: Link: https://lore.kernel.org/r/20200824224541.1260307-1-ztong0001@gmail.com Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/pci/ca0106/ca0106_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -551,7 +551,8 @@ static int snd_ca0106_pcm_power_dac(stru else /* Power down */ chip->spi_dac_reg[reg] |= bit; - return snd_ca0106_spi_write(chip, chip->spi_dac_reg[reg]); + if (snd_ca0106_spi_write(chip, chip->spi_dac_reg[reg]) != 0) + return -ENXIO; } return 0; } From patchwork Fri Sep 11 12:46:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 309779 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=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,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 849ECC2D0E1 for ; Fri, 11 Sep 2020 17:31:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 48538221ED for ; Fri, 11 Sep 2020 17:31:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845475; bh=ClG/J2D28CSekcsEzvDrVhqfY9dWzpT8JjtNaDePcb8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=W4rmGrxOFhy26LukPyf1iTi2qhxBR+z4+O9TTEeq6x0gyC7s5LwcGOH99B6ZK1JJi Lvb5os4XGDC82Nslor8daPgvs+20T0ugucKmdjqRV4nvYheiSbclCRzP+HWi0vimXV qrJCGopyX7WquwCbDruaWOQrunCWkhEtdvk+gsUY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726192AbgIKRbO (ORCPT ); Fri, 11 Sep 2020 13:31:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:49250 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725974AbgIKMze (ORCPT ); Fri, 11 Sep 2020 08:55:34 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 BD3D522207; Fri, 11 Sep 2020 12:54:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828880; bh=ClG/J2D28CSekcsEzvDrVhqfY9dWzpT8JjtNaDePcb8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NrnpRTqR9VubTJ0O8oKPxbnwK1j6FSopLAka7NwbnfzFAvxYKsrvovFJuKa+a7llC u9Ejl3caTC8YUFf5lHS/wDoyzbL/hfahawPfN0bcwWTUaQ7nlneOZdVzLuSrRIK4MI lYXtmiZK588SMbPsh2sgWZvLNd1DSeN9KNf9b18o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+23b22dc2e0b81cbfcc95@syzkaller.appspotmail.com, Takashi Iwai Subject: [PATCH 4.4 42/62] ALSA: pcm: oss: Remove superfluous WARN_ON() for mulaw sanity check Date: Fri, 11 Sep 2020 14:46:25 +0200 Message-Id: <20200911122504.491959387@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Takashi Iwai commit 949a1ebe8cea7b342085cb6a4946b498306b9493 upstream. The PCM OSS mulaw plugin has a check of the format of the counter part whether it's a linear format. The check is with snd_BUG_ON() that emits WARN_ON() when the debug config is set, and it confuses syzkaller as if it were a serious issue. Let's drop snd_BUG_ON() for avoiding that. While we're at it, correct the error code to a more suitable, EINVAL. Reported-by: syzbot+23b22dc2e0b81cbfcc95@syzkaller.appspotmail.com Cc: Link: https://lore.kernel.org/r/20200901131802.18157-1-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/core/oss/mulaw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/sound/core/oss/mulaw.c +++ b/sound/core/oss/mulaw.c @@ -329,8 +329,8 @@ int snd_pcm_plugin_build_mulaw(struct sn snd_BUG(); return -EINVAL; } - if (snd_BUG_ON(!snd_pcm_format_linear(format->format))) - return -ENXIO; + if (!snd_pcm_format_linear(format->format)) + return -EINVAL; err = snd_pcm_plugin_build(plug, "Mu-Law<->linear conversion", src_format, dst_format, From patchwork Fri Sep 11 12:46:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 264036 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=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 024A5C43461 for ; Fri, 11 Sep 2020 17:30:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B57992220F for ; Fri, 11 Sep 2020 17:30:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845444; bh=uwKdI65cJkdS+Q/qobIiqnPK8gOXzU532WtF7jDAj6U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=EYWNfMqQ86wefzAJiIJGWT90Ndoj0TfqgeJCHa8tmdNQazS6PcR6Mk8/hPMLjZJDV Y4Jvw+J5i+SELNj5+8/xBZ79GtJ1rNTiPCnAj9OLx8w6xfiY2mkRQ1qD+HT3jWoIlm 379LsPRQ5P1hoNeCxjjh1OMV/WOHauPoU4009jws= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726093AbgIKRal (ORCPT ); Fri, 11 Sep 2020 13:30:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:48796 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726066AbgIKMze (ORCPT ); Fri, 11 Sep 2020 08:55:34 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 5FC2522208; Fri, 11 Sep 2020 12:54:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828882; bh=uwKdI65cJkdS+Q/qobIiqnPK8gOXzU532WtF7jDAj6U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bLh6lwFjkHr8yhMvhYrdP8P+MEjTEk9KZje1+OVezhHU0F2yk4nkfufrVUgHrRZVA efTzCHozyGpL3IMhYbuboJrDKND8wRo9K7pAyjP5elNllnxfCbyHpPSw0WSxsH5yPA V0tVCeDe4wMcdtMWfD4CJBC1E3brn2V/sP1gn7UE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ye Bin , Mike Snitzer Subject: [PATCH 4.4 43/62] dm cache metadata: Avoid returning cmd->bm wild pointer on error Date: Fri, 11 Sep 2020 14:46:26 +0200 Message-Id: <20200911122504.542882684@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Ye Bin commit d16ff19e69ab57e08bf908faaacbceaf660249de upstream. Maybe __create_persistent_data_objects() caller will use PTR_ERR as a pointer, it will lead to some strange things. Signed-off-by: Ye Bin Cc: stable@vger.kernel.org Signed-off-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-cache-metadata.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/drivers/md/dm-cache-metadata.c +++ b/drivers/md/dm-cache-metadata.c @@ -501,12 +501,16 @@ static int __create_persistent_data_obje CACHE_MAX_CONCURRENT_LOCKS); if (IS_ERR(cmd->bm)) { DMERR("could not create block manager"); - return PTR_ERR(cmd->bm); + r = PTR_ERR(cmd->bm); + cmd->bm = NULL; + return r; } r = __open_or_format_metadata(cmd, may_format_device); - if (r) + if (r) { dm_block_manager_destroy(cmd->bm); + cmd->bm = NULL; + } return r; } From patchwork Fri Sep 11 12:46:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 264034 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=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 C038EC43461 for ; Fri, 11 Sep 2020 17:31:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7D54422205 for ; Fri, 11 Sep 2020 17:31:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845474; bh=QE17evv1Y7ctaurvyQ7i62yO2vJYXzF22gW2hz51gUo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Mi9KIFuXD4GwtcB2od96DvS1djDB2PG2GPUlwAk5HgmFhG/DKsWdqQtWeIwNyRgyQ NAf70GdzPG4+JkngSkd+1Rf5u82u5F5QWO8BotkZtvI8ag2EPXHFul/XZnf8mSKLpl 4XqMjSBt447pGDltvsADNuD1yGHnE8Hjd0RHmLvA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726147AbgIKRbN (ORCPT ); Fri, 11 Sep 2020 13:31:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:49906 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725909AbgIKMze (ORCPT ); Fri, 11 Sep 2020 08:55:34 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 E0B5422206; Fri, 11 Sep 2020 12:54:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828885; bh=QE17evv1Y7ctaurvyQ7i62yO2vJYXzF22gW2hz51gUo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yMTzcsf+GRmR8JL4QAcLBvNhy/hc8pvXLZjIlrUZJI4dKuX7lumkCnjVAKX3yUVrh f3SbdctlVg6qutgGNzZe2HLQSeHTLSmSfV8RZ6h6V4CLjkEeDWlJejLAzEqzWaEeC+ oL7PETdXhJj0Uke7HsSqxO2fA9yNZQ95BXH0V65M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ye Bin , Mike Snitzer Subject: [PATCH 4.4 44/62] dm thin metadata: Avoid returning cmd->bm wild pointer on error Date: Fri, 11 Sep 2020 14:46:27 +0200 Message-Id: <20200911122504.592215788@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Ye Bin commit 219403d7e56f9b716ad80ab87db85d29547ee73e upstream. Maybe __create_persistent_data_objects() caller will use PTR_ERR as a pointer, it will lead to some strange things. Signed-off-by: Ye Bin Cc: stable@vger.kernel.org Signed-off-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-thin-metadata.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/drivers/md/dm-thin-metadata.c +++ b/drivers/md/dm-thin-metadata.c @@ -700,12 +700,16 @@ static int __create_persistent_data_obje THIN_MAX_CONCURRENT_LOCKS); if (IS_ERR(pmd->bm)) { DMERR("could not create block manager"); - return PTR_ERR(pmd->bm); + r = PTR_ERR(pmd->bm); + pmd->bm = NULL; + return r; } r = __open_or_format_metadata(pmd, format_device); - if (r) + if (r) { dm_block_manager_destroy(pmd->bm); + pmd->bm = NULL; + } return r; } From patchwork Fri Sep 11 12:46:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 309780 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=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 4B99AC433E2 for ; Fri, 11 Sep 2020 17:31:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 150D422205 for ; Fri, 11 Sep 2020 17:31:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845474; bh=8aGgTX7eJGwE5iNADZQgP2zo6D2f/WaG6nmMoTRNV/8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=DtBchnKmEONYDY474edYlHi2clW+NZUAPqzPly+bX6nSYAPsNL7Eh17hIqnU4u6VU cEUA58TnKJNUpUf0QUCKZBTmPuFLCdDst6rdwG+7/SSfiGZaaKer5Yx4O4LECorTow ISg21s+oJQW+q6694uDb6yNClM4eRH8SnzK3lvEs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726085AbgIKRbN (ORCPT ); Fri, 11 Sep 2020 13:31:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:49262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726013AbgIKMze (ORCPT ); Fri, 11 Sep 2020 08:55:34 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 7C8B922227; Fri, 11 Sep 2020 12:54:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828888; bh=8aGgTX7eJGwE5iNADZQgP2zo6D2f/WaG6nmMoTRNV/8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e7NxxEUSguU699UDRAmeH5a81NLR9tP2Biu+F4QY48vkPojaT/x/zMGcYY+rGWqC3 lJPLpgt2+0ivnmvg4l8Z/m+ioRc18lhdWDR+KHLGm6b3sgsYhbXFDOhsRjotoYMez2 zvVikeksGicjvZ6o2RQwyjhYpP2KpjyHkG/emsFU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Matthieu Baerts , Tim Froidcoeur , "David S. Miller" Subject: [PATCH 4.4 45/62] net: refactor bind_bucket fastreuse into helper Date: Fri, 11 Sep 2020 14:46:28 +0200 Message-Id: <20200911122504.641002023@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Tim Froidcoeur commit 62ffc589abb176821662efc4525ee4ac0b9c3894 upstream. Refactor the fastreuse update code in inet_csk_get_port into a small helper function that can be called from other places. Acked-by: Matthieu Baerts Signed-off-by: Tim Froidcoeur Signed-off-by: David S. Miller Signed-off-by: Tim Froidcoeur Signed-off-by: Greg Kroah-Hartman --- include/net/inet_connection_sock.h | 4 +++ net/ipv4/inet_connection_sock.c | 46 ++++++++++++++++++++++--------------- 2 files changed, 32 insertions(+), 18 deletions(-) --- a/include/net/inet_connection_sock.h +++ b/include/net/inet_connection_sock.h @@ -319,5 +319,9 @@ int inet_csk_compat_getsockopt(struct so int inet_csk_compat_setsockopt(struct sock *sk, int level, int optname, char __user *optval, unsigned int optlen); +/* update the fast reuse flag when adding a socket */ +void inet_csk_update_fastreuse(struct inet_bind_bucket *tb, + struct sock *sk); + struct dst_entry *inet_csk_update_pmtu(struct sock *sk, u32 mtu); #endif /* _INET_CONNECTION_SOCK_H */ --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c @@ -87,6 +87,31 @@ int inet_csk_bind_conflict(const struct } EXPORT_SYMBOL_GPL(inet_csk_bind_conflict); +void inet_csk_update_fastreuse(struct inet_bind_bucket *tb, + struct sock *sk) +{ + kuid_t uid = sock_i_uid(sk); + + if (hlist_empty(&tb->owners)) { + if (sk->sk_reuse && sk->sk_state != TCP_LISTEN) + tb->fastreuse = 1; + else + tb->fastreuse = 0; + if (sk->sk_reuseport) { + tb->fastreuseport = 1; + tb->fastuid = uid; + } else + tb->fastreuseport = 0; + } else { + if (tb->fastreuse && + (!sk->sk_reuse || sk->sk_state == TCP_LISTEN)) + tb->fastreuse = 0; + if (tb->fastreuseport && + (!sk->sk_reuseport || !uid_eq(tb->fastuid, uid))) + tb->fastreuseport = 0; + } +} + /* Obtain a reference to a local port for the given sock, * if snum is zero it means select any available local port. */ @@ -216,24 +241,9 @@ tb_not_found: if (!tb && (tb = inet_bind_bucket_create(hashinfo->bind_bucket_cachep, net, head, snum)) == NULL) goto fail_unlock; - if (hlist_empty(&tb->owners)) { - if (sk->sk_reuse && sk->sk_state != TCP_LISTEN) - tb->fastreuse = 1; - else - tb->fastreuse = 0; - if (sk->sk_reuseport) { - tb->fastreuseport = 1; - tb->fastuid = uid; - } else - tb->fastreuseport = 0; - } else { - if (tb->fastreuse && - (!sk->sk_reuse || sk->sk_state == TCP_LISTEN)) - tb->fastreuse = 0; - if (tb->fastreuseport && - (!sk->sk_reuseport || !uid_eq(tb->fastuid, uid))) - tb->fastreuseport = 0; - } + + inet_csk_update_fastreuse(tb, sk); + success: if (!inet_csk(sk)->icsk_bind_hash) inet_bind_hash(sk, tb, snum); From patchwork Fri Sep 11 12:46:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 309781 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=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,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 A7C5DC43461 for ; Fri, 11 Sep 2020 17:31:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6C451221ED for ; Fri, 11 Sep 2020 17:31:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845468; bh=u1dk5W0oM0NPdP8kRNII+SlXEzp77OsHcF2QsEGuQEs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=j9Q/WbGU4OrNl1dfJwkKclPHvbozYIzOG6q1XV9zr4n/MeS7wvAQWfUL1PciDmTTW kln/3Zq4Lgk1Ble9LyunctD2fgHsMQBjFSgbAhZV1xHm6tCH3qcCmE2eYBITdugw/d jr8nmof9c4O2Gs2oq37jtv3W/1cZ837RDwQr7S7c= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726183AbgIKRak (ORCPT ); Fri, 11 Sep 2020 13:30:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:49246 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726068AbgIKMzh (ORCPT ); Fri, 11 Sep 2020 08:55:37 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 1141C22245; Fri, 11 Sep 2020 12:54:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828890; bh=u1dk5W0oM0NPdP8kRNII+SlXEzp77OsHcF2QsEGuQEs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SG6lakEQk91fVQvLZWq1aFlM/JrSIhy76D5FSJVlLYv+b9yzUp6H8DJ8ksXe/2tVt PBLrAzHRPHHymHlsUu6at4nsjxao3QUzGtfuAGBAWQgyIpjJB18kvSrm8TRBvskLFb u0P7lKCD+vEX6jdlVHupsNzLQPSTVrRfu8dFy0Us= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Matthieu Baerts , Tim Froidcoeur , "David S. Miller" Subject: [PATCH 4.4 46/62] net: initialize fastreuse on inet_inherit_port Date: Fri, 11 Sep 2020 14:46:29 +0200 Message-Id: <20200911122504.690138814@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Tim Froidcoeur commit d76f3351cea2d927fdf70dd7c06898235035e84e upstream. In the case of TPROXY, bind_conflict optimizations for SO_REUSEADDR or SO_REUSEPORT are broken, possibly resulting in O(n) instead of O(1) bind behaviour or in the incorrect reuse of a bind. the kernel keeps track for each bind_bucket if all sockets in the bind_bucket support SO_REUSEADDR or SO_REUSEPORT in two fastreuse flags. These flags allow skipping the costly bind_conflict check when possible (meaning when all sockets have the proper SO_REUSE option). For every socket added to a bind_bucket, these flags need to be updated. As soon as a socket that does not support reuse is added, the flag is set to false and will never go back to true, unless the bind_bucket is deleted. Note that there is no mechanism to re-evaluate these flags when a socket is removed (this might make sense when removing a socket that would not allow reuse; this leaves room for a future patch). For this optimization to work, it is mandatory that these flags are properly initialized and updated. When a child socket is created from a listen socket in __inet_inherit_port, the TPROXY case could create a new bind bucket without properly initializing these flags, thus preventing the optimization to work. Alternatively, a socket not allowing reuse could be added to an existing bind bucket without updating the flags, causing bind_conflict to never be called as it should. Call inet_csk_update_fastreuse when __inet_inherit_port decides to create a new bind_bucket or use a different bind_bucket than the one of the listen socket. Fixes: 093d282321da ("tproxy: fix hash locking issue when using port redirection in __inet_inherit_port()") Acked-by: Matthieu Baerts Signed-off-by: Tim Froidcoeur Signed-off-by: David S. Miller Signed-off-by: Tim Froidcoeur Signed-off-by: Greg Kroah-Hartman --- net/ipv4/inet_hashtables.c | 1 + 1 file changed, 1 insertion(+) --- a/net/ipv4/inet_hashtables.c +++ b/net/ipv4/inet_hashtables.c @@ -160,6 +160,7 @@ int __inet_inherit_port(const struct soc return -ENOMEM; } } + inet_csk_update_fastreuse(tb, child); } inet_bind_hash(child, tb, port); spin_unlock(&head->lock); From patchwork Fri Sep 11 12:46:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 264035 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=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,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 DA9BEC2D0E1 for ; Fri, 11 Sep 2020 17:31:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A212222205 for ; Fri, 11 Sep 2020 17:31:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845469; bh=+h/p9gHHwVzsHz7LcGKUucRqugGoYlWRyIyoXbbg724=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=DDe+Fe++2GC1qM8iENtSdxMWJ76wj79eBpniwGB2fjJ9Rdwda3ccsmuEBLFNPEd/Y rqut26xu+kQQvSCTjXN0y/G/lHcKUTcL72tQ9kQAgSSIKAyDwasyl82Md57jg0gtOY T/lYpNwZH4iSdSQoH7m1N5SxeSwCVy1aQFTXLXY8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726163AbgIKRah (ORCPT ); Fri, 11 Sep 2020 13:30:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:49480 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726069AbgIKMzi (ORCPT ); Fri, 11 Sep 2020 08:55:38 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 811DC22246; Fri, 11 Sep 2020 12:54:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828893; bh=+h/p9gHHwVzsHz7LcGKUucRqugGoYlWRyIyoXbbg724=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z+q+I1QVC2DWAnt32+Kz3cDUEHLc8gpeyXSGBJT76ovyOABEg+uREQWZNQ99CtSsI bFz3uuz39RuqVLDGU9H4SQnBwNNhCtSYFaiSWBT8pRO2rh5BU/vMqn+lECV8WtQSl5 VGsoVlMbz2ROPfasYflUKrAfdAjBpdNJdUae7rgc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mrinal Pandey , Andrew Morton , Lukas Bulwahn , Joe Perches , Linus Torvalds Subject: [PATCH 4.4 47/62] checkpatch: fix the usage of capture group ( ... ) Date: Fri, 11 Sep 2020 14:46:30 +0200 Message-Id: <20200911122504.739680751@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Mrinal Pandey commit 13e45417cedbfc44b1926124b1846f5ee8c6ba4a upstream. The usage of "capture group (...)" in the immediate condition after `&&` results in `$1` being uninitialized. This issues a warning "Use of uninitialized value $1 in regexp compilation at ./scripts/checkpatch.pl line 2638". I noticed this bug while running checkpatch on the set of commits from v5.7 to v5.8-rc1 of the kernel on the commits with a diff content in their commit message. This bug was introduced in the script by commit e518e9a59ec3 ("checkpatch: emit an error when there's a diff in a changelog"). It has been in the script since then. The author intended to store the match made by capture group in variable `$1`. This should have contained the name of the file as `[\w/]+` matched. However, this couldn't be accomplished due to usage of capture group and `$1` in the same regular expression. Fix this by placing the capture group in the condition before `&&`. Thus, `$1` can be initialized to the text that capture group matches thereby setting it to the desired and required value. Fixes: e518e9a59ec3 ("checkpatch: emit an error when there's a diff in a changelog") Signed-off-by: Mrinal Pandey Signed-off-by: Andrew Morton Tested-by: Lukas Bulwahn Reviewed-by: Lukas Bulwahn Cc: Joe Perches Link: https://lkml.kernel.org/r/20200714032352.f476hanaj2dlmiot@mrinalpandey Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- scripts/checkpatch.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2195,8 +2195,8 @@ sub process { # Check if the commit log has what seems like a diff which can confuse patch if ($in_commit_log && !$commit_log_has_diff && - (($line =~ m@^\s+diff\b.*a/[\w/]+@ && - $line =~ m@^\s+diff\b.*a/([\w/]+)\s+b/$1\b@) || + (($line =~ m@^\s+diff\b.*a/([\w/]+)@ && + $line =~ m@^\s+diff\b.*a/[\w/]+\s+b/$1\b@) || $line =~ m@^\s*(?:\-\-\-\s+a/|\+\+\+\s+b/)@ || $line =~ m/^\s*\@\@ \-\d+,\d+ \+\d+,\d+ \@\@/)) { ERROR("DIFF_IN_COMMIT_MSG", From patchwork Fri Sep 11 12:46:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 309778 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=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 3A4A1C43461 for ; Fri, 11 Sep 2020 17:31:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F099B22205 for ; Fri, 11 Sep 2020 17:31:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845489; bh=uJsaI9YEbxKUytNbGORp2QRFuqQUum35+4iuPAUaF14=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=czm7ohzuCMEWxzdxWj7GZQYPxFlTd+XsOXNg9mXQSeOM6r55BL2QTayP0LnCKQPNX K6At8K5qApKfFy2DSKhIOr8Uk/JJXdmgtg11Ah7SshSR2a8zBwGWVOK/EqZzcx+iEN 9Xpp63ct+jWv9hlrpQi1ZDIXp0jRaYf7S/Efw3zs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726546AbgIKRb0 (ORCPT ); Fri, 11 Sep 2020 13:31:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:49206 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726075AbgIKM4b (ORCPT ); Fri, 11 Sep 2020 08:56:31 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 158E722247; Fri, 11 Sep 2020 12:54:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828895; bh=uJsaI9YEbxKUytNbGORp2QRFuqQUum35+4iuPAUaF14=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wq+x2TTFuCKsdwzloG3x6RHa41AAMgT1ehjQ1qwmXAUlYYKz6/Yy//ncXfrskOQxE XKx5k4rUpPQqW75uHXeCMQVI6eeo6CnQRi/oInSrMmrNPV4BolR0bBMtv3k8th4tEY 0AQ+jHyjeXV0I62k+/SMsMPxJxL6DmWZFmRVLS4A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Muchun Song , Andrew Morton , Mike Kravetz , Andi Kleen , Linus Torvalds Subject: [PATCH 4.4 48/62] mm/hugetlb: fix a race between hugetlb sysctl handlers Date: Fri, 11 Sep 2020 14:46:31 +0200 Message-Id: <20200911122504.788369330@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Muchun Song commit 17743798d81238ab13050e8e2833699b54e15467 upstream. There is a race between the assignment of `table->data` and write value to the pointer of `table->data` in the __do_proc_doulongvec_minmax() on the other thread. CPU0: CPU1: proc_sys_write hugetlb_sysctl_handler proc_sys_call_handler hugetlb_sysctl_handler_common hugetlb_sysctl_handler table->data = &tmp; hugetlb_sysctl_handler_common table->data = &tmp; proc_doulongvec_minmax do_proc_doulongvec_minmax sysctl_head_finish __do_proc_doulongvec_minmax unuse_table i = table->data; *i = val; // corrupt CPU1's stack Fix this by duplicating the `table`, and only update the duplicate of it. And introduce a helper of proc_hugetlb_doulongvec_minmax() to simplify the code. The following oops was seen: BUG: kernel NULL pointer dereference, address: 0000000000000000 #PF: supervisor instruction fetch in kernel mode #PF: error_code(0x0010) - not-present page Code: Bad RIP value. ... Call Trace: ? set_max_huge_pages+0x3da/0x4f0 ? alloc_pool_huge_page+0x150/0x150 ? proc_doulongvec_minmax+0x46/0x60 ? hugetlb_sysctl_handler_common+0x1c7/0x200 ? nr_hugepages_store+0x20/0x20 ? copy_fd_bitmaps+0x170/0x170 ? hugetlb_sysctl_handler+0x1e/0x20 ? proc_sys_call_handler+0x2f1/0x300 ? unregister_sysctl_table+0xb0/0xb0 ? __fd_install+0x78/0x100 ? proc_sys_write+0x14/0x20 ? __vfs_write+0x4d/0x90 ? vfs_write+0xef/0x240 ? ksys_write+0xc0/0x160 ? __ia32_sys_read+0x50/0x50 ? __close_fd+0x129/0x150 ? __x64_sys_write+0x43/0x50 ? do_syscall_64+0x6c/0x200 ? entry_SYSCALL_64_after_hwframe+0x44/0xa9 Fixes: e5ff215941d5 ("hugetlb: multiple hstates for multiple page sizes") Signed-off-by: Muchun Song Signed-off-by: Andrew Morton Reviewed-by: Mike Kravetz Cc: Andi Kleen Link: http://lkml.kernel.org/r/20200828031146.43035-1-songmuchun@bytedance.com Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/hugetlb.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -2812,6 +2812,22 @@ static unsigned int cpuset_mems_nr(unsig } #ifdef CONFIG_SYSCTL +static int proc_hugetlb_doulongvec_minmax(struct ctl_table *table, int write, + void *buffer, size_t *length, + loff_t *ppos, unsigned long *out) +{ + struct ctl_table dup_table; + + /* + * In order to avoid races with __do_proc_doulongvec_minmax(), we + * can duplicate the @table and alter the duplicate of it. + */ + dup_table = *table; + dup_table.data = out; + + return proc_doulongvec_minmax(&dup_table, write, buffer, length, ppos); +} + static int hugetlb_sysctl_handler_common(bool obey_mempolicy, struct ctl_table *table, int write, void __user *buffer, size_t *length, loff_t *ppos) @@ -2823,9 +2839,8 @@ static int hugetlb_sysctl_handler_common if (!hugepages_supported()) return -ENOTSUPP; - table->data = &tmp; - table->maxlen = sizeof(unsigned long); - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos); + ret = proc_hugetlb_doulongvec_minmax(table, write, buffer, length, ppos, + &tmp); if (ret) goto out; @@ -2869,9 +2884,8 @@ int hugetlb_overcommit_handler(struct ct if (write && hstate_is_gigantic(h)) return -EINVAL; - table->data = &tmp; - table->maxlen = sizeof(unsigned long); - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos); + ret = proc_hugetlb_doulongvec_minmax(table, write, buffer, length, ppos, + &tmp); if (ret) goto out; From patchwork Fri Sep 11 12:46:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 264104 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=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 B4327C2BC11 for ; Fri, 11 Sep 2020 12:58:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6CDB422249 for ; Fri, 11 Sep 2020 12:58:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599829119; bh=qJYoeA8rT3BH29yUPVS7a/6SxvkuI+QN0m4oiym4bXU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=AVYacK329x6xpwRBx6J9AC7ZqzoJMtoIc7D/Gs56Ub97nZekt3Zz/Z6o2iRG2XRyS qaesfZcdGL+WvpJ3bV+2CbqfVPYRKS74eVglB1QwZl2jQm7WPw0c/r62r8ZCg10zoO PHYLldi9POCt4+s8EawlAaQliTN54zYTYcO0kmpw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726116AbgIKM6R (ORCPT ); Fri, 11 Sep 2020 08:58:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:49208 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725955AbgIKM4b (ORCPT ); Fri, 11 Sep 2020 08:56:31 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 78B2D2220A; Fri, 11 Sep 2020 12:54:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828898; bh=qJYoeA8rT3BH29yUPVS7a/6SxvkuI+QN0m4oiym4bXU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m5muY0dl25nTkCXg0gLnICpGcvfpXccgullGD9ylhojOlz8wopy9c2rcgrqiytNCU jygfKH88ioDIfyIfki2r9eDlUYjECmwX6gMN+4bU/urQLXcqxIh6UjZfC5ERv3Egkr V2QrjJ7etcuOs2dfiz4CV+U+7AiGsglBywVH/WDY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+d451401ffd00a60677ee@syzkaller.appspotmail.com, Johannes Berg Subject: [PATCH 4.4 49/62] cfg80211: regulatory: reject invalid hints Date: Fri, 11 Sep 2020 14:46:32 +0200 Message-Id: <20200911122504.839242879@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Johannes Berg commit 47caf685a6854593348f216e0b489b71c10cbe03 upstream. Reject invalid hints early in order to not cause a kernel WARN later if they're restored to or similar. Reported-by: syzbot+d451401ffd00a60677ee@syzkaller.appspotmail.com Link: https://syzkaller.appspot.com/bug?extid=d451401ffd00a60677ee Link: https://lore.kernel.org/r/20200819084648.13956-1-johannes@sipsolutions.net Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman --- net/wireless/reg.c | 3 +++ 1 file changed, 3 insertions(+) --- a/net/wireless/reg.c +++ b/net/wireless/reg.c @@ -2383,6 +2383,9 @@ int regulatory_hint_user(const char *alp if (WARN_ON(!alpha2)) return -EINVAL; + if (!is_world_regdom(alpha2) && !is_an_alpha2(alpha2)) + return -EINVAL; + request = kzalloc(sizeof(struct regulatory_request), GFP_KERNEL); if (!request) return -ENOMEM; From patchwork Fri Sep 11 12:46:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 309846 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=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 0BB1FC43461 for ; Fri, 11 Sep 2020 12:58:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AF91822249 for ; Fri, 11 Sep 2020 12:58:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599829118; bh=2M3kLTHecVIjdKsP3KHuzpxTamDyJv9Z+X2VsAslpYc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=y4aCQHusWB1OQRLBSZO6xuOV99C5VWcXbiljL2pqC4WpgY6EqcXM9yiIGdFHZ/gmP d4qsx/DWVcsVRPcFpOmdGqcLWxn+op2UVQCzaVmzokP90a8Y1vleYrr8bQ0uvAP66J 7zF8ACz0MHeD6rpIoeNh7RSy5CZSa5JrZoCB6M/w= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726056AbgIKM6e (ORCPT ); Fri, 11 Sep 2020 08:58:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:49594 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725999AbgIKM4d (ORCPT ); Fri, 11 Sep 2020 08:56:33 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 16F5422248; Fri, 11 Sep 2020 12:54:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828900; bh=2M3kLTHecVIjdKsP3KHuzpxTamDyJv9Z+X2VsAslpYc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z4WKEr6cj603/VIOZdFmipUDUi/AdJngdkLoKfgYFQAaiqmfQzL4nqb79CKKH17BU PATcsICqqcTGUPyUu4xycIziFbwKaKk+h2GGub1OjgcYwx0p5xRcd6FQyKsPES0iie srESN7S6n/NC9EGL5bnLPEh62Uo42KSS+YNClWRM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Himadri Pandya , "David S. Miller" Subject: [PATCH 4.4 50/62] net: usb: Fix uninit-was-stored issue in asix_read_phy_addr() Date: Fri, 11 Sep 2020 14:46:33 +0200 Message-Id: <20200911122504.887449684@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Himadri Pandya commit a092b7233f0e000cc6f2c71a49e2ecc6f917a5fc upstream. The buffer size is 2 Bytes and we expect to receive the same amount of data. But sometimes we receive less data and run into uninit-was-stored issue upon read. Hence modify the error check on the return value to match with the buffer size as a prevention. Reported-and-tested by: syzbot+a7e220df5a81d1ab400e@syzkaller.appspotmail.com Signed-off-by: Himadri Pandya Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/usb/asix_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/net/usb/asix_common.c +++ b/drivers/net/usb/asix_common.c @@ -251,7 +251,7 @@ int asix_read_phy_addr(struct usbnet *de netdev_dbg(dev->net, "asix_get_phy_addr()\n"); - if (ret < 0) { + if (ret < 2) { netdev_err(dev->net, "Error reading PHYID register: %02x\n", ret); goto out; } From patchwork Fri Sep 11 12:46:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 309782 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 0BDDDC2D0E1 for ; Fri, 11 Sep 2020 17:30:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C069721D91 for ; Fri, 11 Sep 2020 17:30:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845437; bh=4UwAwY108elDYdJj/b91viIve21RQvKuhMtyBTpMSJQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=iz2UbK+xZZzpnfaRphrxCFQVtKTNKCU3pV+/Giq5WhWKVY45auh0SAmw6E8gXkA2o U9+U0UNf5hvzOWMMjibv7AbE99/gGYOyiCsvrvUf87F+D2l455ov8UTeDBC6JG3xWb OmhdkpHeWi7WG1Hw9VePHrovc62MnaB5J5Nl8Rl4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725875AbgIKRag (ORCPT ); Fri, 11 Sep 2020 13:30:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:49240 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726079AbgIKM4f (ORCPT ); Fri, 11 Sep 2020 08:56:35 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 A59AD22249; Fri, 11 Sep 2020 12:55:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828903; bh=4UwAwY108elDYdJj/b91viIve21RQvKuhMtyBTpMSJQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b33U/8oerozCOzf4BTHR+00vk0jUkIMIicfsfLo5lz9KECX9gGG7uYZiuZ1BMaEDj oyrckYiS8g48O4CUX1QFEYIej594V0JtWZxYAXDrnrNgdQ+hRIBz81zv7Mk+LfG+Zb VjDlHs/WZOPIfSlzFmGq9tTHU2647BqKNLDaBC2I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Sakamoto , Takashi Iwai , Sasha Levin Subject: [PATCH 4.4 51/62] ALSA: firewire-digi00x: add support for console models of Digi00x series Date: Fri, 11 Sep 2020 14:46:34 +0200 Message-Id: <20200911122504.936717931@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Takashi Sakamoto [ Upstream commit 13e005f9f933a35b5e55c9d36f151efe2a8383ec ] Digi00x series includes two types of unit; rack and console. As long as reading information on config rom of Digi 002 console, 'MODEL_ID' field has a different value from the one on Digi 002 rack. We've already got a test report from users with Digi 003 rack. We can assume that console type and rack type has different value in the field. This commit adds a device entry for console type. For following commits, this commit also adds a member to 'struct snd_digi00x' to identify console type. $ cd linux-firewire-utils/src $ python2 ./crpp < /sys/bus/firewire/devices/fw1/config_rom ROM header and bus information block ----------------------------------------------------------------- 400 0404f9d0 bus_info_length 4, crc_length 4, crc 63952 404 31333934 bus_name "1394" 408 60647002 irmc 0, cmc 1, isc 1, bmc 0, cyc_clk_acc 100, max_rec 7 (256) 40c 00a07e00 company_id 00a07e | 410 00a30000 device_id 0000a30000 | EUI-64 00a07e0000a30000 root directory ----------------------------------------------------------------- 414 00058a39 directory_length 5, crc 35385 418 0c0043a0 node capabilities 41c 04000001 hardware version 420 0300a07e vendor 424 81000007 --> descriptor leaf at 440 428 d1000001 --> unit directory at 42c unit directory at 42c ----------------------------------------------------------------- 42c 00046674 directory_length 4, crc 26228 430 120000a3 specifier id 434 13000001 version 438 17000001 model 43c 81000007 --> descriptor leaf at 458 descriptor leaf at 440 ----------------------------------------------------------------- 440 00055913 leaf_length 5, crc 22803 444 000050f2 descriptor_type 00, specifier_ID 50f2 448 80000000 44c 44696769 450 64657369 454 676e0000 descriptor leaf at 458 ----------------------------------------------------------------- 458 0004a6fd leaf_length 4, crc 42749 45c 00000000 textual descriptor 460 00000000 minimal ASCII 464 44696769 "Digi" 468 20303032 " 002" Signed-off-by: Takashi Sakamoto Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/firewire/digi00x/digi00x.c | 13 +++++++++++-- sound/firewire/digi00x/digi00x.h | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/sound/firewire/digi00x/digi00x.c b/sound/firewire/digi00x/digi00x.c index 1f33b7a1fca4c..6973a7ff1c503 100644 --- a/sound/firewire/digi00x/digi00x.c +++ b/sound/firewire/digi00x/digi00x.c @@ -13,7 +13,8 @@ MODULE_AUTHOR("Takashi Sakamoto "); MODULE_LICENSE("GPL v2"); #define VENDOR_DIGIDESIGN 0x00a07e -#define MODEL_DIGI00X 0x000002 +#define MODEL_CONSOLE 0x000001 +#define MODEL_RACK 0x000002 static int name_card(struct snd_dg00x *dg00x) { @@ -75,6 +76,8 @@ static int snd_dg00x_probe(struct fw_unit *unit, spin_lock_init(&dg00x->lock); init_waitqueue_head(&dg00x->hwdep_wait); + dg00x->is_console = entry->model_id == MODEL_CONSOLE; + err = name_card(dg00x); if (err < 0) goto error; @@ -138,7 +141,13 @@ static const struct ieee1394_device_id snd_dg00x_id_table[] = { .match_flags = IEEE1394_MATCH_VENDOR_ID | IEEE1394_MATCH_MODEL_ID, .vendor_id = VENDOR_DIGIDESIGN, - .model_id = MODEL_DIGI00X, + .model_id = MODEL_CONSOLE, + }, + { + .match_flags = IEEE1394_MATCH_VENDOR_ID | + IEEE1394_MATCH_MODEL_ID, + .vendor_id = VENDOR_DIGIDESIGN, + .model_id = MODEL_RACK, }, {} }; diff --git a/sound/firewire/digi00x/digi00x.h b/sound/firewire/digi00x/digi00x.h index 907e739936777..d641a0cf077a3 100644 --- a/sound/firewire/digi00x/digi00x.h +++ b/sound/firewire/digi00x/digi00x.h @@ -57,6 +57,7 @@ struct snd_dg00x { /* For asynchronous MIDI controls. */ struct snd_rawmidi_substream *in_control; struct snd_fw_async_midi_port out_control; + bool is_console; }; #define DG00X_ADDR_BASE 0xffffe0000000ull From patchwork Fri Sep 11 12:46:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 264103 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 948EDC433E2 for ; Fri, 11 Sep 2020 13:00:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4B55D21D79 for ; Fri, 11 Sep 2020 13:00:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599829206; bh=pAMpOAnyHqcbatPDSU73E2z9pv/KDTEpLUOtcQTinhY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=jwA5wc7ZKBgKEOgVS5TzmFTEbnAIPP/Aj3/Nl+oHKtsWuRVpK40Po+Pg2RTNVjV3h hW5TtD5vk/VCEvXEajhepdc9MNBk1m4OE8fRxpwzZ4MilJbblsGLDcLEOGOFPlCgK2 w/rVSpIavgdUNIjZTzL/e9ZALPPtvhWb0p4B9p+k= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726047AbgIKM67 (ORCPT ); Fri, 11 Sep 2020 08:58:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:49242 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726085AbgIKM4n (ORCPT ); Fri, 11 Sep 2020 08:56:43 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 7835E2224A; Fri, 11 Sep 2020 12:55:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828908; bh=pAMpOAnyHqcbatPDSU73E2z9pv/KDTEpLUOtcQTinhY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tZCm+xtcdBqJwQONhjrA9qbPu4LtBna8B31qBJQuoMnv3ohqnM8RViiTId0gpfQjy KtzAVQtIuuFJt+nt7nf36W9z6c6mldHYUm+kec2HY6cqIy3A4YpAcwJMTIul2MHTKO XYYP681oWZvbHclyhzlQuglwec9gGOtCQrXZ5IrA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Simon Wood , Takashi Sakamoto , Takashi Iwai , Sasha Levin Subject: [PATCH 4.4 52/62] ALSA: firewire-digi00x: exclude Avid Adrenaline from detection Date: Fri, 11 Sep 2020 14:46:35 +0200 Message-Id: <20200911122504.985599862@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Takashi Sakamoto [ Upstream commit acd46a6b6de88569654567810acad2b0a0a25cea ] Avid Adrenaline is reported that ALSA firewire-digi00x driver is bound to. However, as long as he investigated, the design of this model is hardly similar to the one of Digi 00x family. It's better to exclude the model from modalias of ALSA firewire-digi00x driver. This commit changes device entries so that the model is excluded. $ python3 crpp < ~/git/am-config-rom/misc/avid-adrenaline.img ROM header and bus information block ----------------------------------------------------------------- 400 04203a9c bus_info_length 4, crc_length 32, crc 15004 404 31333934 bus_name "1394" 408 e064a002 irmc 1, cmc 1, isc 1, bmc 0, cyc_clk_acc 100, max_rec 10 (2048) 40c 00a07e01 company_id 00a07e | 410 00085257 device_id 0100085257 | EUI-64 00a07e0100085257 root directory ----------------------------------------------------------------- 414 0005d08c directory_length 5, crc 53388 418 0300a07e vendor 41c 8100000c --> descriptor leaf at 44c 420 0c008380 node capabilities 424 8d000002 --> eui-64 leaf at 42c 428 d1000004 --> unit directory at 438 eui-64 leaf at 42c ----------------------------------------------------------------- 42c 0002410f leaf_length 2, crc 16655 430 00a07e01 company_id 00a07e | 434 00085257 device_id 0100085257 | EUI-64 00a07e0100085257 unit directory at 438 ----------------------------------------------------------------- 438 0004d6c9 directory_length 4, crc 54985 43c 1200a02d specifier id: 1394 TA 440 13014001 version: Vender Unique and AV/C 444 17000001 model 448 81000009 --> descriptor leaf at 46c descriptor leaf at 44c ----------------------------------------------------------------- 44c 00077205 leaf_length 7, crc 29189 450 00000000 textual descriptor 454 00000000 minimal ASCII 458 41766964 "Avid" 45c 20546563 " Tec" 460 686e6f6c "hnol" 464 6f677900 "ogy" 468 00000000 descriptor leaf at 46c ----------------------------------------------------------------- 46c 000599a5 leaf_length 5, crc 39333 470 00000000 textual descriptor 474 00000000 minimal ASCII 478 41647265 "Adre" 47c 6e616c69 "nali" 480 6e650000 "ne" Reported-by: Simon Wood Fixes: 9edf723fd858 ("ALSA: firewire-digi00x: add skeleton for Digi 002/003 family") Cc: # 4.4+ Signed-off-by: Takashi Sakamoto Link: https://lore.kernel.org/r/20200823075545.56305-1-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/firewire/digi00x/digi00x.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sound/firewire/digi00x/digi00x.c b/sound/firewire/digi00x/digi00x.c index 6973a7ff1c503..659e8224a4dee 100644 --- a/sound/firewire/digi00x/digi00x.c +++ b/sound/firewire/digi00x/digi00x.c @@ -15,6 +15,7 @@ MODULE_LICENSE("GPL v2"); #define VENDOR_DIGIDESIGN 0x00a07e #define MODEL_CONSOLE 0x000001 #define MODEL_RACK 0x000002 +#define SPEC_VERSION 0x000001 static int name_card(struct snd_dg00x *dg00x) { @@ -139,14 +140,18 @@ static const struct ieee1394_device_id snd_dg00x_id_table[] = { /* Both of 002/003 use the same ID. */ { .match_flags = IEEE1394_MATCH_VENDOR_ID | + IEEE1394_MATCH_VERSION | IEEE1394_MATCH_MODEL_ID, .vendor_id = VENDOR_DIGIDESIGN, + .version = SPEC_VERSION, .model_id = MODEL_CONSOLE, }, { .match_flags = IEEE1394_MATCH_VENDOR_ID | + IEEE1394_MATCH_VERSION | IEEE1394_MATCH_MODEL_ID, .vendor_id = VENDOR_DIGIDESIGN, + .version = SPEC_VERSION, .model_id = MODEL_RACK, }, {} From patchwork Fri Sep 11 12:46:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 264038 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, 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 22672C43461 for ; Fri, 11 Sep 2020 17:30:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D0F5A21D91 for ; Fri, 11 Sep 2020 17:30:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845430; bh=U/mzlecwlX18nx6LnGZoHxwzL8DkmoulQ2Fg0vy3/mM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=2XT8KokLhFPZATjMWx2LoiOeLoyphuyQB9GrNMFQgZc2s2TqclOtf3TNOgWnx/Nn8 nJjVDzs+xKm2FuZmuYYCIC9XNuMstjXJKFMeH/viqf/A80yc80xF5ECM9+f5i3bNfQ CwvuRZde874k9DTpaDD1MmmLJZjPmt4vLWlLxiaU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726080AbgIKRaD (ORCPT ); Fri, 11 Sep 2020 13:30:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:49794 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726089AbgIKM5a (ORCPT ); Fri, 11 Sep 2020 08:57:30 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 0512C2220E; Fri, 11 Sep 2020 12:55:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828910; bh=U/mzlecwlX18nx6LnGZoHxwzL8DkmoulQ2Fg0vy3/mM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C4bQpGCr4j8jwSD/EGBbSI0EoPNqJToJ0jOU8wZ+g+H30ZLTkz4wJNVEDx5TzWp+Q tz3Kus3l7TQMOSYWufW6wuTqOuqEkAzsTO/yjdVEQrkkXmNR8wDYBY+x8iPuuvPga8 KDUuTHGVXO5qxrpRjP0b2tQ/9GjDIl4Qe6W2Teq4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Sakamoto , Takashi Iwai Subject: [PATCH 4.4 53/62] ALSA; firewire-tascam: exclude Tascam FE-8 from detection Date: Fri, 11 Sep 2020 14:46:36 +0200 Message-Id: <20200911122505.037116689@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Takashi Sakamoto Tascam FE-8 is known to support communication by asynchronous transaction only. The support can be implemented in userspace application and snd-firewire-ctl-services project has the support. However, ALSA firewire-tascam driver is bound to the model. This commit changes device entries so that the model is excluded. In a commit 53b3ffee7885 ("ALSA: firewire-tascam: change device probing processing"), I addressed to the concern that version field in configuration differs depending on installed firmware. However, as long as I checked, the version number is fixed. It's safe to return version number back to modalias. Fixes: 53b3ffee7885 ("ALSA: firewire-tascam: change device probing processing") Cc: # 4.4+ Signed-off-by: Takashi Sakamoto Link: https://lore.kernel.org/r/20200823075537.56255-1-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai --- sound/firewire/tascam/tascam.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/sound/firewire/tascam/tascam.c b/sound/firewire/tascam/tascam.c index ee0bc18395088..a4143f45c7f7a 100644 --- a/sound/firewire/tascam/tascam.c +++ b/sound/firewire/tascam/tascam.c @@ -172,11 +172,39 @@ static void snd_tscm_remove(struct fw_unit *unit) } static const struct ieee1394_device_id snd_tscm_id_table[] = { + // Tascam, FW-1884. { .match_flags = IEEE1394_MATCH_VENDOR_ID | - IEEE1394_MATCH_SPECIFIER_ID, + IEEE1394_MATCH_SPECIFIER_ID | + IEEE1394_MATCH_VERSION, .vendor_id = 0x00022e, .specifier_id = 0x00022e, + .version = 0x800000, + }, + // Tascam, FE-8 (.version = 0x800001) + // This kernel module doesn't support FE-8 because the most of features + // can be implemented in userspace without any specific support of this + // module. + // + // .version = 0x800002 is unknown. + // + // Tascam, FW-1082. + { + .match_flags = IEEE1394_MATCH_VENDOR_ID | + IEEE1394_MATCH_SPECIFIER_ID | + IEEE1394_MATCH_VERSION, + .vendor_id = 0x00022e, + .specifier_id = 0x00022e, + .version = 0x800003, + }, + // Tascam, FW-1804. + { + .match_flags = IEEE1394_MATCH_VENDOR_ID | + IEEE1394_MATCH_SPECIFIER_ID | + IEEE1394_MATCH_VERSION, + .vendor_id = 0x00022e, + .specifier_id = 0x00022e, + .version = 0x800004, }, /* FE-08 requires reverse-engineering because it just has faders. */ {} From patchwork Fri Sep 11 12:46:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 264042 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 F3C46C2BC11 for ; Fri, 11 Sep 2020 17:28:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BAC07221E7 for ; Fri, 11 Sep 2020 17:28:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845285; bh=An3623LYJz8ha2T9Fwp0QpSAGawmTzp7icvaog2KT7I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=XQBcIGS2GbEmPklV6nIk4gBp9Sl/4DjoKZn3nyLCQpxQiLzhenNZHNErnNA746tRZ r6KXvBQeIiSR14fEdDE4svPIgpJs+vDLo+QpuBNVzfWbBF6drLe15GSczDukai5Y5Z jRTujXMlbth/EwWYWeyWinHTrs7wIdBpf4QxV9AQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726092AbgIKR2D (ORCPT ); Fri, 11 Sep 2020 13:28:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:49594 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726070AbgIKM6C (ORCPT ); Fri, 11 Sep 2020 08:58:02 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 E2E792224F; Fri, 11 Sep 2020 12:55:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828951; bh=An3623LYJz8ha2T9Fwp0QpSAGawmTzp7icvaog2KT7I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YGZNhiMqdDLQF9cqPpVbAC0KyHAmJVbhwI2UV/h1OsYLkrwBhwW1oHHkWMI7ePRSa iQc4u4bXbHYfCHqlyqGuX7kasJAPD5Mh/+QwPKzNU1+EwejmqqiyzazIj2NYWDk2p8 wO/YJB//SAAXbrGuD/g6ZQWO/7q+KHO7HXACm5TE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Fabian Frederick , Al Viro , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 4.4 54/62] fs/affs: use octal for permissions Date: Fri, 11 Sep 2020 14:46:37 +0200 Message-Id: <20200911122505.088073305@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Fabian Frederick [ Upstream commit 1bafd6f164d9ec9bf2fa9829051fbeb36342be0b ] According to commit f90774e1fd27 ("checkpatch: look for symbolic permissions and suggest octal instead") Link: http://lkml.kernel.org/r/20170109191208.6085-5-fabf@skynet.be Signed-off-by: Fabian Frederick Cc: Al Viro Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- fs/affs/amigaffs.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c index 5fa92bc790ef7..a148c7ecb35d3 100644 --- a/fs/affs/amigaffs.c +++ b/fs/affs/amigaffs.c @@ -390,23 +390,23 @@ prot_to_mode(u32 prot) umode_t mode = 0; if (!(prot & FIBF_NOWRITE)) - mode |= S_IWUSR; + mode |= 0200; if (!(prot & FIBF_NOREAD)) - mode |= S_IRUSR; + mode |= 0400; if (!(prot & FIBF_NOEXECUTE)) - mode |= S_IXUSR; + mode |= 0100; if (prot & FIBF_GRP_WRITE) - mode |= S_IWGRP; + mode |= 0020; if (prot & FIBF_GRP_READ) - mode |= S_IRGRP; + mode |= 0040; if (prot & FIBF_GRP_EXECUTE) - mode |= S_IXGRP; + mode |= 0010; if (prot & FIBF_OTR_WRITE) - mode |= S_IWOTH; + mode |= 0002; if (prot & FIBF_OTR_READ) - mode |= S_IROTH; + mode |= 0004; if (prot & FIBF_OTR_EXECUTE) - mode |= S_IXOTH; + mode |= 0001; return mode; } @@ -417,23 +417,23 @@ mode_to_prot(struct inode *inode) u32 prot = AFFS_I(inode)->i_protect; umode_t mode = inode->i_mode; - if (!(mode & S_IXUSR)) + if (!(mode & 0100)) prot |= FIBF_NOEXECUTE; - if (!(mode & S_IRUSR)) + if (!(mode & 0400)) prot |= FIBF_NOREAD; - if (!(mode & S_IWUSR)) + if (!(mode & 0200)) prot |= FIBF_NOWRITE; - if (mode & S_IXGRP) + if (mode & 0010) prot |= FIBF_GRP_EXECUTE; - if (mode & S_IRGRP) + if (mode & 0040) prot |= FIBF_GRP_READ; - if (mode & S_IWGRP) + if (mode & 0020) prot |= FIBF_GRP_WRITE; - if (mode & S_IXOTH) + if (mode & 0001) prot |= FIBF_OTR_EXECUTE; - if (mode & S_IROTH) + if (mode & 0004) prot |= FIBF_OTR_READ; - if (mode & S_IWOTH) + if (mode & 0002) prot |= FIBF_OTR_WRITE; AFFS_I(inode)->i_protect = prot; From patchwork Fri Sep 11 12:46:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 264043 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, 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 2BB27C433E2 for ; Fri, 11 Sep 2020 17:27:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E3D6C221EB for ; Fri, 11 Sep 2020 17:27:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845275; bh=8be14t6toKkJ2ugaHUTaO+IyU8RtEwtyfH4schRWzNI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=D3OE94w76c6UFcSpcxuHZiRvcdajy11+6uBWfR34c6GssG2ve5DEgr4AFc/+ycttF c4JkTgYS4WYK77ZDkDH22XCjMoQ5DNpsMrMKfd0AFy34AWKJ06HEEASWA8D6xyaNWQ oDsX4JCHwWjfF/z6eyKffm+s+KFG/6jEtEm+A7aU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726140AbgIKR1B (ORCPT ); Fri, 11 Sep 2020 13:27:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:49250 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726105AbgIKM6C (ORCPT ); Fri, 11 Sep 2020 08:58:02 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 338DB204EC; Fri, 11 Sep 2020 12:55:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828930; bh=8be14t6toKkJ2ugaHUTaO+IyU8RtEwtyfH4schRWzNI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lHrsT0Vrmgy/ObS8WiY8AcGPbqoKM388w5Eo/uNs8cU+R0sjNXAro4aD6slgqsTGU UhtYJs0MD4YumjySvQWyEkgn7Y3AZmhuloLBRzkfjmaevIzEmaZfECdSMh4krPv4Vx 02KUW8oyJ2bHwRL3PSnRkvy5keR9RkvKZLz+JnE4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Max Staudt , David Sterba , Sasha Levin Subject: [PATCH 4.4 55/62] affs: fix basic permission bits to actually work Date: Fri, 11 Sep 2020 14:46:38 +0200 Message-Id: <20200911122505.136472573@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Max Staudt [ Upstream commit d3a84a8d0dde4e26bc084b36ffcbdc5932ac85e2 ] The basic permission bits (protection bits in AmigaOS) have been broken in Linux' AFFS - it would only set bits, but never delete them. Also, contrary to the documentation, the Archived bit was not handled. Let's fix this for good, and set the bits such that Linux and classic AmigaOS can coexist in the most peaceful manner. Also, update the documentation to represent the current state of things. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Signed-off-by: Max Staudt Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- Documentation/filesystems/affs.txt | 16 ++++++++++------ fs/affs/amigaffs.c | 27 +++++++++++++++++++++++++++ fs/affs/file.c | 26 +++++++++++++++++++++++++- 3 files changed, 62 insertions(+), 7 deletions(-) diff --git a/Documentation/filesystems/affs.txt b/Documentation/filesystems/affs.txt index 71b63c2b98410..a8f1a58e36922 100644 --- a/Documentation/filesystems/affs.txt +++ b/Documentation/filesystems/affs.txt @@ -93,13 +93,15 @@ The Amiga protection flags RWEDRWEDHSPARWED are handled as follows: - R maps to r for user, group and others. On directories, R implies x. - - If both W and D are allowed, w will be set. + - W maps to w. - E maps to x. - - H and P are always retained and ignored under Linux. + - D is ignored. - - A is always reset when a file is written to. + - H, S and P are always retained and ignored under Linux. + + - A is cleared when a file is written to. User id and group id will be used unless set[gu]id are given as mount options. Since most of the Amiga file systems are single user systems @@ -111,11 +113,13 @@ Linux -> Amiga: The Linux rwxrwxrwx file mode is handled as follows: - - r permission will set R for user, group and others. + - r permission will allow R for user, group and others. + + - w permission will allow W for user, group and others. - - w permission will set W and D for user, group and others. + - x permission of the user will allow E for plain files. - - x permission of the user will set E for plain files. + - D will be allowed for user, group and others. - All other flags (suid, sgid, ...) are ignored and will not be retained. diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c index a148c7ecb35d3..c1b344e56e855 100644 --- a/fs/affs/amigaffs.c +++ b/fs/affs/amigaffs.c @@ -417,24 +417,51 @@ mode_to_prot(struct inode *inode) u32 prot = AFFS_I(inode)->i_protect; umode_t mode = inode->i_mode; + /* + * First, clear all RWED bits for owner, group, other. + * Then, recalculate them afresh. + * + * We'll always clear the delete-inhibit bit for the owner, as that is + * the classic single-user mode AmigaOS protection bit and we need to + * stay compatible with all scenarios. + * + * Since multi-user AmigaOS is an extension, we'll only set the + * delete-allow bit if any of the other bits in the same user class + * (group/other) are used. + */ + prot &= ~(FIBF_NOEXECUTE | FIBF_NOREAD + | FIBF_NOWRITE | FIBF_NODELETE + | FIBF_GRP_EXECUTE | FIBF_GRP_READ + | FIBF_GRP_WRITE | FIBF_GRP_DELETE + | FIBF_OTR_EXECUTE | FIBF_OTR_READ + | FIBF_OTR_WRITE | FIBF_OTR_DELETE); + + /* Classic single-user AmigaOS flags. These are inverted. */ if (!(mode & 0100)) prot |= FIBF_NOEXECUTE; if (!(mode & 0400)) prot |= FIBF_NOREAD; if (!(mode & 0200)) prot |= FIBF_NOWRITE; + + /* Multi-user extended flags. Not inverted. */ if (mode & 0010) prot |= FIBF_GRP_EXECUTE; if (mode & 0040) prot |= FIBF_GRP_READ; if (mode & 0020) prot |= FIBF_GRP_WRITE; + if (mode & 0070) + prot |= FIBF_GRP_DELETE; + if (mode & 0001) prot |= FIBF_OTR_EXECUTE; if (mode & 0004) prot |= FIBF_OTR_READ; if (mode & 0002) prot |= FIBF_OTR_WRITE; + if (mode & 0007) + prot |= FIBF_OTR_DELETE; AFFS_I(inode)->i_protect = prot; } diff --git a/fs/affs/file.c b/fs/affs/file.c index 659c579c4588b..38e0fd4caf2bb 100644 --- a/fs/affs/file.c +++ b/fs/affs/file.c @@ -426,6 +426,24 @@ static int affs_write_begin(struct file *file, struct address_space *mapping, return ret; } +static int affs_write_end(struct file *file, struct address_space *mapping, + loff_t pos, unsigned int len, unsigned int copied, + struct page *page, void *fsdata) +{ + struct inode *inode = mapping->host; + int ret; + + ret = generic_write_end(file, mapping, pos, len, copied, page, fsdata); + + /* Clear Archived bit on file writes, as AmigaOS would do */ + if (AFFS_I(inode)->i_protect & FIBF_ARCHIVED) { + AFFS_I(inode)->i_protect &= ~FIBF_ARCHIVED; + mark_inode_dirty(inode); + } + + return ret; +} + static sector_t _affs_bmap(struct address_space *mapping, sector_t block) { return generic_block_bmap(mapping,block,affs_get_block); @@ -435,7 +453,7 @@ const struct address_space_operations affs_aops = { .readpage = affs_readpage, .writepage = affs_writepage, .write_begin = affs_write_begin, - .write_end = generic_write_end, + .write_end = affs_write_end, .direct_IO = affs_direct_IO, .bmap = _affs_bmap }; @@ -793,6 +811,12 @@ done: if (tmp > inode->i_size) inode->i_size = AFFS_I(inode)->mmu_private = tmp; + /* Clear Archived bit on file writes, as AmigaOS would do */ + if (AFFS_I(inode)->i_protect & FIBF_ARCHIVED) { + AFFS_I(inode)->i_protect &= ~FIBF_ARCHIVED; + mark_inode_dirty(inode); + } + err_first_bh: unlock_page(page); page_cache_release(page); From patchwork Fri Sep 11 12:46:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 309785 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=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,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 61200C2BC11 for ; Fri, 11 Sep 2020 17:30:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2E962221E7 for ; Fri, 11 Sep 2020 17:30:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845400; bh=kx2e4of3ZWDzyOT5Xs2w6FJ2lWznfZsKxv7uI27JN08=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=rpVFaVfGzyMtvu4g8gofPIVoK1SUEJSM9DryLd3VSsPAxQLri2a158NoFeAyUeLyO JY6iPdDJbkhhmlLrb3lXzOxdv6uVVq0pXUCkxjUf9qCUNL86LKac+2YIfKjl3AP/eK sturDj6qeOuLFAZIyJFqmQ4LwbP0zoMpZ3lN1pxo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726283AbgIKR2z (ORCPT ); Fri, 11 Sep 2020 13:28:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:48794 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726103AbgIKM6C (ORCPT ); Fri, 11 Sep 2020 08:58:02 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 BCE802076C; Fri, 11 Sep 2020 12:55:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828933; bh=kx2e4of3ZWDzyOT5Xs2w6FJ2lWznfZsKxv7uI27JN08=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lkREvrn+f7GLLwt5Y7rfHW/dMadWT+2h0LMAcg2kByG8wQkpGBpfTKp60fimMlYf8 mhJ57/J9HG4cMaAhucWrBuT6UjJ/ay0+llbyyh45sYATfkICIMq21JmzPXsI/TpuZv S39PdwOf3CCBVlZS4DkwTjzDK3lCugSt7TnVZqCU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yuusuke Ashizuka , Sergei Shtylyov , "David S. Miller" Subject: [PATCH 4.4 56/62] ravb: Fixed to be able to unload modules Date: Fri, 11 Sep 2020 14:46:39 +0200 Message-Id: <20200911122505.184614231@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Yuusuke Ashizuka commit 1838d6c62f57836639bd3d83e7855e0ee4f6defc upstream. When this driver is built as a module, I cannot rmmod it after insmoding it. This is because that this driver calls ravb_mdio_init() at the time of probe, and module->refcnt is incremented by alloc_mdio_bitbang() called after that. Therefore, even if ifup is not performed, the driver is in use and rmmod cannot be performed. $ lsmod Module Size Used by ravb 40960 1 $ rmmod ravb rmmod: ERROR: Module ravb is in use Call ravb_mdio_init() at open and free_mdio_bitbang() at close, thereby rmmod is possible in the ifdown state. Fixes: c156633f1353 ("Renesas Ethernet AVB driver proper") Signed-off-by: Yuusuke Ashizuka Reviewed-by: Sergei Shtylyov Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/renesas/ravb_main.c | 110 +++++++++++++++---------------- 1 file changed, 55 insertions(+), 55 deletions(-) --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1214,12 +1214,64 @@ static const struct ethtool_ops ravb_eth .get_ts_info = ravb_get_ts_info, }; +/* MDIO bus init function */ +static int ravb_mdio_init(struct ravb_private *priv) +{ + struct platform_device *pdev = priv->pdev; + struct device *dev = &pdev->dev; + int error; + + /* Bitbang init */ + priv->mdiobb.ops = &bb_ops; + + /* MII controller setting */ + priv->mii_bus = alloc_mdio_bitbang(&priv->mdiobb); + if (!priv->mii_bus) + return -ENOMEM; + + /* Hook up MII support for ethtool */ + priv->mii_bus->name = "ravb_mii"; + priv->mii_bus->parent = dev; + snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x", + pdev->name, pdev->id); + + /* Register MDIO bus */ + error = of_mdiobus_register(priv->mii_bus, dev->of_node); + if (error) + goto out_free_bus; + + return 0; + +out_free_bus: + free_mdio_bitbang(priv->mii_bus); + return error; +} + +/* MDIO bus release function */ +static int ravb_mdio_release(struct ravb_private *priv) +{ + /* Unregister mdio bus */ + mdiobus_unregister(priv->mii_bus); + + /* Free bitbang info */ + free_mdio_bitbang(priv->mii_bus); + + return 0; +} + /* Network device open function for Ethernet AVB */ static int ravb_open(struct net_device *ndev) { struct ravb_private *priv = netdev_priv(ndev); int error; + /* MDIO bus init */ + error = ravb_mdio_init(priv); + if (error) { + netdev_err(ndev, "failed to initialize MDIO\n"); + return error; + } + napi_enable(&priv->napi[RAVB_BE]); napi_enable(&priv->napi[RAVB_NC]); @@ -1268,6 +1320,7 @@ out_free_irq: out_napi_off: napi_disable(&priv->napi[RAVB_NC]); napi_disable(&priv->napi[RAVB_BE]); + ravb_mdio_release(priv); return error; } @@ -1561,6 +1614,8 @@ static int ravb_close(struct net_device ravb_ring_free(ndev, RAVB_BE); ravb_ring_free(ndev, RAVB_NC); + ravb_mdio_release(priv); + return 0; } @@ -1664,51 +1719,6 @@ static const struct net_device_ops ravb_ .ndo_change_mtu = eth_change_mtu, }; -/* MDIO bus init function */ -static int ravb_mdio_init(struct ravb_private *priv) -{ - struct platform_device *pdev = priv->pdev; - struct device *dev = &pdev->dev; - int error; - - /* Bitbang init */ - priv->mdiobb.ops = &bb_ops; - - /* MII controller setting */ - priv->mii_bus = alloc_mdio_bitbang(&priv->mdiobb); - if (!priv->mii_bus) - return -ENOMEM; - - /* Hook up MII support for ethtool */ - priv->mii_bus->name = "ravb_mii"; - priv->mii_bus->parent = dev; - snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x", - pdev->name, pdev->id); - - /* Register MDIO bus */ - error = of_mdiobus_register(priv->mii_bus, dev->of_node); - if (error) - goto out_free_bus; - - return 0; - -out_free_bus: - free_mdio_bitbang(priv->mii_bus); - return error; -} - -/* MDIO bus release function */ -static int ravb_mdio_release(struct ravb_private *priv) -{ - /* Unregister mdio bus */ - mdiobus_unregister(priv->mii_bus); - - /* Free bitbang info */ - free_mdio_bitbang(priv->mii_bus); - - return 0; -} - static const struct of_device_id ravb_match_table[] = { { .compatible = "renesas,etheravb-r8a7790", .data = (void *)RCAR_GEN2 }, { .compatible = "renesas,etheravb-r8a7794", .data = (void *)RCAR_GEN2 }, @@ -1847,13 +1857,6 @@ static int ravb_probe(struct platform_de eth_hw_addr_random(ndev); } - /* MDIO bus init */ - error = ravb_mdio_init(priv); - if (error) { - dev_err(&pdev->dev, "failed to initialize MDIO\n"); - goto out_dma_free; - } - netif_napi_add(ndev, &priv->napi[RAVB_BE], ravb_poll, 64); netif_napi_add(ndev, &priv->napi[RAVB_NC], ravb_poll, 64); @@ -1873,8 +1876,6 @@ static int ravb_probe(struct platform_de out_napi_del: netif_napi_del(&priv->napi[RAVB_NC]); netif_napi_del(&priv->napi[RAVB_BE]); - ravb_mdio_release(priv); -out_dma_free: dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat, priv->desc_bat_dma); out_release: @@ -1899,7 +1900,6 @@ static int ravb_remove(struct platform_d unregister_netdev(ndev); netif_napi_del(&priv->napi[RAVB_NC]); netif_napi_del(&priv->napi[RAVB_BE]); - ravb_mdio_release(priv); pm_runtime_disable(&pdev->dev); free_netdev(ndev); platform_set_drvdata(pdev, NULL); From patchwork Fri Sep 11 12:46:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 264040 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=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,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 B7FDCC433E2 for ; Fri, 11 Sep 2020 17:29:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 76D3B221E7 for ; Fri, 11 Sep 2020 17:29:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845398; bh=4Xk5YfXF6sqYijZ5aWjpFFEN3fF6lqguy/KbKh6p48k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=e/znK0e/znZmAeW97s1nEbYLSiYm+jQPNyXbFzWFC5JCLbZ9pJ/n0kvyNbXGjxesL Dr+dEJdfnknR3j2SHKBrV98Ozpqk0amLD5enEB0ZCmc0u5hLaNM7bMJPStoF7pcTn3 oPUQRDhYX4yZgW1L59fXBXjmAXupKuRqGXhPi1A8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726324AbgIKR2z (ORCPT ); Fri, 11 Sep 2020 13:28:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:49206 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726109AbgIKM6C (ORCPT ); Fri, 11 Sep 2020 08:58:02 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 51C4021D79; Fri, 11 Sep 2020 12:55:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828935; bh=4Xk5YfXF6sqYijZ5aWjpFFEN3fF6lqguy/KbKh6p48k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kRmeTzsZj1YuGjrZhkDDfmi1lPMUnPIk6ZI6IRf2gh+6QDktN1Qp+9FkUR5zwWFB4 Xp3GbEerTUnRILDtkya+jETm0vpEBqLm+YrsuH+KC0D92nPKWGXhRS7NIgN+bOZqyK PO3QnyXdWggChQ6Ob83WVE+feIudD04OxHX8Xa0s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shung-Hsi Yu , "David S. Miller" Subject: [PATCH 4.4 57/62] net: ethernet: mlx4: Fix memory allocation in mlx4_buddy_init() Date: Fri, 11 Sep 2020 14:46:40 +0200 Message-Id: <20200911122505.233303498@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Shung-Hsi Yu commit cbedcb044e9cc4e14bbe6658111224bb923094f4 upstream. On machines with much memory (> 2 TByte) and log_mtts_per_seg == 0, a max_order of 31 will be passed to mlx_buddy_init(), which results in s = BITS_TO_LONGS(1 << 31) becoming a negative value, leading to kvmalloc_array() failure when it is converted to size_t. mlx4_core 0000:b1:00.0: Failed to initialize memory region table, aborting mlx4_core: probe of 0000:b1:00.0 failed with error -12 Fix this issue by changing the left shifting operand from a signed literal to an unsigned one. Fixes: 225c7b1feef1 ("IB/mlx4: Add a driver Mellanox ConnectX InfiniBand adapters") Signed-off-by: Shung-Hsi Yu Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/mellanox/mlx4/mr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/net/ethernet/mellanox/mlx4/mr.c +++ b/drivers/net/ethernet/mellanox/mlx4/mr.c @@ -114,7 +114,7 @@ static int mlx4_buddy_init(struct mlx4_b goto err_out; for (i = 0; i <= buddy->max_order; ++i) { - s = BITS_TO_LONGS(1 << (buddy->max_order - i)); + s = BITS_TO_LONGS(1UL << (buddy->max_order - i)); buddy->bits[i] = kcalloc(s, sizeof (long), GFP_KERNEL | __GFP_NOWARN); if (!buddy->bits[i]) { buddy->bits[i] = vzalloc(s * sizeof(long)); From patchwork Fri Sep 11 12:46:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 264041 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=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 0ED28C43461 for ; Fri, 11 Sep 2020 17:28:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B8D66221E7 for ; Fri, 11 Sep 2020 17:28:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845336; bh=ug9mE9ruhklk8XJEVwovo3PR5kkUnVDdg0W9JMDkpRU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=S821nOe7q6Qt0XhOBwGn0uocb+4aPgaJQiheu8q7eu65LuR1bZaZ/WqNJ3jNy/2H7 n57KSxm9CF3ZA6026vGQDlpGascpdeIazlKLNBrqy58p1It1IWWAwQ9T+mTJPQ2ZYH tcZ17t9/Zu4Xk2G1gh9e3tKblhsRxi27biy5ssg8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726095AbgIKR2z (ORCPT ); Fri, 11 Sep 2020 13:28:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:49246 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726107AbgIKM6C (ORCPT ); Fri, 11 Sep 2020 08:58:02 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 C5D3322210; Fri, 11 Sep 2020 12:55:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828938; bh=ug9mE9ruhklk8XJEVwovo3PR5kkUnVDdg0W9JMDkpRU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qJ3Nkqyvjw5pTGyj8B98Um0krd4wbShNYKwQrzCXIlXnSj1bdBpu6Aq38K35Jx09r laoGAD7rVI5cLZxCbH4084vRsY/hKgQEqn3fMVyBU/aXcCaPNf5+poWPuCl+lbyOOx WnTBlqwKTroUksx1obKsLDdlHaKz6xmvlpjAcWLI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Chan , "David S. Miller" Subject: [PATCH 4.4 58/62] bnxt_en: Failure to update PHY is not fatal condition. Date: Fri, 11 Sep 2020 14:46:41 +0200 Message-Id: <20200911122505.281166065@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Michael Chan commit ba41d46fe03223279054e58d570069fdc62fb768 upstream. If we fail to update the PHY, we should print a warning and continue. The current code to exit is buggy as it has not freed up the NIC resources yet. Signed-off-by: Michael Chan Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -4623,7 +4623,7 @@ static int __bnxt_open_nic(struct bnxt * if (link_re_init) { rc = bnxt_update_phy_setting(bp); if (rc) - goto open_err; + netdev_warn(bp->dev, "failed to update phy settings\n"); } if (irq_re_init) { From patchwork Fri Sep 11 12:46:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 309787 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=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 7CD4EC433E2 for ; Fri, 11 Sep 2020 17:28:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3922E221EB for ; Fri, 11 Sep 2020 17:28:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845286; bh=xgY5qgLudszMnYQV5SBO/5jMmhgxmIR9FqtuIluttXE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ShcYiAZtPr/cDw0k0J+/ZYJ92KVrDJmhnRumjVty8GFZ661vl5AIGibq7vj2iZHg3 VtyaBCn4svxT5wIPl98n++P/Ip9eukl4ftgBynTm9Qy6k0A7mwwCkyWy0OSaQkYnlo DVWc8lVdfhz0Y/kXd+pNEQswkxdD6kJ4m0gDqG9Q= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726239AbgIKR2E (ORCPT ); Fri, 11 Sep 2020 13:28:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:48796 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726111AbgIKM6C (ORCPT ); Fri, 11 Sep 2020 08:58:02 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 5109F22211; Fri, 11 Sep 2020 12:55:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828940; bh=xgY5qgLudszMnYQV5SBO/5jMmhgxmIR9FqtuIluttXE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YSr+k7T2b5mfyxW80zsO5wlO/IoNTMx6G8/gYaz56j1VeW1av6YOJkfAuIQKPi/37 6RwnLEQb6yifmOxQK1CmN8R/z1DoxTPR4Ta5IqhuTOjqA4kIb/40NfBdzqNk4ffID4 ce3GKFZplwevzK2+tjTe+l5ZF0uvqPiYXJNv5QPY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rob Sherwood , Jakub Kicinski , Michael Chan , "David S. Miller" Subject: [PATCH 4.4 59/62] bnxt: dont enable NAPI until rings are ready Date: Fri, 11 Sep 2020 14:46:42 +0200 Message-Id: <20200911122505.330916255@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jakub Kicinski commit 96ecdcc992eb7f468b2cf829b0f5408a1fad4668 upstream. Netpoll can try to poll napi as soon as napi_enable() is called. It crashes trying to access a doorbell which is still NULL: BUG: kernel NULL pointer dereference, address: 0000000000000000 CPU: 59 PID: 6039 Comm: ethtool Kdump: loaded Tainted: G S 5.9.0-rc1-00469-g5fd99b5d9950-dirty #26 RIP: 0010:bnxt_poll+0x121/0x1c0 Code: c4 20 44 89 e0 5b 5d 41 5c 41 5d 41 5e 41 5f c3 41 8b 86 a0 01 00 00 41 23 85 18 01 00 00 49 8b 96 a8 01 00 00 0d 00 00 00 24 <89> 02 41 f6 45 77 02 74 cb 49 8b ae d8 01 00 00 31 c0 c7 44 24 1a netpoll_poll_dev+0xbd/0x1a0 __netpoll_send_skb+0x1b2/0x210 netpoll_send_udp+0x2c9/0x406 write_ext_msg+0x1d7/0x1f0 console_unlock+0x23c/0x520 vprintk_emit+0xe0/0x1d0 printk+0x58/0x6f x86_vector_activate.cold+0xf/0x46 __irq_domain_activate_irq+0x50/0x80 __irq_domain_activate_irq+0x32/0x80 __irq_domain_activate_irq+0x32/0x80 irq_domain_activate_irq+0x25/0x40 __setup_irq+0x2d2/0x700 request_threaded_irq+0xfb/0x160 __bnxt_open_nic+0x3b1/0x750 bnxt_open_nic+0x19/0x30 ethtool_set_channels+0x1ac/0x220 dev_ethtool+0x11ba/0x2240 dev_ioctl+0x1cf/0x390 sock_do_ioctl+0x95/0x130 Reported-by: Rob Sherwood Fixes: c0c050c58d84 ("bnxt_en: New Broadcom ethernet driver.") Signed-off-by: Jakub Kicinski Reviewed-by: Michael Chan Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -4612,14 +4612,14 @@ static int __bnxt_open_nic(struct bnxt * } } - bnxt_enable_napi(bp); - rc = bnxt_init_nic(bp, irq_re_init); if (rc) { netdev_err(bp->dev, "bnxt_init_nic err: %x\n", rc); - goto open_err; + goto open_err_irq; } + bnxt_enable_napi(bp); + if (link_re_init) { rc = bnxt_update_phy_setting(bp); if (rc) @@ -4644,9 +4644,6 @@ static int __bnxt_open_nic(struct bnxt * return 0; -open_err: - bnxt_disable_napi(bp); - open_err_irq: bnxt_del_napi(bp); From patchwork Fri Sep 11 12:46:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 309786 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=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 B7D43C43461 for ; Fri, 11 Sep 2020 17:28:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 86361221E7 for ; Fri, 11 Sep 2020 17:28:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845338; bh=9/wS5bEvxO14rDm9XvJDB9b7N/Md7uB+9PBrpl3OunM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=0RXeOjmNY9/O3ZlxMEfxOCxFIt2yQZtqITn+6FX79h0dzqSCylMlPRoBe0hz6fxY+ gHbg1kCMkq3+JTZoWv0JzLFEkc0L7ioZ3dCQzWy+cW6pqXWhRj0t10/hSA4kVbF1GX 3cLiGjd8XjALi7GjOEu5lJvdxFiZB3DVh1phz1P4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726402AbgIKR24 (ORCPT ); Fri, 11 Sep 2020 13:28:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:49208 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726104AbgIKM6C (ORCPT ); Fri, 11 Sep 2020 08:58:02 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 13F5422225; Fri, 11 Sep 2020 12:55:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828943; bh=9/wS5bEvxO14rDm9XvJDB9b7N/Md7uB+9PBrpl3OunM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N+SwKR7/VOcBiAa7lDn5P8Wou6BvoaPNePVw4FaTBnzwJhKkangEk5Y0BOL8oLYuQ teAgDwDc7tpO4mSckGXur5H9TPSeCGHO6EsIlskt0kjPkw4cHBLDQAdJDaJQPog8xq u3A/B5H66ZHiDsykqhmHYKz//Si8RJi/MkR+17jU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kamil Lorenc , "David S. Miller" Subject: [PATCH 4.4 60/62] net: usb: dm9601: Add USB ID of Keenetic Plus DSL Date: Fri, 11 Sep 2020 14:46:43 +0200 Message-Id: <20200911122505.381673009@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Kamil Lorenc [ Upstream commit a609d0259183a841621f252e067f40f8cc25d6f6 ] Keenetic Plus DSL is a xDSL modem that uses dm9620 as its USB interface. Signed-off-by: Kamil Lorenc Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/usb/dm9601.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/net/usb/dm9601.c +++ b/drivers/net/usb/dm9601.c @@ -624,6 +624,10 @@ static const struct usb_device_id produc USB_DEVICE(0x0a46, 0x1269), /* DM9621A USB to Fast Ethernet Adapter */ .driver_info = (unsigned long)&dm9601_info, }, + { + USB_DEVICE(0x0586, 0x3427), /* ZyXEL Keenetic Plus DSL xDSL modem */ + .driver_info = (unsigned long)&dm9601_info, + }, {}, // END }; From patchwork Fri Sep 11 12:46:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 264039 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=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,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 D279CC43461 for ; Fri, 11 Sep 2020 17:30:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9E48022205 for ; Fri, 11 Sep 2020 17:30:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845400; bh=Z5TbhurZqMuwJnIkK3DCZTFB2mu6W+4eZ+IQQQFIlGg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=h2H3q8DGMo5k10jB9SLy9aPqz3LOzLYA1DttmK59B7UDDUmTqd8PRWEkyp/lFv87E iFQxSxYoxN0AlzkOqpgN4/lUnN41RvSnywiADuiAvSmIMi2CnemHfLgrHyVpD5xTMG y4zcI8mAT02mNzyeKlH+3GG7kQwiXPlOpegmlH+4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725869AbgIKR2z (ORCPT ); Fri, 11 Sep 2020 13:28:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:49480 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726110AbgIKM6C (ORCPT ); Fri, 11 Sep 2020 08:58:02 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 CF27B22226; Fri, 11 Sep 2020 12:55:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828946; bh=Z5TbhurZqMuwJnIkK3DCZTFB2mu6W+4eZ+IQQQFIlGg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VyPqpuzyYKxE7K+5f9lUoDf3/BAHydTfDIJEz53I5pjk1Msxz7Uh00cdUWnuq8NF1 CLBIhzCku+DsNTMSMnZhnpj/y3BTn9KdGquVNFoZ1tQ79bkKMsnzzfUy8RfXoxOqi4 AwgXrJsXlM/82F3+DvkqXzeqFeO1v8ySOhljWUgE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ying Xu , Xin Long , Marcelo Ricardo Leitner , "David S. Miller" Subject: [PATCH 4.4 61/62] sctp: not disable bh in the whole sctp_get_port_local() Date: Fri, 11 Sep 2020 14:46:44 +0200 Message-Id: <20200911122505.429694330@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Xin Long [ Upstream commit 3106ecb43a05dc3e009779764b9da245a5d082de ] With disabling bh in the whole sctp_get_port_local(), when snum == 0 and too many ports have been used, the do-while loop will take the cpu for a long time and cause cpu stuck: [ ] watchdog: BUG: soft lockup - CPU#11 stuck for 22s! [ ] RIP: 0010:native_queued_spin_lock_slowpath+0x4de/0x940 [ ] Call Trace: [ ] _raw_spin_lock+0xc1/0xd0 [ ] sctp_get_port_local+0x527/0x650 [sctp] [ ] sctp_do_bind+0x208/0x5e0 [sctp] [ ] sctp_autobind+0x165/0x1e0 [sctp] [ ] sctp_connect_new_asoc+0x355/0x480 [sctp] [ ] __sctp_connect+0x360/0xb10 [sctp] There's no need to disable bh in the whole function of sctp_get_port_local. So fix this cpu stuck by removing local_bh_disable() called at the beginning, and using spin_lock_bh() instead. The same thing was actually done for inet_csk_get_port() in Commit ea8add2b1903 ("tcp/dccp: better use of ephemeral ports in bind()"). Thanks to Marcelo for pointing the buggy code out. v1->v2: - use cond_resched() to yield cpu to other tasks if needed, as Eric noticed. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Reported-by: Ying Xu Signed-off-by: Xin Long Acked-by: Marcelo Ricardo Leitner Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/sctp/socket.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -6206,8 +6206,6 @@ static long sctp_get_port_local(struct s pr_debug("%s: begins, snum:%d\n", __func__, snum); - local_bh_disable(); - if (snum == 0) { /* Search for an available port. */ int low, high, remaining, index; @@ -6226,20 +6224,21 @@ static long sctp_get_port_local(struct s continue; index = sctp_phashfn(sock_net(sk), rover); head = &sctp_port_hashtable[index]; - spin_lock(&head->lock); + spin_lock_bh(&head->lock); sctp_for_each_hentry(pp, &head->chain) if ((pp->port == rover) && net_eq(sock_net(sk), pp->net)) goto next; break; next: - spin_unlock(&head->lock); + spin_unlock_bh(&head->lock); + cond_resched(); } while (--remaining > 0); /* Exhausted local port range during search? */ ret = 1; if (remaining <= 0) - goto fail; + return ret; /* OK, here is the one we will use. HEAD (the port * hash table list entry) is non-NULL and we hold it's @@ -6254,7 +6253,7 @@ static long sctp_get_port_local(struct s * port iterator, pp being NULL. */ head = &sctp_port_hashtable[sctp_phashfn(sock_net(sk), snum)]; - spin_lock(&head->lock); + spin_lock_bh(&head->lock); sctp_for_each_hentry(pp, &head->chain) { if ((pp->port == snum) && net_eq(pp->net, sock_net(sk))) goto pp_found; @@ -6338,10 +6337,7 @@ success: ret = 0; fail_unlock: - spin_unlock(&head->lock); - -fail: - local_bh_enable(); + spin_unlock_bh(&head->lock); return ret; } From patchwork Fri Sep 11 12:46:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 264044 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=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 D40C1C43461 for ; Fri, 11 Sep 2020 17:27:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8E75E221E7 for ; Fri, 11 Sep 2020 17:27:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845221; bh=q6Djdj5iMtLD4h1J473FEJ2zuCCDsdSzoYWwpc9on3Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=sVeRHMUO5CbqE4vSC8chIU1oD1n0Ak3yWn43ZezvlQGlzH071F6lyJQaYV5OBtQD5 onCDTcrRGELUUvm1rBsacbAY/boHLIgUw2L4o3vqSvnflQ6jUyk3iHkIe/A/fH4lK3 hVgCm9hq9QT2HaCTlerRwP7m1wCOWeIdnoM9GFmk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726114AbgIKR1A (ORCPT ); Fri, 11 Sep 2020 13:27:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:49262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726106AbgIKM6C (ORCPT ); Fri, 11 Sep 2020 08:58:02 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 8469F22228; Fri, 11 Sep 2020 12:55:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828949; bh=q6Djdj5iMtLD4h1J473FEJ2zuCCDsdSzoYWwpc9on3Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OA8o2MNVlaKg0/Qg3CkQxXrvl8/hE4TcL25XV4cGAKMyauNRGBpk/2Kgjs3bPe+0p 26G/cOYLRWbIrB06Yfud4p2rJnoFJlHQrF/jGUN6Jh5qgR88njKR5RVhqz02R4upgg 4u1sc1pZo2idfGbJvBIKIb960Y7aq3pXXX1quOBg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rob Sherwood , Jakub Kicinski , "David S. Miller" Subject: [PATCH 4.4 62/62] net: disable netpoll on fresh napis Date: Fri, 11 Sep 2020 14:46:45 +0200 Message-Id: <20200911122505.478198435@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jakub Kicinski [ Upstream commit 96e97bc07e90f175a8980a22827faf702ca4cb30 ] napi_disable() makes sure to set the NAPI_STATE_NPSVC bit to prevent netpoll from accessing rings before init is complete. However, the same is not done for fresh napi instances in netif_napi_add(), even though we expect NAPI instances to be added as disabled. This causes crashes during driver reconfiguration (enabling XDP, changing the channel count) - if there is any printk() after netif_napi_add() but before napi_enable(). To ensure memory ordering is correct we need to use RCU accessors. Reported-by: Rob Sherwood Fixes: 2d8bff12699a ("netpoll: Close race condition between poll_one_napi and napi_disable") Signed-off-by: Jakub Kicinski Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/core/dev.c | 3 ++- net/core/netpoll.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) --- a/net/core/dev.c +++ b/net/core/dev.c @@ -4849,13 +4849,14 @@ void netif_napi_add(struct net_device *d pr_err_once("netif_napi_add() called with weight %d on device %s\n", weight, dev->name); napi->weight = weight; - list_add(&napi->dev_list, &dev->napi_list); napi->dev = dev; #ifdef CONFIG_NETPOLL spin_lock_init(&napi->poll_lock); napi->poll_owner = -1; #endif set_bit(NAPI_STATE_SCHED, &napi->state); + set_bit(NAPI_STATE_NPSVC, &napi->state); + list_add_rcu(&napi->dev_list, &dev->napi_list); } EXPORT_SYMBOL(netif_napi_add); --- a/net/core/netpoll.c +++ b/net/core/netpoll.c @@ -178,7 +178,7 @@ static void poll_napi(struct net_device { struct napi_struct *napi; - list_for_each_entry(napi, &dev->napi_list, dev_list) { + list_for_each_entry_rcu(napi, &dev->napi_list, dev_list) { if (napi->poll_owner != smp_processor_id() && spin_trylock(&napi->poll_lock)) { poll_one_napi(napi);