Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3288911ybb; Tue, 31 Mar 2020 02:10:48 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvmsZjAzyBW7cvpSYs0Sk6CpeOIXFP/sUJpRt90hVpkthDRgpNOc+XAssCTCBGgT5bPInyZ X-Received: by 2002:aca:3284:: with SMTP id y126mr1291481oiy.175.1585645848103; Tue, 31 Mar 2020 02:10:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585645848; cv=none; d=google.com; s=arc-20160816; b=G/Bri6LccVljGh75ym88W172KrIVOOAsC0nIW6dCIR5Ka7aawYtFLrka9SaEQ1FA1+ BLlXekC3bUvMcixSlwV+LftyyCOX+UwsC2MCFTQsZJGHoEZUQqiXHeU2f5D9YQZgdqRZ 4nAiF9wTFgClEgB12ar8tm17ApxIA+4TBhNRUqsXpC0RUZG3JNedyGj0fZJUwuN50jUG CEFHPdq8xVWNHLaA//CsKAD/twBdl93uzo27krBby65dfUKhCwAJvz18zQ8VEvIwnX/l w1LL29Fa64dYPvjJjr02rGMUJxaJoma4WyElLY3iNnaihWoh1iQzp/UqSS4OldvIaaxI Xdow== 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=l8nqnsHrQe0l19sKJ6XWXzNjdWDtAtRja4C9NxRSPN8=; b=tjgEJDKsw2ELp018dxPY+IrnKvxLOQOEn39nOmhZGJTPev+ncKL6HRVHVhR9ygWbp/ etUss+0LC83xzmgkroWiwJoXSb+Uf4ZIr+gykznKKMR5Z30s5Dhd+RwY2HiDnI18AgaL thAnkEhAZWJ15u3TU4Wu2dbQxxj9k0gFTmUINkwbCLF9CTQ/thr6Y56S8lQTyrZjYTZH T9KAmfJqeAFUz1/9DHehPsj8WuovUuYuvhNI3aGfdYGnNAHFbwWmVusZ8YnXHBEgFWWB spiHjVGqHQLofMhCVtf4ROeZaotOUjHes5zYcx+ovvZvo2M6h85Mj/QgRrEjORHiIY2M b7Ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="RZl/TOb0"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p203si6983862oic.214.2020.03.31.02.10.35; Tue, 31 Mar 2020 02:10:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="RZl/TOb0"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731448AbgCaJJO (ORCPT + 99 others); Tue, 31 Mar 2020 05:09:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:52180 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731202AbgCaJJM (ORCPT ); Tue, 31 Mar 2020 05:09:12 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 601AF20675; Tue, 31 Mar 2020 09:09:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585645751; bh=Ne9+LlSQFMWHN1DGAzP8M7ivWUlamrWM9ZR/Ae2AiRA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RZl/TOb0Ohz9+cv7C7LtfXVOZV8lr1z0PMoJuKiJP6/DyKDyIwXP7RUu2pxXZ8L0q 4SV6hhkTBUPb4YMMfbmg2mvy/45dUFq04/BAiNn2BPjRQdSgVLjTmlfB0Vvw3Ie80t u6UAoc2nV58O+N/UlWnfUyg4WHdWHalgcV8C2THg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anthony Mallet , Oliver Neukum , Matthias Reichl Subject: [PATCH 5.5 152/170] USB: cdc-acm: restore capability check order Date: Tue, 31 Mar 2020 10:59:26 +0200 Message-Id: <20200331085439.279687524@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200331085423.990189598@linuxfoundation.org> References: <20200331085423.990189598@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matthias Reichl commit 62d65bdd9d05158aa2547f8ef72375535f3bc6e3 upstream. commit b401f8c4f492c ("USB: cdc-acm: fix rounding error in TIOCSSERIAL") introduced a regression by changing the order of capability and close settings change checks. When running with CAP_SYS_ADMIN setting the close settings to the values already set resulted in -EOPNOTSUPP. Fix this by changing the check order back to how it was before. Fixes: b401f8c4f492c ("USB: cdc-acm: fix rounding error in TIOCSSERIAL") Cc: Anthony Mallet Cc: stable Cc: Oliver Neukum Signed-off-by: Matthias Reichl Link: https://lore.kernel.org/r/20200327150350.3657-1-hias@horus.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/class/cdc-acm.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c @@ -923,16 +923,16 @@ static int set_serial_info(struct tty_st mutex_lock(&acm->port.mutex); - if ((ss->close_delay != old_close_delay) || - (ss->closing_wait != old_closing_wait)) { - if (!capable(CAP_SYS_ADMIN)) + if (!capable(CAP_SYS_ADMIN)) { + if ((ss->close_delay != old_close_delay) || + (ss->closing_wait != old_closing_wait)) retval = -EPERM; - else { - acm->port.close_delay = close_delay; - acm->port.closing_wait = closing_wait; - } - } else - retval = -EOPNOTSUPP; + else + retval = -EOPNOTSUPP; + } else { + acm->port.close_delay = close_delay; + acm->port.closing_wait = closing_wait; + } mutex_unlock(&acm->port.mutex); return retval;