Received: by 2002:a17:90a:1609:0:0:0:0 with SMTP id n9csp840435pja; Wed, 1 Apr 2020 09:39:09 -0700 (PDT) X-Google-Smtp-Source: APiQypJX5HSds86Bdbg+Fs+WrKdKsSFILnrNR6P1pimD+txeOKUa7Ckg6PjaMn0KntnhPMkeaPn9 X-Received: by 2002:aca:d50f:: with SMTP id m15mr3698200oig.19.1585759149156; Wed, 01 Apr 2020 09:39:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585759149; cv=none; d=google.com; s=arc-20160816; b=S6O5KykMVBlVtW6lsbt+g7sSm7egJ39WZtNlUyzq27qrgblIavhS3TozmnbwzfRV7V w2OYS5S6QHzLbkk7QwGWuZ61AmaMYBprhJnRP6lPcMTWCpyQobUpoYN4bpnh9joBuR+i yS2i6z4eirIeIHLrK1a5cwc1eLw2qp/HzBI0KirT3WWCjMQYZ9ZwZH28SaddAJ+cNn0E UQu9AXqLH/KT+On7wq8wd1fIptGVoMBtQAb8u94Vg6VrVtmmMjF8dOltKL3Sieselbac o/l7mXNvpeGDlFfEPq7KhrcbiXtm6D+cDRmqDVq6P4n08PzY/tO7YEboSA5mk6F3IHhW bmLg== 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=N594vw2vBNVuMBT1syuFPo70RxqKcJBkG6UX0ymLYqA=; b=Z9y1VbU7SdNgpy27mXy5bkoVGNXlAVucbErU65f4tYDe7x8glDtwEhQIhohon5DlIw eel4NpGjttQ16xGaG99n0BuihclSCdKzNj/mA4O2jl55H3BujqHRCZ4nKxe5VSHFuyZ1 jtJ4NzbgUHuqXABcLqx8bb3H/EJUU8LZOqsDUT+Zl2nc+mwMxDnTTJmxRcNYO8sj+V0Y dMGRr8CSj4pyBf/mAdTNcWL4MaH3kSBGDUNqMDM5U4mUxoKzyoC6vFwmQELdz7igjLPh VKGXms6A4+cFD5pyGe0R3lCQzM9kE3g0h/TKixv4NqDjvBW1LfcbMv9VCXsaV9dfuQkC W9xA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=p8Vnt3l8; 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 d16si1079064oti.42.2020.04.01.09.38.56; Wed, 01 Apr 2020 09:39:09 -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=p8Vnt3l8; 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 S1733036AbgDAQid (ORCPT + 99 others); Wed, 1 Apr 2020 12:38:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:38228 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388483AbgDAQi3 (ORCPT ); Wed, 1 Apr 2020 12:38:29 -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 A6E5720658; Wed, 1 Apr 2020 16:38:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585759109; bh=dFjXY1QlWtybV0vDkb/h3x6ZtJMyOFc9h+GDlPWsSm4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p8Vnt3l8mDvTVJ1z3RYdoIkQlvf17etSQFxQCTc5ANElsybkOfL+wIOWGBTxGIC1K Ihrz9N1zan7qu/0EA3cmWXKqq/SVhkw3GVbvzRugdFlY0t2Xb9el+BlFz7KwDrSTBN QFbYpvnhTEypbapXLx0nnUAQvfue2dOvphYIX9Ao= 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 4.9 077/102] USB: cdc-acm: restore capability check order Date: Wed, 1 Apr 2020 18:18:20 +0200 Message-Id: <20200401161545.546407859@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200401161530.451355388@linuxfoundation.org> References: <20200401161530.451355388@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 @@ -863,16 +863,16 @@ static int set_serial_info(struct acm *a mutex_lock(&acm->port.mutex); - if ((new_serial.close_delay != old_close_delay) || - (new_serial.closing_wait != old_closing_wait)) { - if (!capable(CAP_SYS_ADMIN)) + if (!capable(CAP_SYS_ADMIN)) { + if ((new_serial.close_delay != old_close_delay) || + (new_serial.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;