Received: by 10.223.185.116 with SMTP id b49csp6356453wrg; Wed, 28 Feb 2018 08:06:05 -0800 (PST) X-Google-Smtp-Source: AH8x2266SKw8jEZY/xbbDwfttqFQ1y2WzexUhvCnHLS2fntwmYLbgrNa9kHCWUr3o5MaztvnA9E6 X-Received: by 10.98.196.199 with SMTP id h68mr18087777pfk.42.1519833965369; Wed, 28 Feb 2018 08:06:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519833965; cv=none; d=google.com; s=arc-20160816; b=TPIPne3Vu4YGSoh3OCgBwot90LS+xdMVIUAxm5IG0bI7Sscp4A8b3qiCICqBj6tyZk JrYYHV5kKOjAJSrI7v+P++xSiMd1hLkU3GHB9ZpV9A0RsIZ5E93Gll0cKnRYlE/G1+JH LCBdDfUPhyIw+liE0bLg1gaNWN65M4NNBuBFePVSU0t7zC+nKcnSP447rsiOsKZVQLWL Aq2mqXQwfovFhSBMThGlpJVJqv/t6wuIry2hHH8J7SvTxC6Bc1j7a1OkrOJqxkYkZ/XW OkFVD/0w3jsBRQwYNtEKecX2gcNOj+sS2w1Rjj1beNhXZt/CEpHryBqh82/WL40QOywW vZVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=L9mXpaMpnuqccpiz+8QqAUNbXynTcy5CL3IJEp7PXFs=; b=aVyEs3OB0GqwL4Ee4N7/oMoqv2vg5cV8TAc0ni/GFfosbNFWVRIU/6RhZ04TPCIl/N u3IDgCLvdj+Ehtsu4EOomZtw2pXvzIwWEKf0v/JcFztof1tZ10CbMTJ6IY54jjqA3N6k L4LO16a7v7J9jaSnBeoeQ5MOrr9+K5yWlbq+ACobCHBTAq83VAUSYtpk2d567j1QvXML iwk4eVx2clp94OOsHBDzHkwY2gzwfUZ7C2Y9wtUCEcnyE23oyaUG4Qms9SI5ELV3cXTT vR8yj0IFtSepNAudTmaD3FZiFA/O/YFvCYtm03XeuQ52Hva/OMuJVXPiUycZcVQZ9qbA Gsqw== ARC-Authentication-Results: i=1; mx.google.com; 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 c1-v6si1441554pld.401.2018.02.28.08.05.50; Wed, 28 Feb 2018 08:06:05 -0800 (PST) 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; 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 S932345AbeB1QCw (ORCPT + 99 others); Wed, 28 Feb 2018 11:02:52 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:34728 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932224AbeB1QCt (ORCPT ); Wed, 28 Feb 2018 11:02:49 -0500 Received: from [2a02:8011:400e:2:6f00:88c8:c921:d332] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1er3Yi-0006XR-JQ; Wed, 28 Feb 2018 15:22:20 +0000 Received: from ben by deadeye with local (Exim 4.90_1) (envelope-from ) id 1er3Yh-00007k-5Z; Wed, 28 Feb 2018 15:22:19 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Shuah Khan" , "Greg Kroah-Hartman" , "Juan Zea" Date: Wed, 28 Feb 2018 15:20:18 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 130/254] usbip: fix usbip bind writing random string after command in match_busid In-Reply-To: X-SA-Exim-Connect-IP: 2a02:8011:400e:2:6f00:88c8:c921:d332 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.55-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Juan Zea commit 544c4605acc5ae4afe7dd5914147947db182f2fb upstream. usbip bind writes commands followed by random string when writing to match_busid attribute in sysfs, caused by using full variable size instead of string length. Signed-off-by: Juan Zea Acked-by: Shuah Khan Signed-off-by: Greg Kroah-Hartman [bwh: Backported to 3.16: adjust context] Signed-off-by: Ben Hutchings --- drivers/staging/usbip/userspace/src/utils.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) --- a/drivers/staging/usbip/userspace/src/utils.c +++ b/drivers/staging/usbip/userspace/src/utils.c @@ -30,6 +30,7 @@ int modify_match_busid(char *busid, int char command[SYSFS_BUS_ID_SIZE + 4]; char match_busid_attr_path[SYSFS_PATH_MAX]; int rc; + int cmd_size; snprintf(match_busid_attr_path, sizeof(match_busid_attr_path), "%s/%s/%s/%s/%s/%s", SYSFS_MNT_PATH, SYSFS_BUS_NAME, @@ -37,12 +38,14 @@ int modify_match_busid(char *busid, int attr_name); if (add) - snprintf(command, SYSFS_BUS_ID_SIZE + 4, "add %s", busid); + cmd_size = snprintf(command, SYSFS_BUS_ID_SIZE + 4, "add %s", + busid); else - snprintf(command, SYSFS_BUS_ID_SIZE + 4, "del %s", busid); + cmd_size = snprintf(command, SYSFS_BUS_ID_SIZE + 4, "del %s", + busid); rc = write_sysfs_attribute(match_busid_attr_path, command, - sizeof(command)); + cmd_size); if (rc < 0) { dbg("failed to write match_busid: %s", strerror(errno)); return -1;