Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5354884ybi; Tue, 4 Jun 2019 05:32:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqwKWMejrlUFOGW92/wGjSSM6zMIvgheucozvvpy+vjBHI0E5pXQxbQyD0I1sB+7lzntmJyn X-Received: by 2002:a17:90a:a116:: with SMTP id s22mr36324181pjp.51.1559651543401; Tue, 04 Jun 2019 05:32:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559651543; cv=none; d=google.com; s=arc-20160816; b=ZWRuJzRqgC6/xOntDPWC27Y7aiCsa7drlWa6R6wZUbBGfTLP/Kumiu/qJ8H2Vv73+1 3UbaMtCnx7FuD51H2641xsaPxzhw4svggSuj98p0hEPiNtsFyvW+H3i8OYa/6DqYwN3h HnNOO27q92pCdwfHqOcASOQbpOi/7ArmnXmvxgjwCCmdDA5z3HygGyOiMrWK4MGlgPiT Wl+MgOL5SymnlFLykwnvx30p1Qw4ML/CjvGabiB+ZMihP1nG5ehxeIydoRACcyBU1W0G 0iJmqTsvm53bOCM8fye+deD7RbZCPA/q6qNSQpYfgWDL6q4LxziJ7668cZ5bD/buyaNS TqOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=6HDzC7R+RL6DjYFySUs1ztmYGpeRF4flURMQGfgz8ek=; b=eRscl/emuLDRFcEYbWHVd61ndSQTcU2M61i271PprVVNqboJmDxhpmda4cLCBCLTI3 gkgqytcfRE56HKuwzx/hyciGbgkP9JPcdSRQPWlFiw6gg/VJ89iWcRzl/iXCCFD/aC4L c7f6FCQJbogXG7Z1H+sIO2kJnQvWLjMkyZ5ye+oZ4H/g9cNDyMYgzSs5yz19EXAluTiK Js9kLLSIiUsBHvbO8otMU6eNOPjEn6FZFzbbYV0bWxxXQxqUnyNJtP3Bmn5B1eRPFyRE Rk6xUBg3nfyIecPzg4y+jgHwUqcDaSyaNvZXT5Sb5DtkGy38bXFrjOuO/Qe+aI1Epppd K5nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WoQIZydC; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a4si20565748plm.209.2019.06.04.05.32.06; Tue, 04 Jun 2019 05:32:23 -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=@gmail.com header.s=20161025 header.b=WoQIZydC; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727779AbfFDMaj (ORCPT + 99 others); Tue, 4 Jun 2019 08:30:39 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:44339 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726994AbfFDMag (ORCPT ); Tue, 4 Jun 2019 08:30:36 -0400 Received: by mail-pf1-f194.google.com with SMTP id t16so3779705pfe.11; Tue, 04 Jun 2019 05:30:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=6HDzC7R+RL6DjYFySUs1ztmYGpeRF4flURMQGfgz8ek=; b=WoQIZydCeh0fjhw/TBqjgdAJFJ96KSB7ecnpoTGfCGUFFp6p0gFO/2EHv5Y2kolD+Q lDco3Su5Wue2nWstBr/2r+eJW3tn1R1JY2QGvq8qExTzsZIFPhYSkrILFlr5Hd/0PXUx 8KfrWiaa+Zlr6zYs3Am+KCtcQknBt6bFUGhFfwri77WfemH+ofLLqRet2GVUpgCl+Sv1 BCAe+LRvB7hEOVK1UdZ0NufKGKr/V9m88LANh+GaRsVU88aYtwpm8Qf+bAiyI3EfFq6i 4IoBqjleCPWP5Uz7HwYsPwr8tU/Ny3j+Djv7Cd9OLJmSY/oARV6zsR0WmXbyP+4qpcrV 6WIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=6HDzC7R+RL6DjYFySUs1ztmYGpeRF4flURMQGfgz8ek=; b=KYbDH5YTCv50NCiGVkglKy98hnZCZ+iFe39bkL2jVmctlMA1MMa12QrXY3Lfaf/POZ g7Udv7ts3cW+MiI6aUl/ViSBw/dNoebd8j1V9cF1MrDIZwXUlihiFdLIg5yEPqXrhRke Pv57G9QW0edF5/+eiCxDLoVYhSfhIuv/9E0oe+rU2iWYuT6cy3Zei5AdBuAi72xdfP7z fd7pXPIu2L8GJCmdYll5cF2fdCAdOmS+7Y+OxfCOxAGXWP8Ul6VW2y3alOnnkq7PZKIG 1RDw7nAjPRWNSPzSg9aFHtwxN9zxH9e78n1/4mCuIb5GNbwu/wjoEYzyyAHgeZCXeqYe wJZQ== X-Gm-Message-State: APjAAAUq4GbTQrQUyiiJOhcnhrWK/JMEfukV8c1jyYHbZtv8VaMDOHjw Ga++/NQhoggqrLv/OygkdK0650gG0Y1wpQ== X-Received: by 2002:a17:90a:35c:: with SMTP id 28mr35237599pjf.110.1559651435842; Tue, 04 Jun 2019 05:30:35 -0700 (PDT) Received: from xy-data.openstacklocal (ecs-159-138-22-150.compute.hwclouds-dns.com. [159.138.22.150]) by smtp.gmail.com with ESMTPSA id f10sm23734078pgo.14.2019.06.04.05.30.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Jun 2019 05:30:35 -0700 (PDT) From: Young Xiao <92siuyang@gmail.com> To: davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Young Xiao <92siuyang@gmail.com> Subject: [PATCH] net: compat: fix msg_controllen overflow in scm_detach_fds_compat() Date: Tue, 4 Jun 2019 20:31:45 +0800 Message-Id: <1559651505-18137-1-git-send-email-92siuyang@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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"). 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; } -- 2.7.4