Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5371545ybi; Tue, 4 Jun 2019 05:48:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqyQdJxUV2RtX1Fh2E0w2HKpzK5IGVxr+ZfAXh/oJ49ruDUPOHEeOggRccZIJ1YdKbI2e004 X-Received: by 2002:a63:140c:: with SMTP id u12mr3565981pgl.378.1559652497993; Tue, 04 Jun 2019 05:48:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559652497; cv=none; d=google.com; s=arc-20160816; b=L1eL5M0pelkYy3VZ2v4D/kfJadqQptRXPA8TU4YLjEOoIGlzfwS/mvXK9LxEuXObiS UiCAK4N56NEmc5Re/Hz27eUvCYb55TZgXAlibq04WiSQ7X87W67Wd6g/p7sDr/Wgk+Dg yVRbggX7ICQxluGem2UBJnFSJ5Xtr6sU2ZXCnsXH+J1HOZf2HXIAvq0yUDQZQI18+IBC eCWoSa6lM3spdovIAqNcOPkw2StFnT1un2uuNo+Swx9DGOy/6yLquVZGiXcgkb2wgvGy V4P5G6sGuaHrqG4Mlt04qc7tIlAWHCQgYrVcKHVHBlpy49FYXiyrI7ovCnbtZ2/FRc6m 0TZw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:cc:references:to:subject; bh=gtvphjgyMugZSN9H9qlHZUTgF00Vpeu7iwo1GetAIlo=; b=C1gHxRfoHtU90zqEYbubuUnK4X4a9TmgpnxEPCBNJudYixRGzzwFwwnz7YKfcd5pHj 8DNzhkScMFEQFwmYczdw8XWXqfTeKKV5Npkerxe+EsKCIyljhI//2q3PloLTX62zD2ne NmKXdn4ebXQPNa1RGPJn3Sntu+bUuOJdQ9YTb6sF1EpkKmanjvg7VuVcNCKNEjwwsFAh POU33UeUN+Kb6bn/U+4vbpWVHi0h6xhlVoFhB+3gWgW9F+YiqATOP3932WjFP+HR3xMv 05NBtaSyTPPYjedUcecQb77DBMc60j5/4Wng3zedbdWX2jTNdS7NIVdu3SzQSwdQBoZf g2Qw== 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 n9si24261690pff.14.2019.06.04.05.48.01; Tue, 04 Jun 2019 05:48:17 -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; 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 S1727853AbfFDMq1 (ORCPT + 99 others); Tue, 4 Jun 2019 08:46:27 -0400 Received: from www62.your-server.de ([213.133.104.62]:50958 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727709AbfFDMq1 (ORCPT ); Tue, 4 Jun 2019 08:46:27 -0400 Received: from [78.46.172.3] (helo=sslproxy06.your-server.de) by www62.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1hY8pa-00046h-T5; Tue, 04 Jun 2019 14:46:22 +0200 Received: from [178.197.249.21] (helo=linux.home) by sslproxy06.your-server.de with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1hY8pa-000BRN-Ma; Tue, 04 Jun 2019 14:46:22 +0200 Subject: Re: [PATCH] net: compat: fix msg_controllen overflow in scm_detach_fds_compat() To: Young Xiao <92siuyang@gmail.com> References: <1559651505-18137-1-git-send-email-92siuyang@gmail.com> Cc: davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, eric.dumazet@gmail.com From: Daniel Borkmann Message-ID: Date: Tue, 4 Jun 2019 14:46:21 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <1559651505-18137-1-git-send-email-92siuyang@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.100.3/25470/Tue Jun 4 10:01:16 2019) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/04/2019 02:31 PM, Young Xiao wrote: > There is a missing check between kmsg->msg_controllen and cmlen, > which can possibly lead to overflow. > > This bug is similar to vulnerability that was fixed in commit 6900317f5eff > ("net, scm: fix PaX detected msg_controllen overflow in scm_detach_fds"). Back then I mentioned in commit 6900317f5eff: In case of MSG_CMSG_COMPAT (scm_detach_fds_compat()), I haven't seen an issue in my tests as alignment seems always on 4 byte boundary. Same should be in case of native 32 bit, where we end up with 4 byte boundaries as well. Do you have an actual reproducer or is it based on code inspection? > Signed-off-by: Young Xiao <92siuyang@gmail.com> > --- > net/compat.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/net/compat.c b/net/compat.c > index a031bd3..8e74dfb 100644 > --- a/net/compat.c > +++ b/net/compat.c > @@ -301,6 +301,8 @@ void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm) > err = put_user(cmlen, &cm->cmsg_len); > if (!err) { > cmlen = CMSG_COMPAT_SPACE(i * sizeof(int)); > + if (kmsg->msg_controllen < cmlen) > + cmlen = kmsg->msg_controllen; > kmsg->msg_control += cmlen; > kmsg->msg_controllen -= cmlen; > } >