From mboxrd@z Thu Jan 1 00:00:00 1970 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=-6.8 required=3.0 tests=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 00579C2D0F2 for ; Wed, 1 Apr 2020 16:28:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C71C4212CC for ; Wed, 1 Apr 2020 16:28:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585758518; bh=MpayfXopxg/rWdzTRI0RFVYc1nBvqXgUxTLUgzl8GvU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=PdVrg4+U9FsZytokFHWQ6XlLV0U/hdjrzViYH/p9K0gzdrXWOuQPyv5QO8zTrDbrv qJP6JH5g8TgVFpAfecq05YLt6s507K4xfzfpF899ZS4yRFb3/pMFvflAR3EfDZA5Ev I/VTlESL0h1nvCmRZ+7763/yXJ9Szy/FYV6R5+pU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388106AbgDAQ2V (ORCPT ); Wed, 1 Apr 2020 12:28:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:53678 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388100AbgDAQ2U (ORCPT ); Wed, 1 Apr 2020 12:28:20 -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 CF8C820BED; Wed, 1 Apr 2020 16:28:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585758500; bh=MpayfXopxg/rWdzTRI0RFVYc1nBvqXgUxTLUgzl8GvU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V50Ra+LpI2fJqf8lSyT8oXN/COyoWp5SDyBHJYv7/RnY//nDGTASxH1+/Tyntcbmr KK7k24uo+f8a5zbwn/tCkkAZVyG0dkU4+fcdrNB7zYYx+sJdzcKd80x1tHop9pBM0Y tzAbEyXA0KcNSmVMo1LIBIPonjLcp8KSfneA6Y7Y= 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.19 082/116] USB: cdc-acm: restore capability check order Date: Wed, 1 Apr 2020 18:17:38 +0200 Message-Id: <20200401161553.051896608@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200401161542.669484650@linuxfoundation.org> References: <20200401161542.669484650@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 @@ -949,16 +949,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;